Slicer  5.3
Slicer is a multi-platform, free and open source software package for visualization and medical image computing
List of all members | Public Types | Properties | Public Slots | Signals | Public Member Functions | Protected Member Functions | Protected Attributes
qSlicerAbstractModuleFactoryManager Class Reference

#include <Base/QTCore/qSlicerAbstractModuleFactoryManager.h>

Inheritance diagram for qSlicerAbstractModuleFactoryManager:
Inheritance graph
[legend]
Collaboration diagram for qSlicerAbstractModuleFactoryManager:
Collaboration graph
[legend]

Public Types

typedef ctkAbstractFileBasedFactory< qSlicerAbstractCoreModuleqSlicerFileBasedModuleFactory
 
typedef ctkAbstractFactory< qSlicerAbstractCoreModuleqSlicerModuleFactory
 
typedef QObject Superclass
 

Properties

QStringList modulesToIgnore
 
QStringList searchPaths
 

Public Slots

bool isVerbose () const
 
void setIsVerbose (bool flag)
 

Signals

void explicitModulesChanged (const QStringList &moduleNames)
 
void moduleAboutToBeUninstantiated (const QString &moduleName)
 
void moduleIgnored (const QString &moduleName)
 
void moduleInstantiated (const QString &moduleName)
 
void moduleRegistered (const QString &moduleName)
 
void modulesAboutToBeUninstantiated (const QStringList &moduleNames)
 
void modulesInstantiated (const QStringList &moduleNames)
 
void modulesRegistered (const QStringList &moduleNames)
 This signal is emitted when all the modules associated with the registered factories have been loaded. More...
 
void modulesToIgnoreChanged (const QStringList &moduleNames)
 
void modulesUninstantiated (const QStringList &moduleNames)
 
void moduleUninstantiated (const QString &moduleName)
 

Public Member Functions

void addModuleToIgnore (const QString &moduleName)
 
void addSearchPath (const QString &path)
 Utility function that adds a path to the current searchPaths list. More...
 
void addSearchPaths (const QStringList &paths)
 
QStringList dependentModules (const QString &module) const
 
QStringList explicitModules () const
 
QStringList ignoredModuleNames () const
 
Q_INVOKABLE QStringList instantiatedModuleNames () const
 List of registered and instantiated modules. More...
 
virtual void instantiateModules ()
 Instantiate all previously registered modules. More...
 
Q_INVOKABLE bool isInstantiated (const QString &name) const
 Return true if a module has been instantiated, false otherwise. More...
 
Q_INVOKABLE bool isRegistered (const QString &name) const
 Return true if a module has been registered, false otherwise. More...
 
QStringList moduleDependees (const QString &module) const
 
Q_INVOKABLE qSlicerAbstractCoreModulemoduleInstance (const QString &moduleName) const
 Return the instance of a module if already instantiated, 0 otherwise. More...
 
QStringList modulesToIgnore () const
 
virtual void printAdditionalInfo ()
 Print internal state using qDebug() More...
 
 qSlicerAbstractModuleFactoryManager (QObject *newParent=nullptr)
 
Q_INVOKABLE QStringList registeredModuleNames () const
 Convenient method returning the list of all registered module names. More...
 
void registerFactory (qSlicerModuleFactory *factory, int priority=0)
 Register a factory The factory will be deleted when unregistered (e.g. in ~qSlicerAbstractModuleFactoryManager()) More...
 
Q_INVOKABLE void registerModule (const QFileInfo &file)
 
void registerModules ()
 
void removeModuleToIgnore (const QString &moduleName)
 
void removeSearchPath (const QString &path)
 Utility function that removes a path from the current searchPaths list. More...
 
void removeSearchPaths (const QStringList &paths)
 
QStringList searchPaths () const
 
void setExplicitModules (const QStringList &moduleNames)
 
void setModulesToIgnore (const QStringList &modulesNames)
 
void setSearchPaths (const QStringList &searchPaths)
 
void setVerboseModuleDiscovery (bool value)
 Enable/Disable verbose output during module discovery process. More...
 
void uninstantiateModules ()
 Uninstantiate all instantiated modules. More...
 
void unregisterFactories ()
 
void unregisterFactory (qSlicerModuleFactory *factory)
 
 ~qSlicerAbstractModuleFactoryManager () override
 

Protected Member Functions

qSlicerAbstractCoreModuleinstantiateModule (const QString &name)
 Instantiate a module given its name. More...
 
void registerModules (const QString &directoryPath)
 
virtual void uninstantiateModule (const QString &moduleName)
 Uninstantiate a module given its moduleName. More...
 

Protected Attributes

QScopedPointer< qSlicerAbstractModuleFactoryManagerPrivate > d_ptr
 

Detailed Description

Loading modules into slicer happens in multiple steps: 1) module factories must be registered into the factory manager: qSlicerModuleFactoryManager* factoryManager = app->moduleManager()->factoryManager(); factoryManager->registerFactory(new qSlicerLoadableModuleFactory); ... 2) directories where the modules to load are located must be passed to the factory manager factoryManager->addSearchPath(app->slicerHome() + "/" + Slicer_QTSCRIPTEDMODULES_LIB_DIR + "/" ); factoryManager->addSearchPath(app->slicerHome() + "/" + Slicer_CLIMODULES_LIB_DIR + "/" ); ... 3) Optionally:

Definition at line 65 of file qSlicerAbstractModuleFactoryManager.h.

Member Typedef Documentation

◆ qSlicerFileBasedModuleFactory

Definition at line 86 of file qSlicerAbstractModuleFactoryManager.h.

◆ qSlicerModuleFactory

Definition at line 87 of file qSlicerAbstractModuleFactoryManager.h.

◆ Superclass

Definition at line 89 of file qSlicerAbstractModuleFactoryManager.h.

Property Documentation

◆ modulesToIgnore

QStringList qSlicerAbstractModuleFactoryManager::modulesToIgnore
readwrite

This property holds the names of the modules to ignore at registration time.

Due to the large amount of modules to load, it can be faster (and less overwhelming) to load only a subset of the modules.

Definition at line 84 of file qSlicerAbstractModuleFactoryManager.h.

◆ searchPaths

QStringList qSlicerAbstractModuleFactoryManager::searchPaths
readwrite

This property holds the paths where the modules are located. At registration time (registerModules), the paths are scanned and module discovered. A module can be a library (dll, so), an executable (exe), a python file (py) or any other file type supported by the registered factories. The search is not recursive, you need to provide each subdirectory manually.

Todo:
In qSlicerAbstractModuleFactoryManager, should the module search recursively descend searchPaths

Definition at line 78 of file qSlicerAbstractModuleFactoryManager.h.

Constructor & Destructor Documentation

◆ qSlicerAbstractModuleFactoryManager()

qSlicerAbstractModuleFactoryManager::qSlicerAbstractModuleFactoryManager ( QObject *  newParent = nullptr)

◆ ~qSlicerAbstractModuleFactoryManager()

qSlicerAbstractModuleFactoryManager::~qSlicerAbstractModuleFactoryManager ( )
override

Destructor, Deallocates resources Unregister (and delete) all registered factories.

Member Function Documentation

◆ addModuleToIgnore()

void qSlicerAbstractModuleFactoryManager::addModuleToIgnore ( const QString &  moduleName)
inline

Utility function that adds a module to the modulesToIgnore list.

See also
removeModuleToIgnore(const QString& moduleName)

Definition at line 271 of file qSlicerAbstractModuleFactoryManager.h.

◆ addSearchPath()

void qSlicerAbstractModuleFactoryManager::addSearchPath ( const QString &  path)
inline

Utility function that adds a path to the current searchPaths list.

Definition at line 248 of file qSlicerAbstractModuleFactoryManager.h.

◆ addSearchPaths()

void qSlicerAbstractModuleFactoryManager::addSearchPaths ( const QStringList &  paths)
inline

Utility function that adds a list of path to the current searchPaths list.

Definition at line 242 of file qSlicerAbstractModuleFactoryManager.h.

◆ dependentModules()

QStringList qSlicerAbstractModuleFactoryManager::dependentModules ( const QString &  module) const

Return the list of modules that have module as a dependency. Note that the list can contain unloaded modules.

See also
qSlicerAbstractCoreModule::dependencies(), moduleDependees()

◆ explicitModules()

QStringList qSlicerAbstractModuleFactoryManager::explicitModules ( ) const

◆ explicitModulesChanged

void qSlicerAbstractModuleFactoryManager::explicitModulesChanged ( const QStringList &  moduleNames)
signal

◆ ignoredModuleNames()

QStringList qSlicerAbstractModuleFactoryManager::ignoredModuleNames ( ) const

After the modules are registered, ignoredModules contains the list of all the modules that were ignored.

◆ instantiatedModuleNames()

Q_INVOKABLE QStringList qSlicerAbstractModuleFactoryManager::instantiatedModuleNames ( ) const

List of registered and instantiated modules.

◆ instantiateModule()

qSlicerAbstractCoreModule* qSlicerAbstractModuleFactoryManager::instantiateModule ( const QString &  name)
protected

Instantiate a module given its name.

◆ instantiateModules()

virtual void qSlicerAbstractModuleFactoryManager::instantiateModules ( )
virtual

Instantiate all previously registered modules.

◆ isInstantiated()

Q_INVOKABLE bool qSlicerAbstractModuleFactoryManager::isInstantiated ( const QString &  name) const

Return true if a module has been instantiated, false otherwise.

◆ isRegistered()

Q_INVOKABLE bool qSlicerAbstractModuleFactoryManager::isRegistered ( const QString &  name) const

Return true if a module has been registered, false otherwise.

◆ isVerbose

bool qSlicerAbstractModuleFactoryManager::isVerbose ( ) const
slot

◆ moduleAboutToBeUninstantiated

void qSlicerAbstractModuleFactoryManager::moduleAboutToBeUninstantiated ( const QString &  moduleName)
signal

◆ moduleDependees()

QStringList qSlicerAbstractModuleFactoryManager::moduleDependees ( const QString &  module) const

Return the list of modules that depend on module. Note that the list can contain unloaded modules.

See also
dependentModules(), qSlicerAbstractCoreModule::dependencies()

◆ moduleIgnored

void qSlicerAbstractModuleFactoryManager::moduleIgnored ( const QString &  moduleName)
signal

◆ moduleInstance()

Q_INVOKABLE qSlicerAbstractCoreModule* qSlicerAbstractModuleFactoryManager::moduleInstance ( const QString &  moduleName) const

Return the instance of a module if already instantiated, 0 otherwise.

◆ moduleInstantiated

void qSlicerAbstractModuleFactoryManager::moduleInstantiated ( const QString &  moduleName)
signal

◆ moduleRegistered

void qSlicerAbstractModuleFactoryManager::moduleRegistered ( const QString &  moduleName)
signal

◆ modulesAboutToBeUninstantiated

void qSlicerAbstractModuleFactoryManager::modulesAboutToBeUninstantiated ( const QStringList &  moduleNames)
signal

◆ modulesInstantiated

void qSlicerAbstractModuleFactoryManager::modulesInstantiated ( const QStringList &  moduleNames)
signal

◆ modulesRegistered

void qSlicerAbstractModuleFactoryManager::modulesRegistered ( const QStringList &  moduleNames)
signal

This signal is emitted when all the modules associated with the registered factories have been loaded.

◆ modulesToIgnore()

QStringList qSlicerAbstractModuleFactoryManager::modulesToIgnore ( ) const

◆ modulesToIgnoreChanged

void qSlicerAbstractModuleFactoryManager::modulesToIgnoreChanged ( const QStringList &  moduleNames)
signal

◆ modulesUninstantiated

void qSlicerAbstractModuleFactoryManager::modulesUninstantiated ( const QStringList &  moduleNames)
signal

◆ moduleUninstantiated

void qSlicerAbstractModuleFactoryManager::moduleUninstantiated ( const QString &  moduleName)
signal

◆ printAdditionalInfo()

virtual void qSlicerAbstractModuleFactoryManager::printAdditionalInfo ( )
virtual

Print internal state using qDebug()

Reimplemented in qSlicerModuleFactoryManager.

◆ registeredModuleNames()

Q_INVOKABLE QStringList qSlicerAbstractModuleFactoryManager::registeredModuleNames ( ) const

Convenient method returning the list of all registered module names.

◆ registerFactory()

void qSlicerAbstractModuleFactoryManager::registerFactory ( qSlicerModuleFactory factory,
int  priority = 0 
)

Register a factory The factory will be deleted when unregistered (e.g. in ~qSlicerAbstractModuleFactoryManager())

Example:

The order in which factories are registered is important. When scanning directories, registered factories are browse and the first factory that can read a file is used. Priority is used when multiple factories can register the same module. The factory with the higher priority wins.

◆ registerModule()

Q_INVOKABLE void qSlicerAbstractModuleFactoryManager::registerModule ( const QFileInfo &  file)

◆ registerModules() [1/2]

void qSlicerAbstractModuleFactoryManager::registerModules ( )

Scan the paths in searchPaths and for each file, attempt to register using one of the registered factories.

◆ registerModules() [2/2]

void qSlicerAbstractModuleFactoryManager::registerModules ( const QString &  directoryPath)
protected

◆ removeModuleToIgnore()

void qSlicerAbstractModuleFactoryManager::removeModuleToIgnore ( const QString &  moduleName)
inline

Utility function that removes a module to the modulesToIgnore list.

See also
addModuleToIgnore(const QString& moduleName)

Definition at line 283 of file qSlicerAbstractModuleFactoryManager.h.

◆ removeSearchPath()

void qSlicerAbstractModuleFactoryManager::removeSearchPath ( const QString &  path)
inline

Utility function that removes a path from the current searchPaths list.

Definition at line 263 of file qSlicerAbstractModuleFactoryManager.h.

◆ removeSearchPaths()

void qSlicerAbstractModuleFactoryManager::removeSearchPaths ( const QStringList &  paths)
inline

Utility function that removes a list of path to the current searchPaths list.

Definition at line 254 of file qSlicerAbstractModuleFactoryManager.h.

◆ searchPaths()

QStringList qSlicerAbstractModuleFactoryManager::searchPaths ( ) const

◆ setExplicitModules()

void qSlicerAbstractModuleFactoryManager::setExplicitModules ( const QStringList &  moduleNames)

◆ setIsVerbose

void qSlicerAbstractModuleFactoryManager::setIsVerbose ( bool  flag)
slot

Enable/disable local verbose output during module discovery and uninstantiating, set by setVerboseModuleDiscovery()

See also
setVerboseModuleDiscovery()

◆ setModulesToIgnore()

void qSlicerAbstractModuleFactoryManager::setModulesToIgnore ( const QStringList &  modulesNames)

Set or get the modulesToIgnore list.

If list is modified, the signal modulesToIgnoreChanged(const QStringLists&) is emitted.

◆ setSearchPaths()

void qSlicerAbstractModuleFactoryManager::setSearchPaths ( const QStringList &  searchPaths)

◆ setVerboseModuleDiscovery()

void qSlicerAbstractModuleFactoryManager::setVerboseModuleDiscovery ( bool  value)

Enable/Disable verbose output during module discovery process.

◆ uninstantiateModule()

virtual void qSlicerAbstractModuleFactoryManager::uninstantiateModule ( const QString &  moduleName)
protectedvirtual

Uninstantiate a module given its moduleName.

Reimplemented in qSlicerModuleFactoryManager.

◆ uninstantiateModules()

void qSlicerAbstractModuleFactoryManager::uninstantiateModules ( )

Uninstantiate all instantiated modules.

◆ unregisterFactories()

void qSlicerAbstractModuleFactoryManager::unregisterFactories ( )

◆ unregisterFactory()

void qSlicerAbstractModuleFactoryManager::unregisterFactory ( qSlicerModuleFactory factory)

Member Data Documentation

◆ d_ptr

QScopedPointer<qSlicerAbstractModuleFactoryManagerPrivate> qSlicerAbstractModuleFactoryManager::d_ptr
protected

Definition at line 226 of file qSlicerAbstractModuleFactoryManager.h.


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