"Fossies" - the Fresh Open Source Software Archive

Member "cutter-1.10.3/src/plugins/PluginManager.h" (8 May 2020, 1377 Bytes) of package /linux/privat/cutter-1.10.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "PluginManager.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.10.2_vs_1.10.3.

    1 
    2 #ifndef PLUGINMANAGER_H
    3 #define PLUGINMANAGER_H
    4 
    5 #include <QObject>
    6 #include <QDir>
    7 #include <memory>
    8 #include <vector>
    9 
   10 class CutterPlugin;
   11 
   12 class PluginManager: public QObject
   13 {
   14 Q_OBJECT
   15 
   16 public:
   17     static PluginManager *getInstance();
   18 
   19     class PluginTerminator
   20     {
   21     public:
   22         void operator()(CutterPlugin*) const;
   23     };
   24     using PluginPtr = std::unique_ptr<CutterPlugin, PluginTerminator>;
   25 
   26     PluginManager();
   27     ~PluginManager();
   28 
   29     /**
   30      * @brief Load all plugins, should be called once on application start
   31      * @param enablePlugins set to false if plugin code shouldn't be started
   32      */
   33     void loadPlugins(bool enablePlugins = true);
   34 
   35     /**
   36      * @brief Destroy all loaded plugins, should be called once on application shutdown
   37      */
   38     void destroyPlugins();
   39 
   40     const std::vector<PluginPtr> &getPlugins()   { return plugins; }
   41 
   42     QVector<QDir> getPluginDirectories() const;
   43     QString getUserPluginsDirectory() const;
   44 
   45 private:
   46     std::vector<PluginPtr> plugins;
   47 
   48     void loadNativePlugins(const QDir &directory);
   49     void loadPluginsFromDir(const QDir &pluginsDir, bool writable = false);
   50 
   51 #ifdef CUTTER_ENABLE_PYTHON_BINDINGS
   52     void loadPythonPlugins(const QDir &directory);
   53     CutterPlugin *loadPythonPlugin(const char *moduleName);
   54 #endif
   55 };
   56 
   57 #define Plugins() (PluginManager::getInstance())
   58 
   59 #endif //PLUGINMANAGER_H