Computer Assited Medical Intervention Tool Kit  version 5.0
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:
+ Collaboration diagram for camitk::ExtensionManager:

Public Types

enum  ExtensionType { ACTION, COMPONENT, APPLICATION, VIEWER }
 

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, const QString &globalInstallDir, const QString &userInstallDir, const QString &currentWorkingDir)
 Returns a three char string that corresponds to the installation directory of a given shared library. More...
 
static bool loadExtension (ExtensionType type, QString file)
 Load a specific extension from a file. More...
 
Component extension list management
static ComponentExtensiongetComponentExtension (QString)
 get the plugin corresponding to a given extension or name. More...
 
static const QList< ComponentExtension * > getComponentExtensionsList ()
 Get the list of registered ComponentExtension. More...
 
static ComponentExtensiongetDataDirectoryComponentExtension (QString)
 get the plugin corresponding to a given data directory component extension's name. More...
 
static const QList< ComponentExtension * > getDataDirectoryComponentsList ()
 Get the list of registered ComponentExtension working on directory. 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 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 instantiated actions More...
 
static const QList< ActionExtension * > getActionExtensionsList ()
 Get the list of registered ActionExtension. More...
 
static ActionExtensiongetActionExtension (QString)
 Get the ActionExtension corresponding to the given shared library file. More...
 
static bool unloadActionExtension (QString)
 Unload an action extension using its .dll/.so/.dylib filename. More...
 
Viewer extension list management
static void unloadAllViewerExtensions ()
 unload all viewer extensions and delete instantiated actions More...
 
static const QList< ViewerExtension * > getViewerExtensionsList ()
 Get the list of registered ViewerExtension. More...
 
static ViewerExtensiongetViewerExtension (QString)
 Get the Viewer Extension corresponding to the given shared library file. More...
 
static bool unloadViewerExtension (QString)
 Unload an viewer extension using its .dll/.so/.dylib filename. More...
 

Static Private Member Functions

static void addLibraryPath (QDir potentialPath, QString potentialLibDir)
 check if the given directory contains an extension repository and if it does update PATH (on windows) and call QCoreApplication::addLibraryPath for the given directory and all derived possible extension directories (actions, components and viewers) To check if it contains an extension repository, the given QString is used More...
 
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...
 
static QMap< QString, ViewerExtension * > & getViewerExtensionMap ()
 get the singleton map of loaded viewer plugins (the key is the shared object/dll/dylib filename) This is the private (intern) method. More...
 
static void initPrivateLibDirs ()
 Add the private library directories (lib/camitk-version) in the current session PATH: More...
 
Custom comparaison methods
static bool componentExtensionLessThan (const ComponentExtension *left, const ComponentExtension *right)
 Custom comparaison method between two ComponentExtension* This method uses the QString::<() (less than operator) to perform the comparaison of two ComponentExtension* based on their name. More...
 
static bool actionExtensionLessThan (ActionExtension *left, ActionExtension *right)
 Custom comparaison method between two ActionExtension* This method uses the QString::<() (less than operator) to perform the comparaison of two ActionExtension* based on their name. More...
 
static bool viewerExtensionLessThan (ViewerExtension *left, ViewerExtension *right)
 Custom comparaison method between two ViewerExtension* based on the same principle as actionExtensionLessThan(..) 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 Enumeration Documentation

◆ ExtensionType

describes the CamiTK Extension Type (Action, Component, Application...). CamiTK follows Component-Based programming architecture. The Service Layer defines four types of extensions.

Enumerator
ACTION 

Action extensions: manages the processing logic.

COMPONENT 

Component extensions: manages the data logic.

APPLICATION 

MainWindow extensions: manages the application logic.

VIEWER 

Viewer extensions: manages the presentation and user interaction logic.

Member Function Documentation

◆ actionExtensionLessThan()

bool camitk::ExtensionManager::actionExtensionLessThan ( ActionExtension left,
ActionExtension right 
)
staticprivate

Custom comparaison method between two ActionExtension* This method uses the QString::<() (less than operator) to perform the comparaison of two ActionExtension* based on their name.

This method is used for sorting alphabitically a list of ActionExtension*.

Parameters
leftleft ActionExtension* to compare
rightright ActionExtension* to compare
Returns
the comparaison result, based on their name (alphabitically order)
Note
This method does not take const input arguments as the ActionExtension::getName() accessor is a mutable method (not const). This should be updated, but would change the CamiTK API check the Wiki for Code developer guidelines

◆ addLibraryPath()

void camitk::ExtensionManager::addLibraryPath ( QDir  potentialPath,
QString  potentialLibDir 
)
staticprivate

check if the given directory contains an extension repository and if it does update PATH (on windows) and call QCoreApplication::addLibraryPath for the given directory and all derived possible extension directories (actions, components and viewers) To check if it contains an extension repository, the given QString is used

◆ autoload() [1/2]

void camitk::ExtensionManager::autoload ( )
static

Autoload component and action extensions.

Referenced by camitk::Application::Application(), and main().

+ Here is the caller graph for this function:

◆ autoload() [2/2]

void camitk::ExtensionManager::autoload ( ExtensionManager::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

References CAMITK_TRACE_ALT, and getPluginFileNames().

+ Here is the call graph for this function:

◆ componentExtensionLessThan()

bool camitk::ExtensionManager::componentExtensionLessThan ( const ComponentExtension left,
const ComponentExtension right 
)
staticprivate

Custom comparaison method between two ComponentExtension* This method uses the QString::<() (less than operator) to perform the comparaison of two ComponentExtension* based on their name.

This method is used for sorting alphabitically a list of ComponentExtension*.

Parameters
leftleft ComponentExtension* to compare
rightright ComponentExtension* to compare
Returns
the comparaison result, based on their name (alphabitically order)

Referenced by getComponentExtension().

+ Here is the caller graph for this function:

◆ getActionExtension()

ActionExtension * camitk::ExtensionManager::getActionExtension ( QString  file)
static

Get the ActionExtension corresponding to the given shared library file.

If the given shared library is not loaded return nullptr. The shared library file should be given as a complete filepath in the QString.

Returns
nullptr if the given shared library complete path is not loaded.

References unloadViewerExtension().

+ Here is the call graph for this function:

◆ getActionExtensionMap()

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 action 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

References unloadActionExtension().

+ Here is the call graph for this function:

◆ getActionExtensionsList()

const QList< ActionExtension * > camitk::ExtensionManager::getActionExtensionsList ( )
static

Get the list of registered ActionExtension.

The list contains unique elements (no duplicates possible) and is alphabitically sorted.

Note
The list is read-only and cannot be modified. This list is useful to loop over the loaded ActionExtension, especially when order counts.
Returns
list of unique ActionExtension loaded in the Core.

◆ getComponentExtension()

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

get the plugin corresponding to a given extension or name.

References componentExtensionLessThan(), and getComponentExtensionMap().

Referenced by camitk::Application::open(), and camitk::Application::save().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getComponentExtensionMap()

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

Referenced by getComponentExtension(), and unloadActionExtension().

+ Here is the caller graph for this function:

◆ getComponentExtensionsList()

const QList< ComponentExtension * > camitk::ExtensionManager::getComponentExtensionsList ( )
static

Get the list of registered ComponentExtension.

The list contains unique elements (no duplicates possible) and is alphabitically sorted.

Note
The list is read-only and cannot be modified. This list is useful to loop over the loaded ComponentExtension, especially when order counts.
Returns
list of unique ComponentExtension loaded in the Core.

Referenced by main().

+ Here is the caller graph for this function:

◆ getDataDirectoryComponentExtension()

ComponentExtension * camitk::ExtensionManager::getDataDirectoryComponentExtension ( QString  pluginName)
static

get the plugin corresponding to a given data directory component extension's name.

Referenced by camitk::Application::openDirectory().

+ Here is the caller graph for this function:

◆ getDataDirectoryComponentExtensionMap()

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

◆ getDataDirectoryComponentsList()

const QList< ComponentExtension * > camitk::ExtensionManager::getDataDirectoryComponentsList ( )
static

Get the list of registered ComponentExtension working on directory.

The list contains unique elements (no duplicates possible) and is alphabitically sorted.

Note
The list is read-only and cannot be modified. This list is useful to loop over the loaded ComponentExtension, especially when order counts.
Returns
list of unique ComponentExtension working on data directory loaded in the Core.

◆ getDataDirectoryExtNames()

QStringList camitk::ExtensionManager::getDataDirectoryExtNames ( )
static

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

◆ getExtensionFilter()

QStringList camitk::ExtensionManager::getExtensionFilter ( )
staticprivate

return the extensions file filter

◆ getFileExtensions()

QStringList camitk::ExtensionManager::getFileExtensions ( )
static

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

Referenced by camitk::Application::Application().

+ Here is the caller graph for this function:

◆ getInstallationString()

QString camitk::ExtensionManager::getInstallationString ( QString  file,
const QString &  globalInstallDir,
const QString &  userInstallDir,
const QString &  currentWorkingDir 
)
static

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

The shared library should be the complete filename corresponding to a component or action 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
globalInstallDirthe global installation directory
userInstallDirthe user installation directory
currentWorkingDirthe current working directory

◆ getPluginFileNames()

QStringList camitk::ExtensionManager::getPluginFileNames ( QDir  extensionsDir)
staticprivate

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

Referenced by autoload().

+ Here is the caller graph for this function:

◆ getViewerExtension()

ViewerExtension * camitk::ExtensionManager::getViewerExtension ( QString  file)
static

Get the Viewer Extension corresponding to the given shared library file.

If the given shared library is not loaded return nullptr. The shared library file should be given as a complete filepath in the QString.

Returns
nullptr if the given shared library complete path is not loaded.

◆ getViewerExtensionMap()

QMap< QString, ViewerExtension * > & camitk::ExtensionManager::getViewerExtensionMap ( )
staticprivate

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

The viewer extension map is updated by loadViewerExtension, unloadViewerExtension and autoloadViewerExtensions. 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

Referenced by unloadAllActionExtensions(), and unloadAllViewerExtensions().

+ Here is the caller graph for this function:

◆ getViewerExtensionsList()

const QList< ViewerExtension * > camitk::ExtensionManager::getViewerExtensionsList ( )
static

Get the list of registered ViewerExtension.

The list contains unique elements (no duplicates possible) and is alphabitically sorted.

Note
The list is read-only and cannot be modified. This list is useful to loop over the loaded ViewerExtension, especially when order counts.
Returns
list of unique ViewerExtension loaded in the Core.

Referenced by camitk::Application::getNewViewer(), and camitk::Application::getViewerExtension().

+ Here is the caller graph for this function:

◆ initPrivateLibDirs()

void camitk::ExtensionManager::initPrivateLibDirs ( )
staticprivate

Add the private library directories (lib/camitk-version) in the current session PATH:

  • the current build library directory
  • the local installation library directory
  • the global installation library directory Note that we also add the actions and component private library subdirectories. Uses addLibraryPath(). Takes multiarch into account.

◆ loadExtension()

bool camitk::ExtensionManager::loadExtension ( ExtensionManager::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

Referenced by main().

+ Here is the caller graph for this function:

◆ registerFileExtension()

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

Referenced by camitk::Application::Application().

+ Here is the caller graph for this function:

◆ unloadActionExtension()

bool camitk::ExtensionManager::unloadActionExtension ( QString  fileName)
static

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

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

References getComponentExtensionMap().

Referenced by getActionExtensionMap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unloadAllActionExtensions()

void camitk::ExtensionManager::unloadAllActionExtensions ( )
static

unload all action extensions and delete instantiated actions

References getViewerExtensionMap(), and viewerExtensionLessThan().

Referenced by camitk::Application::quitting().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unloadAllViewerExtensions()

void camitk::ExtensionManager::unloadAllViewerExtensions ( )
static

unload all viewer extensions and delete instantiated actions

References getViewerExtensionMap(), and camitk::Application::unregisterAllViewers().

Referenced by camitk::Application::quitting().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unloadComponentExtension()

bool camitk::ExtensionManager::unloadComponentExtension ( QString  extOrName)
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

◆ unloadViewerExtension()

bool camitk::ExtensionManager::unloadViewerExtension ( QString  fileName)
static

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

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

Referenced by getActionExtension().

+ Here is the caller graph for this function:

◆ viewerExtensionLessThan()

bool camitk::ExtensionManager::viewerExtensionLessThan ( ViewerExtension left,
ViewerExtension right 
)
staticprivate

Custom comparaison method between two ViewerExtension* based on the same principle as actionExtensionLessThan(..)

See also
actionExtensionLessThan(..) for more information

Referenced by unloadAllActionExtensions().

+ Here is the caller graph for this function:

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