Computer Assited Medical Intervention Tool Kit  version 4.1
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>

Inherits QObject.

Public Types

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

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

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 see https://forge.imag.fr/plugins/mediawiki/wiki/camitk/index.php/Core_developper_guidelines

References camitk::ActionExtension::getName().

Referenced by getActionExtensionsList().

◆ autoload() [1/2]

void camitk::ExtensionManager::autoload ( )
static

Autoload component and action extensions.

References ACTION, and COMPONENT.

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

◆ 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 ACTION, CAMITK_ERROR_ALT, CAMITK_TRACE_ALT, COMPONENT, camitk::Core::getActionDirectories(), camitk::Core::getComponentDirectories(), getPluginFileNames(), camitk::Application::getSettings(), and loadExtension().

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

References camitk::ComponentExtension::getName().

Referenced by getComponentExtensionsList(), and getDataDirectoryComponentsList().

◆ 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 getActionExtensionMap().

Referenced by camitk::SettingsDialog::on_removeActionExtensionButton_released().

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

Referenced by getActionExtension(), getActionExtensionsList(), loadExtension(), unloadActionExtension(), and unloadAllActionExtensions().

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

References actionExtensionLessThan(), and getActionExtensionMap().

Referenced by camitk::Core::getConfig(), and camitk::SettingsDialog::updateActionExtensionList().

◆ getComponentExtension()

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

◆ 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(), getComponentExtensionsList(), getFileExtensions(), loadExtension(), and unloadComponentExtension().

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

References componentExtensionLessThan(), and getComponentExtensionMap().

Referenced by camitk::Core::getConfig(), camitk::ImageAcquisitionComponentExtension::getImagerList(), camitk::ImageAcquisitionComponentExtension::getInstance(), main(), and camitk::SettingsDialog::updateComponentExtensionList().

◆ getDataDirectoryComponentExtension()

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

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

References getDataDirectoryComponentExtensionMap().

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

◆ 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

Referenced by getComponentExtension(), getDataDirectoryComponentExtension(), getDataDirectoryComponentsList(), getDataDirectoryExtNames(), loadExtension(), and unloadComponentExtension().

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

References componentExtensionLessThan(), and getDataDirectoryComponentExtensionMap().

Referenced by camitk::Core::getConfig(), and camitk::SettingsDialog::updateComponentExtensionList().

◆ getDataDirectoryExtNames()

QStringList camitk::ExtensionManager::getDataDirectoryExtNames ( )
static

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

References getDataDirectoryComponentExtensionMap().

◆ getExtensionFilter()

QStringList camitk::ExtensionManager::getExtensionFilter ( )
staticprivate

return the extensions file filter

References camitk::Core::debugPostfix, camitk::Core::isDebugBuild(), and camitk::Core::soVersion.

Referenced by getPluginFileNames().

◆ getFileExtensions()

QStringList camitk::ExtensionManager::getFileExtensions ( )
static

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

References getComponentExtensionMap().

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

◆ 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

Referenced by camitk::Core::getConfig().

◆ getPluginFileNames()

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

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

References camitk::Core::debugPostfix, getExtensionFilter(), and camitk::Core::isDebugBuild().

Referenced by autoload().

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

References camitk::Core::getCurrentWorkingDir(), camitk::Core::getGlobalInstallDir(), camitk::Core::getUserInstallDir(), and camitk::Core::shortVersion.

Referenced by loadExtension().

◆ loadExtension()

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

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

◆ 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 getActionExtensionMap(), camitk::ActionExtension::getActions(), camitk::Action::getName(), and camitk::Application::unregisterAllActions().

Referenced by camitk::SettingsDialog::on_removeActionExtensionButton_released(), and unloadAllActionExtensions().

◆ unloadAllActionExtensions()

void camitk::ExtensionManager::unloadAllActionExtensions ( )
static

unload all action extensions and delete instantiated actions

References getActionExtensionMap(), and unloadActionExtension().

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

◆ 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

References getComponentExtensionMap(), getDataDirectoryComponentExtensionMap(), and camitk::ComponentExtension::getLocation().

Referenced by camitk::SettingsDialog::on_removeComponentExtensionButton_released().


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