![]() |
ImFusion SDK 4.3
|
Namespace containing general framework initialization methods. More...
Namespace containing general framework initialization methods.
Classes | |
struct | InitConfig |
Record to configure the initialization of the ImFusion SDK. More... | |
struct | PluginInfo |
Functions | |
std::function< void()> | defaultLicenseInitFunction () |
Returns the license initialization function which is set in the InitConfig by default. | |
void | init (InitConfig &&initializationSettings={}) |
Performs general initialization of the framework. | |
void | deinit () |
De-intializes the framework. | |
bool | isInitialized () |
Returns whether the framework was successfully initialized. | |
void | installSignalHandlers () |
Installs signal handlers for SIGINT and SIGTERM that call deinit() and exit gracefully. | |
void | loadPlugins (const std::vector< std::string > &pluginFolders=std::vector< std::string >()) |
Load and register/initializes all ImFusion plugins from the specified folders. | |
bool | loadPlugin (const std::string &pluginFilename) |
Load and register/initialize a single ImFusion plugin, returns true on success. | |
bool | loadRequiredPlugins (const std::vector< std::string > &pluginLibraryNames, const std::vector< std::string > &pluginFolders=std::vector< std::string >()) |
Load and register/initialize all requested plugins, returns true on success. | |
void | addBlacklistedPluginLibraryName (std::string libraryName) |
Blacklist a libraryName in the plugin folder and prevent it from being loaded. | |
void | registerPlugin (std::unique_ptr< ImFusionPlugin > plugin, const std::string &name="", const std::string &path="") |
Registers and initializes a new ImFusionPlugin. | |
std::vector< PluginInfo > | loadedPlugins () |
Returns a list of all currently loaded plugins. | |
template<typename T> | |
T * | queryLoadedPlugin () |
Returns the ImFusionPlugin of the given type if it has been loaded. | |
ImFusionPlugin * | queryLoadedPlugin (const std::string &pluginName) |
Returns the ImFusionPlugin with the given name if it has been loaded. | |
Utils::Version | version () |
Returns the version of the ImFusion SDK. | |
std::string | versionInfoString () |
Returns a string containing information about the version of the ImFusionLib. | |
void | init (const InitConfig &initializationSettings)=delete |
std::function< void()> defaultLicenseInitFunction | ( | ) |
Returns the license initialization function which is set in the InitConfig by default.
The returned function tries to activate a license if no license is active by using the environment variable IMFUSION_LICENSE_KEY
if it is set. If license activation fails it throws a MissingLicenseException.
void init | ( | InitConfig && | initializationSettings = {} | ) |
Performs general initialization of the framework.
Default initialization settings are defined by the default values of the InitConfig struct. You can customize the initialization process by providing a custom instance. Be advised that due to the std::unique_ptr in this struct, you can only move it into the init() function.
By default, (with default Framework::InitConfig) this function does not load any plugins yet. If you are using an ApplicationController, it can take care of SDK initialization as well, so that you don't have to call this function directly. If the framework has already been initialized, this function does nothing.
A license must be activated inside Framework::InitConfig::licenseInitFunction. If nothing is specified, the default implementation is used, which reads the license key from the environment variable IMFUSION_LICENSE_KEY
. Alternatively, you can set your own function (see below and LicenseManagerSDK)
Example of a complete initialization:
MissingLicenseException | if the license is invalid |
GL::OpenGLNotFoundException | if the OpenGL context could not be initialized |
void deinit | ( | ) |
De-intializes the framework.
Deinitialize the logging framework.
Deletes the main OpenGL context and unloads all plugins. This should only be called at the end of the application and if init() was called before. Does nothing if the framework was not initialized yet.
void installSignalHandlers | ( | ) |
Installs signal handlers for SIGINT and SIGTERM that call deinit() and exit gracefully.
This only has an effect on UNIX-like systems.
void loadPlugins | ( | const std::vector< std::string > & | pluginFolders = std::vector< std::string >() | ) |
Load and register/initializes all ImFusion plugins from the specified folders.
If pluginFolders is empty, the following default search paths are used:
Windows platforms:
IMFUSION_PLUGIN_PATH
environment variableUnix platforms:
IMFUSION_PLUGIN_PATH
environment variablePlugin names defined in the environment variable IMFUSION_PLUGIN_BLACKLIST
as a semi-colon-separated list (e.g. "Foo.dll;Bar.dll") will not be loaded by this function. This mechanism can also be used to explicitly ignore libraries that might conflict with or crash the application.
bool loadPlugin | ( | const std::string & | pluginFilename | ) |
Load and register/initialize a single ImFusion plugin, returns true on success.
This is useful to load a single plugin from a non-standard path without setting the IMFUSION_PLUGIN_PATH environment variable. If the plugin name is blacklisted, loading of such library will be skipped, see addBlacklistedPluginLibraryName
pluginFilename | Full path to the .dll/.so/.dylib plugin file to load. |
bool loadRequiredPlugins | ( | const std::vector< std::string > & | pluginLibraryNames, |
const std::vector< std::string > & | pluginFolders = std::vector< std::string >() ) |
Load and register/initialize all requested plugins, returns true on success.
This is useful, in particular for regulatory purposes, to ensure that the application has these plugins and no additional ones. One can provide a folder location for the plugins. If that is empty, the following default search paths are used:
Windows platforms:
IMFUSION_PLUGIN_PATH
environment variableUnix platforms:
IMFUSION_PLUGIN_PATH
environment variablepluginLibraryNames | The names of the desired plugins e.g. { "ImFusionSeg", "ImFusionReg", "TorchPlugin" } |
pluginFolders | The folder(s) where the plugins are located. If empty, default paths will be searched. |
void addBlacklistedPluginLibraryName | ( | std::string | libraryName | ) |
Blacklist a libraryName in the plugin folder and prevent it from being loaded.
Adds the name of a library to the list of blacklisted .dll/.so/.dylib which shall not be loaded by Framework::loadPlugins(). This can useful to skip loading of libraries which are not ImFusion plugins but might be required to sit next to an ImFusion plugin. Call this function in your main.cpp, before calling Framework::loadPlugins()
void registerPlugin | ( | std::unique_ptr< ImFusionPlugin > | plugin, |
const std::string & | name = "", | ||
const std::string & | path = "" ) |
Registers and initializes a new ImFusionPlugin.
Optionally a display name can be passed (otherwise ImFusionPlugin::pluginName is used). If the plugin was loaded from a file (e.g. a .dll or .so) the path argument should be set to the absolute path to that file. This method is internally called by loadPlugins and loadPlugin. Can be used if you need full control of the construction of the ImFusionPlugin.
T * queryLoadedPlugin | ( | ) |
Returns the ImFusionPlugin of the given type if it has been loaded.
Returns nullptr, if no such plugin has been loaded.
ImFusionPlugin * queryLoadedPlugin | ( | const std::string & | pluginName | ) |
Returns the ImFusionPlugin with the given name if it has been loaded.
Returns nullptr, if no such plugin has been loaded.
std::string versionInfoString | ( | ) |
Returns a string containing information about the version of the ImFusionLib.
Format: "ImFusionLib Version <Version> built on <Year>-<Month>-<Day>.";