Fix
[ryzomcore.git] / studio / src / extension_system / plugin_manager.h
blob42bca3d9774931163544eb0c52e2f234d513de23
1 // Object Viewer Qt - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010-2011 Dzmitry KAMIAHIN (dnk-88) <dnk-88@tut.by>
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2010 Winch Gate Property Limited
6 // Copyright (C) 2014 Laszlo KIS-ADAM (dfighter) <dfighter1985@gmail.com>
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU Affero General Public License as
10 // published by the Free Software Foundation, either version 3 of the
11 // License, or (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Affero General Public License for more details.
18 // You should have received a copy of the GNU Affero General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifndef PLUGINMANAGER_H
22 #define PLUGINMANAGER_H
24 // Qt Include
25 #include <QtCore/QReadWriteLock>
27 // Project include
28 #include "iplugin_manager.h"
30 namespace ExtensionSystem
33 class IPlugin;
34 class PluginSpec;
36 class PluginManager : public IPluginManager
38 Q_OBJECT
40 public:
41 PluginManager(QObject *parent = 0);
42 ~PluginManager();
44 // Object pool operations
45 virtual void addObject(QObject *obj);
46 virtual void removeObject(QObject *obj);
47 virtual QList<QObject *> allObjects() const;
49 // Plugin operations
50 virtual void loadPlugins();
51 virtual QStringList getPluginPaths() const;
52 virtual void setPluginPaths(const QStringList &paths);
53 virtual QList<IPluginSpec *> plugins() const;
54 QList<PluginSpec *> loadQueue();
56 bool loadPlugin( const QString &plugin );
57 bool unloadPlugin( ExtensionSystem::IPluginSpec *plugin );
60 // Settings
61 virtual void setSettings(QSettings *settings);
62 virtual QSettings *settings() const;
63 void readSettings();
64 void writeSettings();
66 private:
67 bool loadPluginSpec( const QString &plugin );
68 void removePlugin( ExtensionSystem::IPluginSpec *plugin );
69 void setPluginState(PluginSpec *spec, int destState);
70 void readPluginPaths();
71 bool loadQueue(PluginSpec *spec, QList<PluginSpec *> &queue, QList<PluginSpec *> &circularityCheckQueue);
72 void stopAll();
73 void deleteAll();
75 mutable QReadWriteLock m_lock;
77 QSettings *m_settings;
78 QString m_extension;
79 QList<PluginSpec *> m_pluginSpecs;
80 QList<IPluginSpec *> m_ipluginSpecs;
81 QStringList m_pluginPaths;
82 QList<QObject *> m_allObjects;
84 }; // class PluginManager
86 } // namespace ExtensionSystem
88 #endif // PLUGINMANAGER_H