eVaf
pluginmanager_p.h
Go to the documentation of this file.
1 
19 #ifndef __PLUGINS_PLUGINMANAGER_P_H
20 #define __PLUGINS_PLUGINMANAGER_P_H
21 
22 #include <QObject>
23 #include <QSharedData>
24 #include <QExplicitlySharedDataPointer>
25 #include <QPluginLoader>
26 
27 namespace eVaf {
28 namespace Plugins {
29 
30 class iPlugin;
31 class iPluginFactory;
32 
33 namespace Internal {
34 
35 class Plugin;
36 class Module;
37 
42 {
43  Q_OBJECT
44 
45 public:
46 
49 
51  virtual ~PluginManagerPrivate();
52 
57  bool init();
58 
62  void done();
63 
68  bool loadPlugins();
69 
73  void unloadPlugins();
74 
75 
76 private: // Members
77 
79  QList<QExplicitlySharedDataPointer<Module> > mModules;
80 
82  QList<QExplicitlySharedDataPointer<Plugin> > mPlugins;
83 
84 
85 private: // Methods
86 
92  Module * moduleByName(QString const & name) const;
93 
94 };
95 
101 class Module : public QSharedData
102 {
103 public:
104 
109  Module(QString const & name);
110 
112  ~Module();
113 
115  bool isLoaded() const { return mLoader != 0; }
116 
118  QString const & name() const { return mName; }
119 
124  bool load();
125 
127  void unload();
128 
134  iPlugin * create(QString const & name);
135 
136 
137 private: // Members
138 
140  QString mName;
141 
143  QPluginLoader * mLoader;
144 
146  QObject * mRoot;
147 
149  iPlugin * mPlugin;
150 
152  iPluginFactory * mPluginFactory;
153 
154 };
155 
161 class Plugin : public QSharedData
162 {
163 public:
164 
171  Plugin(Module * module, QString const & name, QString const & args);
172 
174  ~Plugin();
175 
177  iPlugin * plugin() const { return mPlugin; }
178 
180  QString const & name() const { return mName; }
181 
186  bool load();
187 
189  void unload();
190 
195  bool init();
196 
198  void done();
199 
200 
201 private: // Members
202 
204  Module * mModule;
205 
207  QString mName;
208 
210  QString mArgs;
211 
213  iPlugin * mPlugin;
214 
215 };
216 
217 } // namespace eVaf::Plugins::Internal
218 } // namespace eVaf::Plugins
219 } // namespace eVaf
220 
221 #endif // pluginmanager_p.h
Internal implementation of the plugin manager.
QString const & name() const
The name of the module.
One external module implementing the iPluginFactory or the iPlugin interfaces.
bool loadPlugins()
Loads and initializes plugins.
Common plugin factory interface for eVaf modules.
void done()
Finalizes the private plugin manager object.
One iPlugin interface object.
bool init()
Initializes the private plugin manager object.
Global eVaf namespace.
Definition: engine.h:37
QString const & name() const
The name of the plugin.
void unloadPlugins()
Finalizes and unloads plugins.
Common interface for all the eVaf modules.
Definition: iplugin.h:38
iPlugin * plugin() const
The iPlugin interface.
bool isLoaded() const
Returns true if the module is loaded.