itom 2.2.0
|
class for AddIn management More...
#include <addInManager.h>
Public Slots | |
ito::RetVal | showConfigDialog (ito::AddInBase *addin, ItomSharedSemaphore *waitCond=NULL) |
ito::RetVal | showDockWidget (ito::AddInBase *addin, int visible, ItomSharedSemaphore *waitCond=NULL) |
ito::RetVal | initAddIn (const int pluginNum, const QString &name, ito::AddInDataIO **addIn, QVector< ito::ParamBase > *paramsMand, QVector< ito::ParamBase > *paramsOpt, bool autoLoadPluginParams, ItomSharedSemaphore *aimWait=NULL) |
ito::RetVal | initAddIn (const int pluginNum, const QString &name, ito::AddInActuator **addIn, QVector< ito::ParamBase > *paramsMand, QVector< ito::ParamBase > *paramsOpt, bool autoLoadPluginParams, ItomSharedSemaphore *aimWait=NULL) |
ito::RetVal | initAddIn (const int pluginNum, const QString &name, ito::AddInAlgo **addIn, QVector< ito::ParamBase > *paramsMand, QVector< ito::ParamBase > *paramsOpt, bool autoLoadPluginParams, ItomSharedSemaphore *aimWait=NULL) |
ito::RetVal | closeAddIn (ito::AddInBase *addIn, ItomSharedSemaphore *aimWait=NULL) |
Signals | |
void | splashLoadMessage (const QString &message, int alignment=Qt::AlignLeft, const QColor &color=Qt::black) |
Public Member Functions | |
const RetVal | scanAddInDir (const QString &path) |
const QList< QObject * > * | getDataIOList (void) const |
const QList< QObject * > * | getActList (void) const |
const QList< QObject * > * | getAlgList (void) const |
const QHash< QString, ito::AddInAlgo::FilterDef * > * | getFilterList (void) const |
const QHash< QString, ito::AddInAlgo::AlgoWidgetDef * > * | getAlgoWidgetList (void) const |
const ito::FilterParams * | getHashedFilterParams (ito::AddInAlgo::t_filterParam filterParam) const |
const QList< PluginLoadStatus > | getPluginLoadStatus () const |
const AlgoInterfaceValidator * | getAlgoInterfaceValidator (void) const |
const ito::AddInAlgo::AlgoWidgetDef * | getAlgoWidgetDef (QString algoWidgetName, QString algoPluginName=QString()) |
PlugInModel * | getPluginModel (void) |
const RetVal | reloadAddIn (const QString &name) |
int | getNumTotItems (void) const |
void * | getAddInPtr (const int itemNum) |
int | getItemNum (const void *item) |
int | getItemIndexInList (const void *item) |
int | getPluginNum (const QString &name, ito::AddInInterfaceBase *&addIn) |
void | updateModel (void) |
const RetVal | saveParamVals (ito::AddInBase *plugin) |
const RetVal | loadParamVals (ito::AddInBase *plugin) |
const RetVal | getInitParams (const QString &name, const int pluginType, int *pluginNum, QVector< ito::Param > *¶msMand, QVector< ito::Param > *¶msOpt) |
const RetVal | getPluginInfo (const QString &name, int &pluginType, int &pluginNum, int &version, QString &typeString, QString &author, QString &description, QString &detaildescription, QString &license, QString &about) |
const RetVal | incRef (ito::AddInBase *plugin) |
const RetVal | decRef (ito::AddInBase **plugin) |
bool | isPluginInstanceDead (const ito::AddInBase *plugin) const |
const QList < ito::AddInAlgo::FilterDef * > | getFilterByInterface (ito::AddInAlgo::tAlgoInterface iface, const QString tag=QString::Null()) const |
const QList < ito::AddInAlgo::FilterDef * > | getFiltersByCategory (ito::AddInAlgo::tAlgoCategory cat) const |
const QList < ito::AddInAlgo::FilterDef * > | getFilterByInterfaceAndCategory (ito::AddInAlgo::tAlgoInterface iface, ito::AddInAlgo::tAlgoCategory cat, const QString tag=QString::Null()) const |
Static Public Member Functions | |
static AddInManager * | getInstance (void) |
AddInManager implementation. | |
static RetVal | closeInstance (void) |
Protected Member Functions | |
RetVal | initDockWidget (const ito::AddInBase *addIn) |
RetVal | loadAddIn (QString &filename) |
RetVal | loadAddInDataIO (QObject *plugin, ito::PluginLoadStatus &pluginLoadStatus) |
RetVal | loadAddInActuator (QObject *plugin, ito::PluginLoadStatus &pluginLoadStatus) |
RetVal | loadAddInAlgo (QObject *plugin, ito::PluginLoadStatus &pluginLoadStatus) |
RetVal | registerPluginAsDeadPlugin (ito::AddInBase *addIn) |
Private Slots | |
RetVal | closeDeadPlugins () |
void | propertiesChanged () |
Private Member Functions | |
AddInManager (AddInManager &) | |
~AddInManager (void) | |
Private Attributes | |
QVector< QTranslator * > | m_Translator |
AlgoInterfaceValidator * | m_algoInterfaceValidator |
PlugInModel | m_plugInModel |
QList< QPointer< ito::AddInBase > > | m_deadPlugins |
QTimer | m_deadPluginTimer |
Static Private Attributes | |
static AddInManager * | m_pAddInManager = NULL |
static QList< QObject * > | m_addInListDataIO = QList<QObject *>() |
list holding all available dataIO plugins | |
static QList< QObject * > | m_addInListAct = QList<QObject *>() |
list holding all available actuator plugins | |
static QList< QObject * > | m_addInListAlgo = QList<QObject *>() |
list holding all available algorithm plugins | |
static QHash< QString, ito::AddInAlgo::FilterDef * > | m_filterList = QHash<QString, ito::AddInAlgo::FilterDef *>() |
hash holding all available algorithms | |
static QMultiHash< QString, ito::AddInAlgo::FilterDef * > | m_filterListInterfaceTag = QMultiHash<QString, ito::AddInAlgo::FilterDef *>() |
static QHash< QString, ito::AddInAlgo::AlgoWidgetDef * > | m_algoWidgetList = QHash<QString, ito::AddInAlgo::AlgoWidgetDef *>() |
static QHash< void *, ito::FilterParams * > | filterParamHash = QHash<void*, ito::FilterParams*>() |
static QList< PluginLoadStatus > | m_pluginLoadStatus = QList<ito::PluginLoadStatus>() |
class for AddIn management
This class is internally used for plugin handling, i.e. detecting available plugins which can be loaded, maintaining a list (widget AddInModel) of available and loaded plugins, loading and unloading of plugins. The plugins themselfs are based on the addInInterface, declared in addInInterface. The AddInManager is implemented as singleton class because it must exist only one instance of it (which would also be possible using a static class) but which also does a clean up of the instantiated plugin classes at program exit.
ito::AddInManager::~AddInManager | ( | void | ) | [private] |
destructor, closes all instances of plugins and plugins
Before the AddInManager itself is closed it closes all instances of plugins that are in the plugins' instance lists. Afterwards the AddInInterfaceBase for each plugin (i.e. the library) is closed an it is removed from the plugin list. This is done for dataIO, actuator and algo plugins.
ito::RetVal ito::AddInManager::closeAddIn | ( | ito::AddInBase * | addIn, |
ItomSharedSemaphore * | aimWait = NULL |
||
) | [slot] |
closeAddIn close an instance of an actuator addIn object
[in] | addIn | the addIn to close |
At first the close method of the plugin class is invoked. Then the closeInst method of the addInInterfaceBase is called.
RetVal ito::AddInManager::closeInstance | ( | void | ) | [static] |
closeInstance
closes the instance of the AddInManager - should only be called at the very closing of the main program
const ito::RetVal ito::AddInManager::decRef | ( | ito::AddInBase ** | addIn | ) |
decRef decrement reference counter of addin and close it if necessary
[in] | addIn | the addIn to increment reference |
The method decrements the reference counter of the addin.
const ito::AddInAlgo::AlgoWidgetDef * ito::AddInManager::getAlgoWidgetDef | ( | QString | algoWidgetName, |
QString | algoPluginName = QString() |
||
) |
algoWidgetName | algoPluginName |
algoPluginName |
const QList< ito::AddInAlgo::FilterDef * > ito::AddInManager::getFilterByInterface | ( | ito::AddInAlgo::tAlgoInterface | iface, |
const QString | tag = QString::Null() |
||
) | const |
iface | |
tag |
const QList< ito::AddInAlgo::FilterDef * > ito::AddInManager::getFilterByInterfaceAndCategory | ( | ito::AddInAlgo::tAlgoInterface | iface, |
ito::AddInAlgo::tAlgoCategory | cat, | ||
const QString | tag = QString::Null() |
||
) | const |
iface | |
cat | |
tag |
const QList< ito::AddInAlgo::FilterDef * > ito::AddInManager::getFiltersByCategory | ( | ito::AddInAlgo::tAlgoCategory | cat | ) | const |
cat |
const ito::FilterParams * ito::AddInManager::getHashedFilterParams | ( | ito::AddInAlgo::t_filterParam | filterParam | ) | const |
path | filterParam |
const RetVal ito::AddInManager::getInitParams | ( | const QString & | name, |
const int | pluginType, | ||
int * | pluginNum, | ||
QVector< ito::Param > *& | paramsMand, | ||
QVector< ito::Param > *& | paramsOpt | ||
) |
getInitParams
[in] | name | plugin name for which the initialisation parameters should be retrieved |
[in] | pluginType | plugin type, i.e. in which of the plugin lists should be searched for the plugin |
[out] | pluginNum | number of the plugin in the plugin list, this number is needed later to create an instance of the plugin class |
[out] | paramsMand | mandatory initialisation parameters |
[out] | paramsOpt | optional initialisation parameters |
The getInitParams method searchs the plugin list given by plugin type for a plugin with the name 'name'. In case the according plugin is found its number, mandatory and optional initialisation parameters are returned.
Please consider that this method returns pointers to the original initialization parameter vectors. If you change the value of these elements consider to copy the complete vector.
AddInManager * ito::AddInManager::getInstance | ( | void | ) | [static] |
AddInManager implementation.
getInstance method, retrieves Instance of the AddInManager (or opens it if no instance exists)
This method returns the instance of the AddInManager, i.e. if the AddInManager has not been started, it is started then. Otherwise the reference to the open AddInManager is returned
const RetVal ito::AddInManager::getPluginInfo | ( | const QString & | name, |
int & | pluginType, | ||
int & | pluginNum, | ||
int & | version, | ||
QString & | typeString, | ||
QString & | author, | ||
QString & | description, | ||
QString & | detaildescription, | ||
QString & | license, | ||
QString & | about | ||
) |
getPlugInInfo
[in] | name | plugin name for which type and number should be retrieved |
[out] | pluginType | plugin type, i.e. in which of the plugin lists should be searched for the plugin |
[out] | pluginNum | number of the plugin in the plugin list, this number is needed later to create an instance of the plugin class |
[out] | pluginTypeString | type of the plugin as string |
[out] | author | author name or company |
[out] | description | short discribtion of the plugin |
[out] | detaildescription | detail discription of the plugin |
[out] | version | plugin version number |
The getPlugInInfo method searchs in all three plugin lists for a plugin with the name 'name'. In case the according plugin is found its information about number, name ... returned. For all parameters of type char** provide the address to a char*-variable. Then, a newly allocated \0-terminated string is returned. Don't forget to free this pointer after using it (free not delete!).
const ito::RetVal ito::AddInManager::incRef | ( | ito::AddInBase * | addIn | ) |
incRef increment reference counter of addin
[in] | addIn | the addIn to increment reference |
The method increments the reference counter of the addin.
ito::RetVal ito::AddInManager::initAddIn | ( | const int | pluginNum, |
const QString & | name, | ||
ito::AddInDataIO ** | addIn, | ||
QVector< ito::ParamBase > * | paramsMand, | ||
QVector< ito::ParamBase > * | paramsOpt, | ||
bool | autoLoadPluginParams, | ||
ItomSharedSemaphore * | aimWait = NULL |
||
) | [slot] |
initAddIn initialize new instance of a dataIO addIn class
[in] | pluginNum | number of the plugin in the plugin list, retrieved with getInitParams |
[in] | name | name of the plugin to be initialized, this just a check that number and name correspond, principally it should not be necessary to pass the name |
[out] | addIn | pointer to the new instance of the plugin class |
[in] | paramsMand | mandatory initialisation parameters which are required by the initialisation. As this vector should(must) be retrieved from the plugin previously with the getInitParams method it should always be filled with meaningful values |
[in] | paramsOpt | mandatory initialisation parameters which may optionally be passed to the initialisation. As this vector should(must) be retrieved from the plugin previously with the getInitParams method it should always be filled with meaningful values |
[in,out] | aimWait | wait condition for calls from other threads. See also ItomSharedSemaphore |
A new instance from the addIn class is created then the newly created object is moved into a new thread. Afterwards the classes init method is invoked with the passed mandatory and optional parameters. As a last step the plugins parameters are loaded from the plugins parameters xml file loadParamVals.
ito::RetVal ito::AddInManager::initAddIn | ( | const int | pluginNum, |
const QString & | name, | ||
ito::AddInAlgo ** | addIn, | ||
QVector< ito::ParamBase > * | paramsMand, | ||
QVector< ito::ParamBase > * | paramsOpt, | ||
bool | autoLoadPluginParams, | ||
ItomSharedSemaphore * | aimWait = NULL |
||
) | [slot] |
initAddIn initialize new instance of a algo addIn class
[in] | pluginNum | number of the plugin in the plugin list, retrieved with getInitParams |
[in] | name | name of the plugin to be initialized, this just a check that number and name correspond, principally it should not be necessary to pass the name |
[out] | addIn | pointer to the new instance of the plugin class |
[in] | paramsMand | mandatory initialisation parameters which are required by the initialisation. As this vector should(must) be retrieved from the plugin previously with the getInitParams method it should always be filled with meaningful values |
[in] | paramsOpt | mandatory initialisation parameters which may optionally be passed to the initialisation. As this vector should(must) be retrieved from the plugin previously with the getInitParams method it should always be filled with meaningful values |
new instance from the addIn class is created. In contrast to the dataIO and actuator plugins the new object is not moved to a new thread and no init method is called. As a last step the plugins parameters are loaded from the plugins parameters xml file loadParamVals.
ito::RetVal ito::AddInManager::initAddIn | ( | const int | pluginNum, |
const QString & | name, | ||
ito::AddInActuator ** | addIn, | ||
QVector< ito::ParamBase > * | paramsMand, | ||
QVector< ito::ParamBase > * | paramsOpt, | ||
bool | autoLoadPluginParams, | ||
ItomSharedSemaphore * | aimWait = NULL |
||
) | [slot] |
initAddIn initialize new instance of a actuator addIn class
[in] | pluginNum | number of the plugin in the plugin list, retrieved with getInitParams |
[in] | name | name of the plugin to be initialized, this just a check that number and name correspond, principally it should not be necessary to pass the name |
[out] | addIn | pointer to the new instance of the plugin class |
[in] | paramsMand | mandatory initialisation parameters which are required by the initialisation. As this vector should(must) be retrieved from the plugin previously with the getInitParams method it should always be filled with meaningful values |
[in] | paramsOpt | mandatory initialisation parameters which may optionally be passed to the initialisation. As this vector should(must) be retrieved from the plugin previously with the getInitParams method it should always be filled with meaningful values |
[in,out] | aimWait | wait condition for calls from other threads. See also ItomSharedSemaphore |
A new instance from the addIn class is created then the newly created object is moved into a new thread. Afterwards the classes init method is invoked with the passed mandatory and optional parameters. As a last step the plugins parameters are loaded from the plugins parameters xml file loadParamVals.
ito::RetVal ito::AddInManager::initDockWidget | ( | const ito::AddInBase * | addIn | ) | [protected] |
initAddIn initialize new instance of a dataIO addIn class
[in] | addIn | pointer to newly initialized pluginIn |
checks if addIn has a docking widget and if so, registers this docking widget to mainWindow
bool ito::AddInManager::isPluginInstanceDead | ( | const ito::AddInBase * | plugin | ) | const |
plugin |
RetVal ito::AddInManager::loadAddIn | ( | QString & | filename | ) | [protected] |
filename |
RetVal ito::AddInManager::loadAddInActuator | ( | QObject * | plugin, |
ito::PluginLoadStatus & | pluginLoadStatus | ||
) | [protected] |
plugin | |
pluginLoadStatus |
RetVal ito::AddInManager::loadAddInAlgo | ( | QObject * | plugin, |
ito::PluginLoadStatus & | pluginLoadStatus | ||
) | [protected] |
plugin | |
pluginLoadStatus |
RetVal ito::AddInManager::loadAddInDataIO | ( | QObject * | plugin, |
ito::PluginLoadStatus & | pluginLoadStatus | ||
) | [protected] |
plugin | |
pluginLoadStatus |
const ito::RetVal ito::AddInManager::loadParamVals | ( | ito::AddInBase * | plugin | ) |
loadParamVals loads the plugins parameter values from the plugin parameter xml file
[in] | plugin | plugin for which the parameter should be loaded |
A xml file with the same name as the plugin library in the plugin directory is used to load the plugin parameters. The xml file is checked for the current plugin-file version and type when opened. The parameters are set using the invokeMethod function on the plugins' setParam method.
RetVal ito::AddInManager::registerPluginAsDeadPlugin | ( | ito::AddInBase * | addIn | ) | [protected] |
addIn |
const ito::RetVal ito::AddInManager::reloadAddIn | ( | const QString & | name | ) |
name |
const ito::RetVal ito::AddInManager::saveParamVals | ( | ito::AddInBase * | plugin | ) |
saveParamVals saves the plugins parameter values to the plugin parameter xml file
[in] | plugin | plugin for which the parameter should be saved |
A xml file with the same name as the plugin library in the plugin directory is used to save the plugin parameters. The xml file is checked for the current plugin-file version and type when opened. The parameters are stored underneath the unique ID of the instance currently closed. This enables to have a several parameter sets for one plugin. Each parameter is stored with its name, type and value. The type may be either number or string.
const RetVal ito::AddInManager::scanAddInDir | ( | const QString & | path | ) |
scanAddInDir
path | directory path to search in (currently unused) |
This method searches the plugin directory which is currently assumed to be in the main programs folder and must habe the name "plugins" for loadable plugins. The found plugins are sorted into the three lists with the available plugins (ito::AddInManager::m_addInListDataIO, ito::AddInManager::m_addInListAct, ito::AddInManager::m_addInListAlg)
ito::RetVal ito::AddInManager::showConfigDialog | ( | ito::AddInBase * | addin, |
ItomSharedSemaphore * | waitCond = NULL |
||
) | [slot] |
showConfigDialog show the plugin's configuration dialog
[in] | addin | addin from which the dialog should be called |
This method opens the configuration dialog of a plugin. The dialog can be opened using a right click on an instance of the plugin in the addInModel list or using showConfiguration command in python. An implementation of a configuration dialog is not mandatory, so in case there is no dialog implemented nothing happens.
ito::RetVal ito::AddInManager::showDockWidget | ( | ito::AddInBase * | addin, |
int | visible, | ||
ItomSharedSemaphore * | waitCond = NULL |
||
) | [slot] |
showDockWidget show or hide the plugin's widget
[in] | addin | addin from which the dialog should be called |
[in] | visible | 1=show, 0=hide, -1=toggle |
[in,out] | waitCond | wait condition for calls from other threads. See also ItomSharedSemaphore |
This method opens or closes the wodget of a plugin. The widget can be opened or closed using a right click on an instance of the plugin in the addInModel list or using showToolbox or hideToolbox command in python. An implementation of a configuration dialog is not mandatory, so in case there is no dialog implemented nothing happens.
ito::AddInManager * ito::AddInManager::m_pAddInManager = NULL [static, private] |
global variables used by the AddInManager global variable reference used to store AddInManager reference, as the AIM is singleton this variable is principally only accessed by the class itself. Its value is return also by the getReference AddInManager::method of AIM