ImFusion SDK 4.3
ImFusion::Framework Namespace Reference

Namespace containing general framework initialization methods. More...

Detailed Description

Namespace containing general framework initialization methods.

See also
What is the correct way to initialize the ImFusionLib and its plugins? License System

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< PluginInfoloadedPlugins ()
 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.
 
ImFusionPluginqueryLoadedPlugin (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
 

Function Documentation

◆ defaultLicenseInitFunction()

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.

◆ init()

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:

initConfig.licenseInitFunction = []() {
LicenseManagerSDK::setLicenseKey("XXXX-XXXX-XXXX-XXXX");
};
initConfig.loadPlugins = true;
Framework::init(std::move(initConfig));
void init(InitConfig &&initializationSettings={})
Performs general initialization of the framework.
int setLicenseKey(std::string_view key)
Set license key An online activation is performed.
bool isActivated()
Check whether a valid license is installed.
Record to configure the initialization of the ImFusion SDK.
Definition Framework.h:35
bool loadPlugins
Flag whether to search for plugins using Framework::loadPlugins().
Definition Framework.h:67
std::function< void()> licenseInitFunction
Function will be called once during framework initialization just before checking the license state.
Definition Framework.h:74
Exceptions
MissingLicenseExceptionif the license is invalid
GL::OpenGLNotFoundExceptionif the OpenGL context could not be initialized

◆ deinit()

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.

◆ installSignalHandlers()

void installSignalHandlers ( )

Installs signal handlers for SIGINT and SIGTERM that call deinit() and exit gracefully.

This only has an effect on UNIX-like systems.

◆ loadPlugins()

void loadPlugins ( const std::vector< std::string > & pluginFolders = std::vectorstd::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 variable
  • <executable-path>/plugins
  • <ImFusionLib.dll-path>/plugins

Unix platforms:

  • IMFUSION_PLUGIN_PATH environment variable
  • <ImFusionLib.so-path>/../lib/ImFusionLib/plugins

Plugin 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.

◆ loadPlugin()

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

Parameters
pluginFilenameFull path to the .dll/.so/.dylib plugin file to load.

◆ loadRequiredPlugins()

bool loadRequiredPlugins ( const std::vector< std::string > & pluginLibraryNames,
const std::vector< std::string > & pluginFolders = std::vectorstd::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 variable
  • <executable-path>/plugins
  • <ImFusionLib.dll-path>/plugins

Unix platforms:

  • IMFUSION_PLUGIN_PATH environment variable
  • <ImFusionLib.so-path>/../lib/ImFusionLib/plugins
Parameters
pluginLibraryNamesThe names of the desired plugins e.g. { "ImFusionSeg", "ImFusionReg", "TorchPlugin" }
pluginFoldersThe folder(s) where the plugins are located. If empty, default paths will be searched.

◆ addBlacklistedPluginLibraryName()

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()

◆ registerPlugin()

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.

◆ queryLoadedPlugin() [1/2]

template<typename T>
T * queryLoadedPlugin ( )

Returns the ImFusionPlugin of the given type if it has been loaded.

Returns nullptr, if no such plugin has been loaded.

◆ queryLoadedPlugin() [2/2]

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.

◆ versionInfoString()

std::string versionInfoString ( )

Returns a string containing information about the version of the ImFusionLib.

Format: "ImFusionLib Version <Version> built on <Year>-<Month>-<Day>.";

Search Tab / S to search, Esc to close