2 * @file Plugins/pluginmanager_p.h
3 * @brief Private implementation of the plugin manager
5 * Copyright (c) 2011-2019 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 <QScopedPointer>
26 #include <QPluginLoader>
40 * Internal implementation of the plugin manager
42 class PluginManagerPrivate
: public QObject
49 PluginManagerPrivate();
52 virtual ~PluginManagerPrivate();
55 * Initializes the private plugin manager object
56 * @return True; false if failed
61 * Finalizes the private plugin manager object
66 * Loads and initializes plugins
67 * @return True; false if failed
72 * Finalizes and unloads plugins
79 /// List of all the modules
80 QList
<QExplicitlySharedDataPointer
<Module
> > mModules
;
82 /// List of all the plugins
83 QList
<QExplicitlySharedDataPointer
<Plugin
> > mPlugins
;
89 * Returns the module object by its name
90 * @param name Name of the module
91 * @return Module object or 0 if not found
93 Module
* moduleByName(QString
const & name
) const;
98 * One external module implementing the iPluginFactory or the iPlugin interfaces.
100 * This class is a wrapper around the external module.
102 class Module
: public QSharedData
108 * @param name Name of the module
110 Module(QString
const & name
);
115 /// Returns true if the module is loaded
116 bool isLoaded() const { return mLoader
!= 0; }
118 /// The name of the module
119 QString
const & name() const { return mName
; }
123 * @return True; false if failed
127 /// Unloads the module
131 * Creates the requested iPlugin interface object
132 * @param name Name of the interface
133 * @return The iPlugin interface object or 0 if failed
135 iPlugin
* create(QString
const & name
);
140 /// Name of the module
144 QScopedPointer
<QPluginLoader
> mLoader
;
146 /// Plugin's root component
149 /// The iPlugin interface object if the module implements only one iPlugin interface
152 /// The iPluginFactory interface object if the module implements more than one iPluginFactory interface
153 iPluginFactory
* mPluginFactory
;
158 * One iPlugin interface object.
160 * This class is a wrapper around the plugin.
162 class Plugin
: public QSharedData
168 * @param module The Module implementing this iPlugin interface
169 * @param name Name of the plugin
170 * @param args Arguments for the plugin initialization
172 Plugin(Module
* module, QString
const & name
, QString
const & args
);
177 /// The iPlugin interface
178 iPlugin
* plugin() const { return mPlugin
; }
180 /// The name of the plugin
181 QString
const & name() const { return mName
; }
185 * @return True; false if failed
189 /// Unloads the plugin
193 * Initializes the plugin
194 * @return True; false if failed
198 /// Uninitializes the plugin
204 /// Module implementing this iPlugin interface
207 /// Name of the plugin
210 /// Arguments for the initialization
213 /// The iPlugin interface object
218 } // namespace eVaf::Plugins::Internal
219 } // namespace eVaf::Plugins
222 #endif // pluginmanager_p.h