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>
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>
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 IPLUGINMANAGER_H
22 #define IPLUGINMANAGER_H
24 #include "iplugin_spec.h"
26 #include <QtCore/QList>
27 #include <QtCore/QObject>
28 #include <QtCore/QStringList>
29 #include <QtCore/QSettings>
31 namespace ExtensionSystem
36 @interface IPluginManager
37 @brief Interface for plugin system that manages the plugins, their life cycle and their registered objects.
38 @details The plugin manager is used for the following tasks:
39 - Manage plugins and their state
40 - Manipulate a 'common object pool'
42 class IPluginManager
: public QObject
46 IPluginManager(QObject
*parent
= 0): QObject(parent
) {}
47 virtual ~IPluginManager() {}
49 // Object pool operations
50 virtual void addObject(QObject
*obj
) = 0;
51 virtual void removeObject(QObject
*obj
) = 0;
52 virtual QList
<QObject
*> allObjects() const = 0;
55 virtual void loadPlugins() = 0;
56 virtual QStringList
getPluginPaths() const = 0;
57 virtual void setPluginPaths(const QStringList
&paths
) = 0;
58 virtual QList
<ExtensionSystem::IPluginSpec
*> plugins() const = 0;
60 virtual bool loadPlugin( const QString
&plugin
) = 0;
61 virtual bool unloadPlugin( ExtensionSystem::IPluginSpec
*plugin
) = 0;
64 virtual void setSettings(QSettings
*settings
) = 0;
65 virtual QSettings
*settings() const = 0;
67 // Auxiliary operations
69 /// Retrieve all objects of a given type from the object pool.
71 QList
<T
*> getObjects() const
73 QList
<QObject
*> all
= allObjects();
75 Q_FOREACH(QObject
*obj
, all
)
77 T
*tObj
= qobject_cast
<T
*>(obj
);
84 /// Retrieve the object of a given type from the object pool.
88 QList
<QObject
*> all
= allObjects();
90 Q_FOREACH(QObject
*obj
, all
)
92 T
*tObj
= qobject_cast
<T
*>(obj
);
102 QObject
*objectByName(const QString
&name
) const
104 QList
<QObject
*> all
= allObjects();
106 Q_FOREACH(QObject
*qobj
, all
)
108 if (qobj
->objectName() == name
)
117 ExtensionSystem::IPluginSpec
*pluginByName(const QString
&name
) const
119 QList
<ExtensionSystem::IPluginSpec
*> all
= plugins();
120 ExtensionSystem::IPluginSpec
*result
= 0;
121 Q_FOREACH (ExtensionSystem::IPluginSpec
*spec
, all
)
123 if (spec
->name() == name
)
133 /// Signal that \a obj has been added to the object pool.
134 void objectAdded(QObject
*obj
);
136 /// Signal that \a obj will be removed from the object pool.
137 void aboutToRemoveObject(QObject
*obj
);
139 /// Signal that the list of available plugins has changed.
140 void pluginsChanged();
142 void pluginCount( int count
);
144 void pluginLoading( const char *plugin
);
145 void pluginInitializing( const char *plugin
);
146 void pluginStarting( const char *plugin
);
148 void pluginsLoaded();
149 void pluginsInitialized();
150 void pluginsStarted();
153 }; // namespace ExtensionSystem
155 #endif // IPLUGINMANAGER_H