aboutsummaryrefslogtreecommitdiff
path: root/base/plugins.h
diff options
context:
space:
mode:
authorMax Horn2006-10-07 00:22:48 +0000
committerMax Horn2006-10-07 00:22:48 +0000
commit26e4e1680050448ad85693d7be5cb07abdeab89c (patch)
treee4db82b38686ee9b26cdaf0d96afe38e904c4161 /base/plugins.h
parent1373686c348f33634bc284c993cb0d5c2b6f0ff6 (diff)
downloadscummvm-rg350-26e4e1680050448ad85693d7be5cb07abdeab89c.tar.gz
scummvm-rg350-26e4e1680050448ad85693d7be5cb07abdeab89c.tar.bz2
scummvm-rg350-26e4e1680050448ad85693d7be5cb07abdeab89c.zip
Started to refactor the plugin code (moving backend specific stuff into backends/plugins/)
svn-id: r24148
Diffstat (limited to 'base/plugins.h')
-rw-r--r--base/plugins.h31
1 files changed, 25 insertions, 6 deletions
diff --git a/base/plugins.h b/base/plugins.h
index 944f4b0aa8..acaa637162 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -25,6 +25,7 @@
#define BASE_PLUGINS_H
#include "common/array.h"
+#include "common/list.h"
#include "common/singleton.h"
#include "common/util.h"
#include "base/game.h"
@@ -86,14 +87,14 @@ enum PluginError {
*/
class Plugin {
public:
- virtual ~Plugin() {}
+ virtual ~Plugin() {}
- virtual bool loadPlugin() { return true; }
- virtual void unloadPlugin() {}
+ virtual bool loadPlugin() = 0;
+ virtual void unloadPlugin() = 0;
virtual const char *getName() const = 0;
virtual const char *getCopyright() const = 0;
- virtual int getVersion() const { return 0; } // TODO!
+// virtual int getVersion() const { return 0; } // TODO!
virtual GameList getSupportedGames() const = 0;
virtual GameDescriptor findGame(const char *gameid) const = 0;
@@ -173,7 +174,8 @@ protected:
GameList _games;
public:
- PluginRegistrator(const char *name, const char *copyright, GameList games, GameIDQueryFunc qf, EngineFactory ef, DetectFunc df);
+ PluginRegistrator(const char *name, const char *copyright, GameList games, GameIDQueryFunc qf, EngineFactory ef, DetectFunc df)
+ : _name(name), _copyright(copyright), _qf(qf), _ef(ef), _df(df), _games(games) {}
};
#endif
@@ -182,7 +184,20 @@ public:
typedef Common::Array<Plugin *> PluginList;
-class PluginManager;
+class PluginProvider {
+public:
+ virtual ~PluginProvider() {}
+
+ /**
+ * Return a list of Plugin objects. The caller is responsible for actually
+ * loading/unloading them (by invoking the appropriate methods).
+ * Furthermore, the caller is responsible for deleting these objects
+ * eventually.
+ */
+ virtual PluginList getPlugins() = 0;
+};
+
+//class PluginManager;
/**
* Instances of this class manage all plugins, including loading them,
@@ -191,8 +206,10 @@ class PluginManager;
* @todo Add support for dynamic plugins (this may need additional API, e.g. for a plugin path)
*/
class PluginManager : public Common::Singleton<PluginManager> {
+ typedef Common::List<PluginProvider *> ProviderList;
private:
PluginList _plugins;
+ ProviderList _providers;
bool tryLoadPlugin(Plugin *plugin);
@@ -201,6 +218,8 @@ private:
public:
~PluginManager();
+
+ void addPluginProvider(PluginProvider *pp);
void loadPlugins();
void unloadPlugins();