Computer Assited Medical Intervention Tool Kit  version 3.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Public Types | Static Public Member Functions | Static Private Member Functions | List of all members
camitk::ExtensionManager Class Reference

This class is used to manage all plugins loaded by the application. More...

#include <ExtensionManager.h>

+ Inheritance diagram for camitk::ExtensionManager:

Public Types

enum  
 
enum  ExtensionType { ACTION, COMPONENT, APPLICATION, VIEWER }
 describes the CamiTK Extension Type (Action, Component, Application...). More...
 

Static Public Member Functions

static void autoload ()
 Autoload component and action extensions. More...
 
static void autoload (ExtensionType type)
 Autoload all the extension of a given type. More...
 
static QString getInstallationString (QString file)
 Returns a three char string that corresponds to the installation directory of a given extension. More...
 
static bool loadExtension (ExtensionType type, QString file)
 Load a specific extension from a file. More...
 
Component extension list management
static const ComponentExtensiongetComponentExtension (QString)
 
static const QMap< QString,
ComponentExtension * > & 
getComponentExtensions ()
 get all the registered component extensions that can manage file (default component extension) This is the public method (return a const, the extensions map is private and cannot be modified externally). More...
 
static const QMap< QString,
ComponentExtension * > & 
getDataDirectoryComponents ()
 get all the registered component extensions that can manage entire directories This is the public method (return a const, the extensions map is private and cannot be modified externally). More...
 
static QStringList getFileExtensions ()
 get the list of all the suffixes managed by registered component extensions (all possible file suffix) More...
 
static QStringList getDataDirectoryExtNames ()
 get the list of all the name of the registered Component data directory More...
 
static void registerFileExtension (QString fileExtension)
 Register the file extension with the current application for opening This function is called by registerFileExtensions. More...
 
static bool promptRegisterFileExtensions (QStringList fileExtensions)
 Prompt the user if he wants the current application to natively (by default) open the following file extensions. More...
 
static bool unloadComponentExtension (QString)
 Unload a plugin corresponding to a given extension or component name. More...
 
Action extension list management
static void unloadAllActionExtensions ()
 unload all action extensions and delete instanciated actions More...
 
static const QMap< QString,
ActionExtension * > & 
getActionExtensions ()
 get all the registered action extension (key is the share object/dll/dylib filename that contains the ActionExtension). More...
 
static bool unloadActionExtension (QString)
 Unload an action extension using its .dll/.so/.dylib filename. More...
 

Static Private Member Functions

static QMap< QString,
ActionExtension * > & 
getActionExtensionMap ()
 get the singleton map of loaded action plugins (the key is the shared object/dll/dylib filename) This is the private (intern) method. More...
 
static QMap< QString,
ComponentExtension * > & 
getComponentExtensionMap ()
 get the singleton map of loaded component plugins for files (the key is the file extension) This is the private (intern) method. More...
 
static QMap< QString,
ComponentExtension * > & 
getDataDirectoryComponentExtensionMap ()
 get the singleton map of loaded component plugins for data directory (the key is the name) This is the private (intern) method. More...
 
static QStringList getExtensionFilter ()
 return the extensions file filter More...
 
static QStringList getPluginFileNames (QDir)
 return the list of shared objects in a directory considering debug/release on MSVC More...
 

Detailed Description

This class is used to manage all plugins loaded by the application.

The current version is able to load dynamic library for

This class is a contained for all the loaded extension. It contains only static members.

Member Function Documentation

static void camitk::ExtensionManager::autoload ( )
static

Autoload component and action extensions.

static void camitk::ExtensionManager::autoload ( ExtensionType  type)
static

Autoload all the extension of a given type.

This method try to load all the extensions of the given type that are found (in this specific order) :

  • in the current working directory (considered as an install directory), this should be the build directory (load extensions that are just being compiled, before their installation
  • in the user config directory (CamiTK user install)
  • in the system-wide install (CamiTK global install)
  • and in the list of user-registered extensions (stored in the configuration directory)

Duplicates found within the installation directory are removed (e.g. if you have the extension x.so in the build directory as well as the user directory, only the extension in the build directory will be loaded (it takes precedence).

Parameters
typethe extension type
static QMap<QString, ActionExtension*>& camitk::ExtensionManager::getActionExtensionMap ( )
staticprivate

get the singleton map of loaded action plugins (the key is the shared object/dll/dylib filename) This is the private (intern) method.

The component extension map is updated by loadActionExtension, unloadActionExtension and autoloadActionExtensions. This method follows the "construct on first use" idiom/design-pattern. It therefore avoids the infamous "static initialization order fiasco", see http://www.parashift.com/c++-faq/ctors.html

static const QMap<QString, ActionExtension*>& camitk::ExtensionManager::getActionExtensions ( )
static

get all the registered action extension (key is the share object/dll/dylib filename that contains the ActionExtension).

This is the public method (return a const, the extensions map is private and cannot be modified externally).

static const ComponentExtension* camitk::ExtensionManager::getComponentExtension ( QString  )
static

get the plugin corresponding to a given extension or name (const, you can only use this method to get information, use open to open a file using a specific plugin)

static QMap<QString, ComponentExtension*>& camitk::ExtensionManager::getComponentExtensionMap ( )
staticprivate

get the singleton map of loaded component plugins for files (the key is the file extension) This is the private (intern) method.

The component extension map is updated by loadComponentExtension, unloadComponentExtension and autoloadComponentExtensions. This method follows the "construct on first use" idiom/design-pattern. It therefore avoids the infamous "static initialization order fiasco", see http://www.parashift.com/c++-faq/ctors.html

static const QMap<QString, ComponentExtension*>& camitk::ExtensionManager::getComponentExtensions ( )
static

get all the registered component extensions that can manage file (default component extension) This is the public method (return a const, the extensions map is private and cannot be modified externally).

static QMap<QString, ComponentExtension*>& camitk::ExtensionManager::getDataDirectoryComponentExtensionMap ( )
staticprivate

get the singleton map of loaded component plugins for data directory (the key is the name) This is the private (intern) method.

The data directory component extension map is updated by loadExtension, unloadExtension and autoloadExtensions. This method follows the "construct on first use" idiom/design-pattern. It therefore avoids the infamous "static initialization order fiasco", see http://www.parashift.com/c++-faq/ctors.html

static const QMap<QString, ComponentExtension*>& camitk::ExtensionManager::getDataDirectoryComponents ( )
static

get all the registered component extensions that can manage entire directories This is the public method (return a const, the extensions map is private and cannot be modified externally).

static QStringList camitk::ExtensionManager::getDataDirectoryExtNames ( )
static

get the list of all the name of the registered Component data directory

static QStringList camitk::ExtensionManager::getExtensionFilter ( )
staticprivate

return the extensions file filter

static QStringList camitk::ExtensionManager::getFileExtensions ( )
static

get the list of all the suffixes managed by registered component extensions (all possible file suffix)

static QString camitk::ExtensionManager::getInstallationString ( QString  file)
static

Returns a three char string that corresponds to the installation directory of a given extension.

It works for all type of extension.

The following string code are returned:

  • [G] for an extension installed in the global installation directory (where CamiTK SDK is installed)
  • [L] for an extension installed in the user configuration directory (local install)
  • [W] for an extension loaded directly from the current working directory (build installation tree)
  • [U] for an extension loaded manually by the user
Returns
the string coding for the installation
Parameters
filethe extension plugin file
static QStringList camitk::ExtensionManager::getPluginFileNames ( QDir  )
staticprivate

return the list of shared objects in a directory considering debug/release on MSVC

static bool camitk::ExtensionManager::loadExtension ( ExtensionType  type,
QString  file 
)
static

Load a specific extension from a file.

This methods loads a ActionExtension, ComponentExtension,... plugin from a .dll/.so/.dylib filename

Parameters
typethe extension type
filethe plugin filename (.dll/.so/.dylib)
Returns
false if it cannot be loaded
static bool camitk::ExtensionManager::promptRegisterFileExtensions ( QStringList  fileExtensions)
static

Prompt the user if he wants the current application to natively (by default) open the following file extensions.

Parameters
fileExtensionsThe list of file extensions (without the prefixed '.').
Returns
The decision of the user regarding the file association.
static void camitk::ExtensionManager::registerFileExtension ( QString  fileExtension)
static

Register the file extension with the current application for opening This function is called by registerFileExtensions.

Parameters
fileExtensionthe file extension to associate with the current application for opening
static bool camitk::ExtensionManager::unloadActionExtension ( QString  )
static

Unload an action extension using its .dll/.so/.dylib filename.

Returns
false if the plugin could not be unloaded - still in use somewhere
static void camitk::ExtensionManager::unloadAllActionExtensions ( )
static

unload all action extensions and delete instanciated actions

static bool camitk::ExtensionManager::unloadComponentExtension ( QString  )
static

Unload a plugin corresponding to a given extension or component name.

Returns
false if the plugin could not be unloaded - still in use somewhere

The documentation for this class was generated from the following file: