2 * @file Plugins/pluginmanager_p.h
3 * @brief Private implementation of the plugin manager
5 * Copyright (c) 2011 Enar Vaikene
7 * This file is part of the eVaf C++ cross-platform application development framework.
9 * This file can be used under the terms of the GNU General Public License
10 * version 3.0 as published by the Free Software Foundation and appearing in
11 * the file LICENSE included in the packaging of this file. Please review the
12 * the following information to ensure the GNU General Public License version
13 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 * Alternatively, this file may be used in accordance with the Commercial License
16 * Agreement provided with the Software.
19 #ifndef __PLUGINS_PLUGINMANAGER_P_H
20 #define __PLUGINS_PLUGINMANAGER_P_H
23 #include <QSharedData>
24 #include <QExplicitlySharedDataPointer>
25 #include <QPluginLoader>
39 * Internal implementation of the plugin manager
41 class PluginManagerPrivate
: public QObject
48 PluginManagerPrivate();
51 virtual ~PluginManagerPrivate();
54 * Initializes the private plugin manager object
55 * @return True; false if failed
60 * Finalizes the private plugin manager object
65 * Loads and initializes plugins
66 * @return True; false if failed
71 * Finalizes and unloads plugins
78 /// List of all the modules
79 QList
<QExplicitlySharedDataPointer
<Module
> > mModules
;
81 /// List of all the plugins
82 QList
<QExplicitlySharedDataPointer
<Plugin
> > mPlugins
;
88 * Returns the module object by its name
89 * @param name Name of the module
90 * @return Module object or 0 if not found
92 Module
* moduleByName(QString
const & name
) const;
96 * @param Name of the Qt plugin
97 * @return True; false if failed
99 bool loadQtPlugin(QString
const & name
) const;
104 * One external module implementing the iPluginFactory or the iPlugin interfaces.
106 * This class is a wrapper around the external module.
108 class Module
: public QSharedData
114 * @param name Name of the module
116 Module(QString
const & name
);
121 /// Returns true if the module is loaded
122 bool isLoaded() const { return mLoader
!= 0; }
124 /// The name of the module
125 QString
const & name() const { return mName
; }
129 * @return True; false if failed
133 /// Unloads the module
137 * Creates the requested iPlugin interface object
138 * @param name Name of the interface
139 * @return The iPlugin interface object or 0 if failed
141 iPlugin
* create(QString
const & name
);
146 /// Name of the module
150 QPluginLoader
* mLoader
;
152 /// Plugin's root component
155 /// The iPlugin interface object if the module implements only one iPlugin interface
158 /// The iPluginFactory interface object if the module implements more than one iPluginFactory interface
159 iPluginFactory
* mPluginFactory
;
164 * One iPlugin interface object.
166 * This class is a wrapper around the plugin.
168 class Plugin
: public QSharedData
174 * @param module The Module implementing this iPlugin interface
175 * @param name Name of the plugin
176 * @param args Arguments for the plugin initialization
178 Plugin(Module
* module, QString
const & name
, QString
const & args
);
183 /// The iPlugin interface
184 iPlugin
* plugin() const { return mPlugin
; }
186 /// The name of the plugin
187 QString
const & name() const { return mName
; }
191 * @return True; false if failed
195 /// Unloads the plugin
199 * Initializes the plugin
200 * @return True; false if failed
204 /// Uninitializes the plugin
210 /// Module implementing this iPlugin interface
213 /// Name of the plugin
216 /// Arguments for the initialization
219 /// The iPlugin interface object
224 } // namespace eVaf::Plugins::Internal
225 } // namespace eVaf::Plugins
228 #endif // pluginmanager_p.h