2 * @file Plugins/pluginmanager.h
3 * @brief Manager for loadable modules (plugins)
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_H
20 #define __PLUGINS_PLUGINMANAGER_H
22 #include "libplugins.h"
24 #include <version_rc.h>
28 #include <QScopedPointer>
33 * Library for managing loadable modules (plugins).
35 * The Plugins library adds loadable modules (plugins) support to the eVaf application. A module is one
36 * external library (.so or .dll file) that implements one or more plugins. A plugin is an individual object
37 * that is created and initialized as one entirety.
39 * Modules are loaded and plugins created by the plugin manager. Plugin manager uses the application's
40 * XML file to define which modules should be loaded and which plugins to be created.
45 * Internal implementation of the plugin manager library.
48 class PluginManagerPrivate
;
52 * Expands plugin names for the selected platform.
53 * @param name Name of the plugin
54 * @return Expanded plugin name
56 * This function expands the plugin name so that it becomes valid for the selected platform.
57 * For example, on Linux it adds the prefix "lib" to the beginning and extension ".so" to the end.
59 inline QString
expandPluginName(QString
const & name
)
63 return "lib" + name
+ ".dll";
67 #elif defined Q_OS_LINUX
68 return "lib" + name
+ ".so";
69 #elif defined Q_OS_CYGWIN
70 return "cyg" + name
+ ".dll";
71 #elif defined Q_OS_MACOS
72 return "lib" + name
+ ".dylib";
79 * Plugin manager for eVaf applications.
81 class PLUGINS_EXPORT PluginManager
: public QObject
91 virtual ~PluginManager();
94 * Returns the plugin manager's instance
96 static PluginManager
* instance();
99 * Initializes the plugin manager.
100 * @return True if ok; false if initialization failed.
102 * This function initializes the plugin manager. External modules are loaded and plugin objects
103 * created in this function.
108 * Finalizes the plugin manager.
110 * This function finalizes the plugin manager. Plugin objects are destroyed and external modules
111 * unloaded in this function.
119 * Plugins loaded signal.
121 * This signal is emitted when all the modules are loaded and plugin objects created.
123 void pluginsLoaded();
126 * Plugins unloaded signal.
128 * This signal is emitted when all the plugin objects are destroyed and modules unloaded.
130 void pluginsUnloaded();
135 QScopedPointer
<Internal::PluginManagerPrivate
> d
;
139 } // namespace eVaf::Plugins
142 #endif // pluginmanager.h