File indexing completed on 2025-01-05 03:59:31
0001 // SPDX-License-Identifier: LGPL-2.1-or-later 0002 // 0003 // SPDX-FileCopyrightText: 2006-2008 Torsten Rahn <tackat@kde.org> 0004 // SPDX-FileCopyrightText: 2009 Jens-Michael Hoffmann <jensmh@gmx.de> 0005 // 0006 0007 #ifndef MARBLE_PLUGINMANAGER_H 0008 #define MARBLE_PLUGINMANAGER_H 0009 0010 #include <QObject> 0011 #include <QList> 0012 0013 #include "digikam_export.h" 0014 0015 namespace Marble 0016 { 0017 0018 class RenderPlugin; 0019 class PluginManagerPrivate; 0020 class SearchRunnerPlugin; 0021 class ReverseGeocodingRunnerPlugin; 0022 class ParseRunnerPlugin; 0023 0024 /** 0025 * @short The class that handles Marble's plugins. 0026 * 0027 * Ownership policy for plugins: 0028 * 0029 * On every invocation of createNetworkPlugins and 0030 * createFloatItems the PluginManager creates new objects and transfers 0031 * ownership to the calling site. In order to create 0032 * the objects, the PluginManager internally has a list of the plugins 0033 * which are owned by the PluginManager and destroyed by it. 0034 * 0035 */ 0036 0037 class DIGIKAM_EXPORT PluginManager : public QObject 0038 { 0039 Q_OBJECT 0040 0041 public: 0042 0043 explicit PluginManager( QObject* parent = nullptr ); 0044 0045 ~PluginManager() override; 0046 0047 /** 0048 * @brief Returns all available RenderPlugins. 0049 * 0050 * Ownership of the items remains in PluginManager. 0051 * In order to use the RenderPlugins, first create new instances using 0052 * RenderPlugin::newInstance(). 0053 */ 0054 QList<const RenderPlugin *> renderPlugins() const; 0055 0056 /** 0057 * @brief Add a RenderPlugin manually to the list of known plugins. Normally you 0058 * don't need to call this method since all plugins are loaded automatically. 0059 * @param plugin The plugin to add. Ownership retains with the caller. 0060 */ 0061 void addRenderPlugin( const RenderPlugin *plugin ); 0062 0063 /** 0064 * Returns all search runner plugins. 0065 * @note: Runner plugins are owned by the PluginManager, do not delete them. 0066 */ 0067 QList<const SearchRunnerPlugin *> searchRunnerPlugins() const; 0068 0069 /** 0070 * @brief Add a SearchRunnerPlugin manually to the list of known plugins. Normally you 0071 * don't need to call this method since all plugins are loaded automatically. 0072 * @param plugin The plugin to add. Ownership retains with the caller. 0073 */ 0074 void addSearchRunnerPlugin( const SearchRunnerPlugin *plugin ); 0075 0076 /** 0077 * Returns all reverse geocoding runner plugins. 0078 * @note: The runner plugins are owned by the PluginManager, do not delete them. 0079 */ 0080 QList<const ReverseGeocodingRunnerPlugin *> reverseGeocodingRunnerPlugins() const; 0081 0082 /** 0083 * @brief Add a ReverseGeocodingRunnerPlugin manually to the list of known plugins. Normally you 0084 * don't need to call this method since all plugins are loaded automatically. 0085 * @param plugin The plugin to add. Ownership retains with the caller. 0086 */ 0087 void addReverseGeocodingRunnerPlugin( const ReverseGeocodingRunnerPlugin *plugin ); 0088 0089 /** 0090 * Returns all parse runner plugins. 0091 * @note: The runner plugins are owned by the PluginManager, do not delete them. 0092 */ 0093 QList<const ParseRunnerPlugin *> parsingRunnerPlugins() const; 0094 0095 /** 0096 * @brief Add a ParseRunnerPlugin manually to the list of known plugins. Normally you 0097 * don't need to call this method since all plugins are loaded automatically. 0098 * @param plugin The plugin to add. Ownership retains with the caller. 0099 */ 0100 void addParseRunnerPlugin( const ParseRunnerPlugin *plugin ); 0101 0102 /** 0103 * @brief blacklistPlugin Prevent that a plugin is loaded from the given filename 0104 * @param filename The name of the file (excluding prefix and file extension) to blacklist. E.g. 0105 * to ignore "libWikipedia.so" on Linux and "Wikipedia.dll" on Windows, pass "Wikipedia" 0106 */ 0107 static void blacklistPlugin(const QString &filename); 0108 0109 /** 0110 * @brief whitelistPlugin Add a plugin to the whitelist of plugins. If the whitelist is not 0111 * empty, only whitelisted plugins are loaded. If a plugin is both whitelisted and blacklisted, 0112 * it will not be loaded 0113 * @param filename The name of the file (excluding prefix and file extension) to whitelist. E.g. 0114 * to ignore "libWikipedia.so" on Linux and "Wikipedia.dll" on Windows, pass "Wikipedia" 0115 */ 0116 static void whitelistPlugin(const QString &filename); 0117 0118 Q_SIGNALS: 0119 0120 void renderPluginsChanged(); 0121 0122 void positionProviderPluginsChanged(); 0123 0124 void searchRunnerPluginsChanged(); 0125 0126 void reverseGeocodingRunnerPluginsChanged(); 0127 0128 void parseRunnerPluginsChanged(); 0129 0130 private: 0131 0132 Q_DISABLE_COPY( PluginManager ) 0133 0134 #ifdef Q_OS_ANDROID 0135 0136 void installPluginsFromAssets() const; 0137 0138 #endif 0139 0140 PluginManagerPrivate* const d; 0141 }; 0142 0143 } 0144 0145 #endif