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;
97 * One external module implementing the iPluginFactory or the iPlugin interfaces.
99 * This class is a wrapper around the external module.
101 class Module
: public QSharedData
107 * @param name Name of the module
109 Module(QString
const & name
);
114 /// Returns true if the module is loaded
115 bool isLoaded() const { return mLoader
!= 0; }
117 /// The name of the module
118 QString
const & name() const { return mName
; }
122 * @return True; false if failed
126 /// Unloads the module
130 * Creates the requested iPlugin interface object
131 * @param name Name of the interface
132 * @return The iPlugin interface object or 0 if failed
134 iPlugin
* create(QString
const & name
);
139 /// Name of the module
143 QPluginLoader
* mLoader
;
145 /// Plugin's root component
148 /// The iPlugin interface object if the module implements only one iPlugin interface
151 /// The iPluginFactory interface object if the module implements more than one iPluginFactory interface
152 iPluginFactory
* mPluginFactory
;
157 * One iPlugin interface object.
159 * This class is a wrapper around the plugin.
161 class Plugin
: public QSharedData
167 * @param module The Module implementing this iPlugin interface
168 * @param name Name of the plugin
169 * @param args Arguments for the plugin initialization
171 Plugin(Module
* module, QString
const & name
, QString
const & args
);
176 /// The iPlugin interface
177 iPlugin
* plugin() const { return mPlugin
; }
179 /// The name of the plugin
180 QString
const & name() const { return mName
; }
184 * @return True; false if failed
188 /// Unloads the plugin
192 * Initializes the plugin
193 * @return True; false if failed
197 /// Uninitializes the plugin
203 /// Module implementing this iPlugin interface
206 /// Name of the plugin
209 /// Arguments for the initialization
212 /// The iPlugin interface object
217 } // namespace eVaf::Plugins::Internal
218 } // namespace eVaf::Plugins
221 #endif // pluginmanager_p.h