/** * @RDE_HEADER@ * plugin loader helper function * $Id$ * $HeadURL$ * $Author$ * * Created by Christian Ehrlicher, SLSE, 2016-07-07 */ #pragma once #define PLUGIN_LOADER_VERSION 3 #include #include #include #include #ifndef LTSPLUGINLOADER_EXPORT # ifdef BUILD_STATIC_LIBRARIES # define LTSPLUGINLOADER_EXPORT # else # if defined(MAKE_LTSPLUGINLOADER_LIB) # define LTSPLUGINLOADER_EXPORT Q_DECL_EXPORT # else # define LTSPLUGINLOADER_EXPORT Q_DECL_IMPORT # endif # endif #endif class QObject; class QPluginLoader; namespace LtsAppDescriptor { struct AppDescription; } namespace LtsPluginManager { enum class PluginType { UNKNOWN = 0, // should not happen DATA, // 1 GUI, // 2 TOPIC_TYPE, PROJECT, STYLE, SPECIAL, // TODO: rm GUI_ELEMENT, }; struct PluginInstance // one instance for one plugin { QString pluginName; QString fullFileName; QString fileName; QObject *plugin = nullptr; QPluginLoader *pluginLoader = nullptr; }; class LTSPLUGINLOADER_EXPORT LtsPluginLoader { public: static LtsPluginLoader *getInstance(); void unloadAllPlugins(); void checkPlugins(const QVector &appVector, QStringList &errors /* out */); bool loadPlugins(PluginType requestedPluginType, const std::function &loadPlugin, const QStringList &requiredPlugins = QStringList(), /* leave empty to get all plugins of the given type */ const QString &specialTopicTypeFilter = QString(), const QStringList &optionalPlugins = QStringList()); typedef QPair PluginKey; private: friend struct LtsPluginLoaderHandler; LtsPluginLoader() = default; ~LtsPluginLoader(); QMap m_loadedPlugins; // TODO: meh... }; } // namespace LtsPluginManager