itom 2.0.0
ito::AddInManager Class Reference

class for AddIn management More...

#include <addInManager.h>

List of all members.

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::FilterParamsgetHashedFilterParams (ito::AddInAlgo::t_filterParam filterParam) const
const QList< PluginLoadStatusgetPluginLoadStatus () const
const AlgoInterfaceValidatorgetAlgoInterfaceValidator (void) const
const
ito::AddInAlgo::AlgoWidgetDef
getAlgoWidgetDef (QString algoWidgetName, QString algoPluginName=QString())
PlugInModelgetPluginModel (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 > *&paramsMand, QVector< ito::Param > *&paramsOpt)
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 AddInManagergetInstance (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 ()

Private Member Functions

 AddInManager (AddInManager &)
 ~AddInManager (void)

Private Attributes

QVector< QTranslator * > m_Translator
AlgoInterfaceValidatorm_algoInterfaceValidator
PlugInModel m_plugInModel
QList< QPointer< ito::AddInBase > > m_deadPlugins
QTimer m_deadPluginTimer

Static Private Attributes

static AddInManagerm_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< PluginLoadStatusm_pluginLoadStatus = QList<ito::PluginLoadStatus>()

Detailed Description

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.


Constructor & Destructor Documentation

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.


Member Function Documentation

ito::RetVal ito::AddInManager::closeAddIn ( ito::AddInBase addIn,
ItomSharedSemaphore aimWait = NULL 
) [slot]

closeAddIn close an instance of an actuator addIn object

Parameters:
[in]addInthe addIn to close
Returns:
on success ito::retOk, ito::retError otherwise

At first the close method of the plugin class is invoked. Then the closeInst method of the addInInterfaceBase is called.

RetVal ito::AddInManager::closeDeadPlugins ( ) [private, slot]
Returns:
RetVal
RetVal ito::AddInManager::closeInstance ( void  ) [static]

closeInstance

Returns:
ito::retOk

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

Parameters:
[in]addInthe addIn to increment reference
Returns:
on success ito::retOk, ito::retError otherwise

The method decrements the reference counter of the addin.

const ito::AddInAlgo::AlgoWidgetDef * ito::AddInManager::getAlgoWidgetDef ( QString  algoWidgetName,
QString  algoPluginName = QString() 
)
Parameters:
algoWidgetNamealgoPluginName
algoPluginName
Returns:
ito::AddInAlgo::AlgoWidgetDef
const QList< ito::AddInAlgo::FilterDef * > ito::AddInManager::getFilterByInterface ( ito::AddInAlgo::tAlgoInterface  iface,
const QString  tag = QString::Null() 
) const
Parameters:
iface
tag
Returns:
QList<ito::AddInAlgo::FilterDef *>
const QList< ito::AddInAlgo::FilterDef * > ito::AddInManager::getFilterByInterfaceAndCategory ( ito::AddInAlgo::tAlgoInterface  iface,
ito::AddInAlgo::tAlgoCategory  cat,
const QString  tag = QString::Null() 
) const
Parameters:
iface
cat
tag
Returns:
QList<ito::AddInAlgo::FilterDef
const QList< ito::AddInAlgo::FilterDef * > ito::AddInManager::getFiltersByCategory ( ito::AddInAlgo::tAlgoCategory  cat) const
Parameters:
cat
Returns:
QList<ito::AddInAlgo::FilterDef *>
const ito::FilterParams * ito::AddInManager::getHashedFilterParams ( ito::AddInAlgo::t_filterParam  filterParam) const
Parameters:
pathfilterParam
Returns:
ito::FilterParams
const RetVal ito::AddInManager::getInitParams ( const QString &  name,
const int  pluginType,
int *  pluginNum,
QVector< ito::Param > *&  paramsMand,
QVector< ito::Param > *&  paramsOpt 
)

getInitParams

Parameters:
[in]nameplugin name for which the initialisation parameters should be retrieved
[in]pluginTypeplugin type, i.e. in which of the plugin lists should be searched for the plugin
[out]pluginNumnumber of the plugin in the plugin list, this number is needed later to create an instance of the plugin class
[out]paramsMandmandatory initialisation parameters
[out]paramsOptoptional initialisation parameters
Returns:
ito::retOk on success ito::retError otherwise

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)

Returns:
instance of the AddInManager

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

Parameters:
[in]nameplugin name for which type and number should be retrieved
[out]pluginTypeplugin type, i.e. in which of the plugin lists should be searched for the plugin
[out]pluginNumnumber of the plugin in the plugin list, this number is needed later to create an instance of the plugin class
[out]pluginTypeStringtype of the plugin as string
[out]authorauthor name or company
[out]descriptionshort discribtion of the plugin
[out]detaildescriptiondetail discription of the plugin
[out]versionplugin version number
Returns:
ito::retOk on success ito::retError otherwise

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

Parameters:
[in]addInthe addIn to increment reference
Returns:
on success ito::retOk, ito::retError otherwise

The method increments the reference counter of the addin.

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

Parameters:
[in]pluginNumnumber of the plugin in the plugin list, retrieved with getInitParams
[in]namename 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]addInpointer to the new instance of the plugin class
[in]paramsMandmandatory 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]paramsOptmandatory 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]aimWaitwait condition for calls from other threads. See also ItomSharedSemaphore
Returns:
on success ito::retOk, ito::retError otherwise

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

Parameters:
[in]pluginNumnumber of the plugin in the plugin list, retrieved with getInitParams
[in]namename 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]addInpointer to the new instance of the plugin class
[in]paramsMandmandatory 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]paramsOptmandatory 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]aimWaitwait condition for calls from other threads. See also ItomSharedSemaphore
Returns:
on success ito::retOk, ito::retError otherwise

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

Parameters:
[in]pluginNumnumber of the plugin in the plugin list, retrieved with getInitParams
[in]namename 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]addInpointer to the new instance of the plugin class
[in]paramsMandmandatory 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]paramsOptmandatory 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
Returns:
on success ito::retOk, ito::retError otherwise

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::initDockWidget ( const ito::AddInBase addIn) [protected]

initAddIn initialize new instance of a dataIO addIn class

Parameters:
[in]addInpointer to newly initialized pluginIn
Returns:
on success ito::retOk

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
Parameters:
plugin
Returns:
bool
RetVal ito::AddInManager::loadAddIn ( QString &  filename) [protected]
Parameters:
filename
Returns:
RetVal
RetVal ito::AddInManager::loadAddInActuator ( QObject *  plugin,
ito::PluginLoadStatus pluginLoadStatus 
) [protected]
Parameters:
plugin
pluginLoadStatus
Returns:
RetVal
RetVal ito::AddInManager::loadAddInAlgo ( QObject *  plugin,
ito::PluginLoadStatus pluginLoadStatus 
) [protected]
Parameters:
plugin
pluginLoadStatus
Returns:
RetVal
RetVal ito::AddInManager::loadAddInDataIO ( QObject *  plugin,
ito::PluginLoadStatus pluginLoadStatus 
) [protected]
Parameters:
plugin
pluginLoadStatus
Returns:
RetVal
const ito::RetVal ito::AddInManager::loadParamVals ( ito::AddInBase plugin)

loadParamVals loads the plugins parameter values from the plugin parameter xml file

Parameters:
[in]pluginplugin 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]
Parameters:
addIn
Returns:
RetVal
const ito::RetVal ito::AddInManager::reloadAddIn ( const QString &  name)
Parameters:
name
Returns:
ito::RetVal
const ito::RetVal ito::AddInManager::saveParamVals ( ito::AddInBase plugin)

saveParamVals saves the plugins parameter values to the plugin parameter xml file

Parameters:
[in]pluginplugin 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

Parameters:
pathdirectory path to search in (currently unused)
Returns:
returns ito::retOk on success otherwise ito::retError

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

Parameters:
[in]addinaddin 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

Parameters:
[in]addinaddin from which the dialog should be called
[in]visible1=show, 0=hide, -1=toggle
[in,out]waitCondwait 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.


Member Data Documentation

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


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends