Fraxinus  22.09
An IGT application
cxPluginFramework.h
Go to the documentation of this file.
1 /*=========================================================================
2 This file is part of CustusX, an Image Guided Therapy Application.
3 
4 Copyright (c) SINTEF Department of Medical Technology.
5 All rights reserved.
6 
7 CustusX is released under a BSD 3-Clause license.
8 
9 See Lisence.txt (https://github.com/SINTEFMedtek/CustusX/blob/master/License.txt) for details.
10 =========================================================================*/
11 
12 #ifndef CXPLUGINFRAMEWORK_H_
13 #define CXPLUGINFRAMEWORK_H_
14 
15 #include "cxLogicManagerExport.h"
16 
17 #include <QString>
18 #include <QObject>
19 #include <boost/shared_ptr.hpp>
20 
21 #include "ctkPlugin.h"
22 #include "ctkPluginFramework_global.h"
23 
24 typedef QSharedPointer<ctkPlugin> ctkPluginPtr;
25 typedef std::pair<QString,ctkPluginPtr> PluginData;
26 
27 class ctkPluginFramework;
28 class ctkPluginFrameworkFactory;
29 class ctkException;
30 
31 namespace cx
32 {
33 typedef boost::shared_ptr<class PluginFrameworkManager> PluginFrameworkManagerPtr;
34 
40 class cxLogicManager_EXPORT PluginFrameworkManager : public QObject
41 {
42  Q_OBJECT
43 
44  struct PluginLoadInfo
45  {
46  QString symbolicName;
47  QString storedState;
48  ctkPlugin::State targetState;
49  bool isNew;
50  };
51 
52 public:
53  static PluginFrameworkManagerPtr create() { return PluginFrameworkManagerPtr(new PluginFrameworkManager()); }
54 
57 
58  void install(const QString& symbolicName);
59  void uninstall(const QString& symbolicName);
60  bool start(const QString& symbolicName, ctkPlugin::StartOptions options = ctkPlugin::START_ACTIVATION_POLICY);
61  bool stop(const QString& symbolicName, ctkPlugin::StopOptions options = 0);
62  bool start();
63  bool stop();
64 
65  ctkPluginContext* getPluginContext();
66  QSharedPointer<ctkPluginFramework> getPluginFramework();
67 
68 // void addSearchPath(const QString& searchPath);
69  void setSearchPaths(const QStringList& searchPath);
70  QStringList getSearchPaths() const;
71  QStringList getPluginSymbolicNames();
72  QSharedPointer<ctkPlugin> getInstalledPluginFromSymbolicName(QString symbolicName);
73  ctkPlugin::State getStateFromSymbolicName(QString name);
74  void loadState();
75 
76 signals:
77  void pluginPoolChanged();
78  void aboutToStop();
79 
80 private:
81  QString getPluginPath(const QString& symbolicName);
82  QStringList getPluginSymbolicNames(const QString& searchPath);
83  bool nameIsProbablyPlugin(QString name) const;
84  std::vector<PluginFrameworkManager::PluginLoadInfo> getPluginLoadInfo(QStringList symbolicNames);
85 
86  QScopedPointer<ctkPluginFrameworkFactory> mFrameworkFactory;
87  QSharedPointer<ctkPluginFramework> mFramework;
88 
89  void initializeFramework();
90  void startFramework();
91 
92  bool frameworkInitialized() const;
93  bool frameworkStarted() const;
94 
95  void saveState();
96  void loadPluginFromStoredState(QString symbolicName, QString storedState);
97 
98  QString convertToRelativePath(QString path) const;
99  QString convertToAbsolutePath(QString path) const;
100 
101  QStringList mPluginSearchPaths;
102  QStringList mPluginLibFilter;
103 
104  QString mSettingsSearchPaths;
105  QString mSettingsBase;
106 
107  void handlePluginException(const QString& message, const ctkException &exc);
108 };
109 
110 } /* namespace cx */
111 #endif /* CXPLUGINFRAMEWORK_H_ */
QSharedPointer< ctkPlugin > ctkPluginPtr
std::pair< QString, ctkPluginPtr > PluginData
boost::shared_ptr< class PluginFrameworkManager > PluginFrameworkManagerPtr
static PluginFrameworkManagerPtr create()
Namespace for all CustusX production code.