Computer Assisted Medical Intervention Tool Kit  version 5.2
ExtensionManager.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * $CAMITK_LICENCE_BEGIN$
3  *
4  * CamiTK - Computer Assisted Medical Intervention ToolKit
5  * (c) 2001-2024 Univ. Grenoble Alpes, CNRS, Grenoble INP - UGA, TIMC, 38000 Grenoble, France
6  *
7  * Visit http://camitk.imag.fr for more information
8  *
9  * This file is part of CamiTK.
10  *
11  * CamiTK is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * CamiTK is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Lesser General Public License version 3 for more details.
19  *
20  * You should have received a copy of the GNU Lesser General Public License
21  * version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
22  *
23  * $CAMITK_LICENCE_END$
24  ****************************************************************************/
25 
26 
27 #ifndef EXTENSIONS_MANAGER_H
28 #define EXTENSIONS_MANAGER_H
29 
30 // -- Core stuff
31 #include "ComponentExtension.h"
32 #include "ActionExtension.h"
33 #include "ViewerExtension.h"
34 #include "CamiTKAPI.h"
35 #include "AbortException.h"
36 
37 // -- QT stuff
38 #include <QtPlugin>
39 #include <QPluginLoader>
40 #include <QStringList>
41 #include <QMap>
42 #include <QDir>
43 
44 namespace camitk {
58 class CAMITK_API ExtensionManager : public QObject {
59 
60 public:
69  VIEWER
70  };
71 
73  static void autoload();
74 
87  static void autoload(ExtensionType type);
88 
96  static bool loadExtension(ExtensionType type, QString file);
97 
114  static QString getInstallationString(QString file, const QString& globalInstallDir, const QString& userInstallDir, const QString& currentWorkingDir);
115 
119 
122  static ComponentExtension* getComponentExtension(QString);
123 
134  static const QList<ComponentExtension*> getComponentExtensionsList();
135 
139  static ComponentExtension* getDataDirectoryComponentExtension(QString);
140 
151  static const QList<ComponentExtension*> getDataDirectoryComponentsList();
152 
154  static QStringList getFileExtensions();
155 
157  static QStringList getDataDirectoryExtNames();
158 
163  static void registerFileExtension(QString fileExtension);
164 
168  static bool unloadComponentExtension(QString);
170 
171 
174 
176  static void unloadAllActionExtensions();
177 
188  static const QList<ActionExtension*> getActionExtensionsList();
189 
198  static ActionExtension* getActionExtension(QString);
199 
203  static bool unloadActionExtension(QString);
205 
208 
210  static void unloadAllViewerExtensions();
211 
222  static const QList<ViewerExtension*> getViewerExtensionsList();
223 
232  static ViewerExtension* getViewerExtension(QString);
233 
237  static bool unloadViewerExtension(QString);
239 
240 private:
248  static QMap<QString, ComponentExtension*>& getComponentExtensionMap();
249 
257  static QMap<QString, ComponentExtension*>& getDataDirectoryComponentExtensionMap();
258 
266  static QMap<QString, ActionExtension*>& getActionExtensionMap();
267 
275  static QMap<QString, ViewerExtension*>& getViewerExtensionMap();
276 
278  static QStringList getExtensionFilter();
279 
281  static QStringList getPluginFileNames(QDir);
282 
291  static void initPrivateLibDirs();
292 
298  static void addLibraryPath(QDir potentialPath, QString potentialLibDir);
299 
302 
312  static bool componentExtensionLessThan(const ComponentExtension* left, const ComponentExtension* right);
313 
329  static bool actionExtensionLessThan(ActionExtension* left, ActionExtension* right);
330 
336  static bool viewerExtensionLessThan(ViewerExtension* left, ViewerExtension* right);
338 };
339 
340 }
341 
342 
343 #endif //EXTENSIONS_MANAGER_H
#define CAMITK_API
Definition: CamiTKAPI.h:49
Definition: PersistenceManager.h:34
This class describes what is a generic Action extension.
Definition: ActionExtension.h:57
This class describes what is a generic Component extension.
Definition: ComponentExtension.h:60
This class is used to manage all plugins loaded by the application.
Definition: ExtensionManager.h:58
ExtensionType
describes the CamiTK Extension Type (Action, Component, Application...).
Definition: ExtensionManager.h:65
@ ACTION
Action extensions: manages the processing logic.
Definition: ExtensionManager.h:66
@ COMPONENT
Component extensions: manages the data logic.
Definition: ExtensionManager.h:67
@ APPLICATION
MainWindow extensions: manages the application logic.
Definition: ExtensionManager.h:68
This class describes what is a generic Action extension.
Definition: ViewerExtension.h:85
Definition: Action.cpp:36