Computer Assisted Medical Intervention Tool Kit  version 6.0
Loading...
Searching...
No Matches
camitk::ExtensionManager Class Reference

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

#include <ExtensionManager.h>

Public Types

enum  ExtensionType { ACTION , COMPONENT , APPLICATION , VIEWER }
 describes the CamiTK Extension Type (Action, Component, Application...). More...
enum  InstallationRepository {
  GLOBAL , LOCAL , WORKING_DIRECTORY , USER ,
  NOT_REGISTERED
}
 corresponds to where the extension is installed More...

Static Public Member Functions

static void autoload ()
 Autoload component, action and viewer extensions (dlls) as well as registered CamiTK extension file.
static void autoload (ExtensionType type)
 Autoload all the extension of a given type.
static InstallationRepository getInstallationRepository (const QString &extensionName)
 Returns the enum corresponding to the installation repository (directory) of a given shared library.
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.
static bool loadExtension (ExtensionType type, QString file)
 Load a specific extension from a file.
static bool registerNewComponentExtension (ComponentExtension *ce, QString filename=QString())
 Register the given ComponentExtension.
Component extension list management
static ComponentExtensiongetComponentExtension (QString)
 get the plugin corresponding to a given extension or name.
static const QList< ComponentExtension * > getComponentExtensionsList ()
 Get the list of registered ComponentExtension.
static ComponentExtensiongetDataDirectoryComponentExtension (QString)
 get the plugin corresponding to a given data directory component extension's name.
static const QList< ComponentExtension * > getDataDirectoryComponentsList ()
 Get the list of registered ComponentExtension working on directory.
static QStringList getFileExtensions ()
 get the list of all the suffixes managed by registered component extensions (all possible file suffix)
static QStringList getDataDirectoryExtNames ()
 get the list of all the name of the registered Component data directory
static void registerFileExtension (QString fileExtension)
 Register the file extension with the current application for opening This function is called by registerFileExtensions.
static bool unloadComponentExtension (QString)
 Unload a plugin corresponding to a given extension or component name.
Action extension list management
static void unloadAllActionExtensions ()
 unload all action extensions and delete instantiated actions
static const QList< ActionExtension * > getActionExtensionsList ()
 Get the list of registered ActionExtension.
static ActionExtensiongetActionExtension (QString)
 Get the ActionExtension corresponding to the given shared library file.
static bool unloadActionExtension (QString)
 Unload an action extension using its .dll/.so/.dylib filename.
Viewer extension list management
static void unloadAllViewerExtensions ()
 unload all viewer extensions and delete instantiated actions
static const QList< ViewerExtension * > getViewerExtensionsList ()
 Get the list of registered ViewerExtension.
static ViewerExtensiongetViewerExtension (QString)
 Get the Viewer Extension corresponding to the given shared library file.
static bool unloadViewerExtension (QString)
 Unload an viewer extension using its .dll/.so/.dylib filename.

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.

◆ InstallationRepository

corresponds to where the extension is installed

Enumerator
GLOBAL 

the extension is installed on the system (global install)

LOCAL 

the extension is installed in the user defined installation directory (local install)

WORKING_DIRECTORY 

the extension is installed in the current working directory (development stage)

USER 

the extension is registered in the user configuration file (could be anywhere)

NOT_REGISTERED 

the extension is not registered in any of the recognized installation repository

Member Function Documentation

◆ autoload() [1/2]

void camitk::ExtensionManager::autoload ( )
static

Autoload component, action and viewer extensions (dlls) as well as registered CamiTK extension file.

References ACTION, autoload(), COMPONENT, camitk::Application::setProgressBarValue(), camitk::Application::showStatusBarMessage(), and VIEWER.

Referenced by camitk::Application::Application(), autoload(), 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(), camitk::Application::getSettings(), camitk::Core::getViewerDirectories(), loadExtension(), and VIEWER.

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

◆ getActionExtensionsList()

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

Get the list of registered ActionExtension.

The list contains unique elements (no duplicates possible) and is alphabetically 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.

Referenced by camitk::Core::getConfig(), camitk::Core::getConfigAsJson(), and getInstallationRepository().

◆ getComponentExtension()

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

get the plugin corresponding to a given extension or name.

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

◆ getComponentExtensionsList()

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

Get the list of registered ComponentExtension.

The list contains unique elements (no duplicates possible) and is alphabetically 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 OpenAction::apply(), SaveAsAction::apply(), camitk::Core::getConfig(), camitk::Core::getConfigAsJson(), camitk::ImageAcquisitionComponentExtension::getImagerList(), camitk::ImageAcquisitionComponentExtension::getInstance(), main(), and OpenFile::selectFile().

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

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

Referenced by camitk::Core::getConfig(), and camitk::Core::getConfigAsJson().

◆ getDataDirectoryExtNames()

QStringList camitk::ExtensionManager::getDataDirectoryExtNames ( )
static

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

Referenced by SaveAsAction::apply(), and ImpMainWindow::updateOpenDirectoryMenu().

◆ 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(), OpenAction::apply(), and OpenFile::selectFile().

◆ getInstallationRepository()

ExtensionManager::InstallationRepository camitk::ExtensionManager::getInstallationRepository ( const QString & extensionName)
static

Returns the enum corresponding to the installation repository (directory) of a given shared library.

The shared library should be the name corresponding to the value of getName() of an existing ComponentExtension, ActionExtension or ViewerExtension.

The following string code are returned:

  • GLOBAL for an extension installed in the global installation directory (where CamiTK SDK is installed)
  • LOCAL for an extension installed in the user configuration directory (local install)
  • WORKING for an extension loaded directly from the current working directory (build installation tree)
  • USER for an extension loaded manually by the user
  • NOT_REGISTERED the extension name was not found in the list of loaded extensions
Note
calls getInstallationString and Core methods.
Returns
the enum value corresponding to the type of installation repository/directory
Parameters
extensionNamethe extension plugin name (i.e. the extension getName() value)

References getActionExtensionsList(), camitk::Core::getCurrentWorkingDir(), camitk::Core::getGlobalInstallDir(), getInstallationString(), camitk::Core::getUserInstallDir(), GLOBAL, LOCAL, NOT_REGISTERED, USER, and WORKING_DIRECTORY.

◆ 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/fullpath filename corresponding to a component, action or viewer extension.

The following enum value is 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

References camitk::Core::libDir().

Referenced by camitk::Core::getConfig(), camitk::Core::getConfigAsJson(), and getInstallationRepository().

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

◆ getViewerExtensionsList()

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

Get the list of registered ViewerExtension.

The list contains unique elements (no duplicates possible) and is alphabetically 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::Core::getConfig(), camitk::Core::getConfigAsJson(), camitk::Application::getNewViewer(), and loadExtension().

◆ loadExtension()

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

◆ registerNewComponentExtension()

bool camitk::ExtensionManager::registerNewComponentExtension ( ComponentExtension * ce,
QString filename = QString() )
static

Register the given ComponentExtension.

If the given ComponentExtension is managing file extensions that are already registered, it will not be registered, and this method will return false and a info message will be printed with more information.

Parameters
cevalid ComponentExtension pointer (loaded from a shared library plugin (.dll/.so/.dylib) or instantiated programmatically)
filename(optional) if the extension was loaded from a shared library (.dll/.so/.dylib), path to this file
Returns
true if the extension was registered without error

References CAMITK_INFO_ALT, camitk::ComponentExtension::getFileExtensions(), camitk::ComponentExtension::getLocation(), camitk::ComponentExtension::getName(), camitk::ComponentExtension::hasDataDirectory(), camitk::ComponentExtension::initResources(), and camitk::ComponentExtension::setLocation().

Referenced by loadExtension().

◆ 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 camitk::Application::unregisterAllActions().

Referenced by unloadAllActionExtensions().

◆ unloadAllActionExtensions()

void camitk::ExtensionManager::unloadAllActionExtensions ( )
static

unload all action extensions and delete instantiated actions

References unloadActionExtension().

◆ unloadAllViewerExtensions()

void camitk::ExtensionManager::unloadAllViewerExtensions ( )
static

unload all viewer extensions and delete instantiated actions

References unloadViewerExtension().

◆ 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 camitk::ComponentExtension::getLocation(), and unloadComponentExtension().

Referenced by unloadComponentExtension().

◆ 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

References camitk::Application::unregisterAllViewers().

Referenced by unloadAllViewerExtensions().


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