itom  4.1.0
addInManagerPrivate.h
1 /* ********************************************************************
2 itom software
3 URL: http://www.uni-stuttgart.de/ito
4 Copyright (C) 2020, Institut fuer Technische Optik (ITO),
5 Universitaet Stuttgart, Germany
6 
7 This file is part of itom.
8 
9 itom is free software; you can redistribute it and/or modify it
10 under the terms of the GNU Library General Public Licence as published by
11 the Free Software Foundation; either version 2 of the Licence, or (at
12 your option) any later version.
13 
14 itom is distributed in the hope that it will be useful, but
15 WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library
17 General Public Licence for more details.
18 
19 You should have received a copy of the GNU Library General Public License
20 along with itom. If not, see <http://www.gnu.org/licenses/>.
21 *********************************************************************** */
22 
23 #ifndef ADDINMANAGERIMPL_H
24 #define ADDINMANAGERIMPL_H
25 
26 #include "algoInterfaceValidator.h"
27 #include "../common/sharedFunctionsQt.h"
28 #include "../common/addInInterface.h"
29 #include "pluginModel.h"
30 
31 #include <qobject.h>
32 #include <qtimer.h>
33 #include <qlist.h>
34 #include <qhash.h>
35 #include <qstring.h>
36 #include <qglobal.h>
37 #include <qfileinfo.h>
38 #include <qsettings.h>
39 #include <QDir>
40 #include <QDirIterator>
41 #include <QTranslator>
42 #include <qmainwindow.h>
43 #include <qpair.h>
44 #include <qpointer.h>
45 #include <qsharedpointer.h>
46 
47 
48 namespace ito
49 {
50 
51 class AddInManager;
52 
53 class AddInManagerPrivate : public QObject
54 {
55  Q_OBJECT
56 
57  Q_DECLARE_PUBLIC(AddInManager);
58  public:
61 
62  protected:
63  AddInManager* const q_ptr;
64 
65  private:
66  QVector<QTranslator*> m_Translator;
67 
68  QList<QObject *> m_addInListDataIO;
69  QList<QObject *> m_addInListAct;
70  QList<QObject *> m_addInListAlgo;
71  QHash<QString, ito::AddInAlgo::FilterDef *> m_filterList;
72  QMultiHash<QString, ito::AddInAlgo::FilterDef *> m_filterListInterfaceTag; //hash value is "{interface-number}_{tag}"
73  QHash<QString, ito::AddInAlgo::AlgoWidgetDef *> m_algoWidgetList;
74  QHash<void*, ito::FilterParams *> filterParamHash;
75  QList<PluginLoadStatus> m_pluginLoadStatus;
76  QObject *m_pMainWindow;
77  QObject *m_pMainApplication;
78 
79  AlgoInterfaceValidator *m_algoInterfaceValidator;
80  PlugInModel *m_plugInModel;
81 
82  QCoreApplication *m_pQCoreApp;
83  QList< QPointer<ito::AddInBase> > m_deadPlugins;
84  QTimer m_deadPluginTimer;
85  int m_timeOutInitClose;
86  int m_timeOutGeneral;
87 
88  int getItemNum(const void *item);
89  int getPluginNum(const QString &name, ito::AddInInterfaceBase *&addIn);
90  const RetVal saveParamVals(ito::AddInBase *plugin);
91  const RetVal loadParamVals(ito::AddInBase *plugin);
92  void incRefParamPlugins(ito::AddInBase *ai, QVector<ito::ParamBase> *paramsMand, QVector<ito::ParamBase> *paramsOpt);
94  const RetVal decRef(ito::AddInBase **plugin);
95  const RetVal closeAddIn(AddInBase *addIn, ItomSharedSemaphore *aimWait = NULL);
96 
97  template<typename _Tp> const RetVal initAddInActuatorOrDataIO(
98  bool actuatorNotDataIO,
99  const int pluginNum, const QString &name,
100  _Tp** addIn, QVector<ito::ParamBase> *paramsMand,
101  QVector<ito::ParamBase> *paramsOpt, bool autoLoadPluginParams,
102  ItomSharedSemaphore *aimWait = NULL);
103 
104  const RetVal initAddInAlgo(
105  const int pluginNum, const QString &name, ito::AddInAlgo **addIn,
106  QVector<ito::ParamBase> * paramsMand, QVector<ito::ParamBase> * paramsOpt,
107  bool autoLoadPluginParams, ItomSharedSemaphore *aimWait = NULL);
108 
109  protected:
110  void setItomProperties(void *propPtr) {};
111  RetVal initDockWidget(const ito::AddInBase *addIn);
112  RetVal loadAddIn(QString &filename);
113 
114  RetVal loadAddInDataIO(QObject *plugin, ito::PluginLoadStatus &pluginLoadStatus);
115  RetVal loadAddInActuator(QObject *plugin, ito::PluginLoadStatus &pluginLoadStatus);
116  RetVal loadAddInAlgo(QObject *plugin, ito::PluginLoadStatus &pluginLoadStatus);
117 
119 
120  private slots:
122  void propertiesChanged();
123 };
124 
125 } //end namespace ito
126 
127 
128 
129 #endif // ADDINMANAGERIMPL_H
RetVal closeDeadPlugins()
Definition: addInManagerPrivate.cpp:219
RetVal initDockWidget(const ito::AddInBase *addIn)
Definition: addInManagerPrivate.cpp:1356
The class AlgoInterfaceValidator provides validators and checks in order to verify that a certain fil...
Definition: algoInterfaceValidator.h:37
const RetVal loadParamVals(ito::AddInBase *plugin)
Definition: addInManagerPrivate.cpp:1252
class for visualizing the available (loaded) plugins
Definition: pluginModel.h:78
Class for managing status values (like errors or warning)
Definition: retVal.h:54
Base class for all plugins.
Definition: addInInterface.h:385
RetVal loadAddInDataIO(QObject *plugin, ito::PluginLoadStatus &pluginLoadStatus)
Definition: addInManagerPrivate.cpp:519
class for AddIn management
Definition: addInManager.h:66
base class for all "algorithm" plugin classes
Definition: addInInterface.h:929
RetVal loadAddInActuator(QObject *plugin, ito::PluginLoadStatus &pluginLoadStatus)
Definition: addInManagerPrivate.cpp:540
const RetVal closeAddIn(AddInBase *addIn, ItomSharedSemaphore *aimWait=NULL)
Definition: addInManagerPrivate.cpp:1032
void incRefParamPlugins(ito::AddInBase *ai, QVector< ito::ParamBase > *paramsMand, QVector< ito::ParamBase > *paramsOpt)
Definition: addInManagerPrivate.cpp:98
Definition: apiFunctionsGraph.cpp:39
This struct provides a structure for saving the load status of any plugins or designerWidgets.
Definition: pluginModel.h:61
RetVal loadAddInAlgo(QObject *plugin, ito::PluginLoadStatus &pluginLoadStatus)
Definition: addInManagerPrivate.cpp:561
RetVal registerPluginAsDeadPlugin(ito::AddInBase *addIn)
Definition: addInManagerPrivate.cpp:264
semaphore which can be used for asychronous thread communication. By using this class it is possible ...
Definition: sharedStructuresQt.h:57
ito::RetVal decRefParamPlugins(ito::AddInBase *ai)
Definition: addInManagerPrivate.cpp:61
forward declaration to private container class of AddInAlog
Definition: addInInterface.h:248
const RetVal initAddInAlgo(const int pluginNum, const QString &name, ito::AddInAlgo **addIn, QVector< ito::ParamBase > *paramsMand, QVector< ito::ParamBase > *paramsOpt, bool autoLoadPluginParams, ItomSharedSemaphore *aimWait=NULL)
Definition: addInManagerPrivate.cpp:775
RetVal loadAddIn(QString &filename)
Definition: addInManagerPrivate.cpp:282
Definition: addInManagerPrivate.h:53
const RetVal decRef(ito::AddInBase **plugin)
Definition: addInManagerPrivate.cpp:1172
const RetVal saveParamVals(ito::AddInBase *plugin)
Definition: addInManagerPrivate.cpp:1197