aboutsummaryrefslogtreecommitdiff
path: root/base
diff options
context:
space:
mode:
authorJordi Vilalta Prat2008-02-04 18:38:22 +0000
committerJordi Vilalta Prat2008-02-04 18:38:22 +0000
commite4ab5dd33964c536ca1813e4a78373dda0008052 (patch)
tree1ff9af75ed432825cd6084b9a6cbe0a3b74a4c24 /base
parent468e9cb056382043008a1ffbbf09acbeb972d1ec (diff)
downloadscummvm-rg350-e4ab5dd33964c536ca1813e4a78373dda0008052.tar.gz
scummvm-rg350-e4ab5dd33964c536ca1813e4a78373dda0008052.tar.bz2
scummvm-rg350-e4ab5dd33964c536ca1813e4a78373dda0008052.zip
Change MetaEngine references to PluginObject where possible to make its semantics more generic.
svn-id: r30789
Diffstat (limited to 'base')
-rw-r--r--base/plugins.cpp27
-rw-r--r--base/plugins.h32
2 files changed, 36 insertions, 23 deletions
diff --git a/base/plugins.cpp b/base/plugins.cpp
index 4364cd0215..3a53142438 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -25,48 +25,47 @@
#include "base/plugins.h"
#include "common/util.h"
-#include "engines/metaengine.h"
const char *Plugin::getName() const {
- return _metaengine->getName();
+ return _pluginObject->getName();
}
const char *Plugin::getCopyright() const {
- return _metaengine->getCopyright();
+ return ((MetaEngine*)_pluginObject)->getCopyright();
}
PluginError Plugin::createInstance(OSystem *syst, Engine **engine) const {
- return _metaengine->createInstance(syst, engine);
+ return ((MetaEngine*)_pluginObject)->createInstance(syst, engine);
}
GameList Plugin::getSupportedGames() const {
- return _metaengine->getSupportedGames();
+ return ((MetaEngine*)_pluginObject)->getSupportedGames();
}
GameDescriptor Plugin::findGame(const char *gameid) const {
- return _metaengine->findGame(gameid);
+ return ((MetaEngine*)_pluginObject)->findGame(gameid);
}
GameList Plugin::detectGames(const FSList &fslist) const {
- return _metaengine->detectGames(fslist);
+ return ((MetaEngine*)_pluginObject)->detectGames(fslist);
}
SaveStateList Plugin::listSaves(const char *target) const {
- return _metaengine->listSaves(target);
+ return ((MetaEngine*)_pluginObject)->listSaves(target);
}
#ifndef DYNAMIC_MODULES
class StaticPlugin : public Plugin {
public:
- StaticPlugin(MetaEngine *metaengine) {
- assert(metaengine);
- _metaengine = metaengine;
+ StaticPlugin(PluginObject *pluginobject) {
+ assert(pluginobject);
+ _pluginObject = pluginobject;
}
~StaticPlugin() {
- delete _metaengine;
+ delete _pluginObject;
}
virtual bool loadPlugin() { return true; }
@@ -85,8 +84,8 @@ public:
PluginList pl;
#define LINK_PLUGIN(ID) \
- extern MetaEngine *g_##ID##_MetaEngine_alloc(); \
- pl.push_back(new StaticPlugin(g_##ID##_MetaEngine_alloc()));
+ extern PluginObject *g_##ID##_getObject(); \
+ pl.push_back(new StaticPlugin(g_##ID##_getObject()));
// "Loader" for the static plugins.
// Iterate over all registered (static) plugins and load them.
diff --git a/base/plugins.h b/base/plugins.h
index bc65a13644..e91ed80aa4 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -33,9 +33,23 @@
#include "common/util.h"
#include "base/game.h"
+/**
+ * Abstract base class for the plugin objects which handle plugins
+ * instantiation. Subclasses for this may be used for engine plugins
+ * and other types of plugins.
+ */
+class PluginObject {
+public:
+ virtual ~PluginObject() {}
+
+ /** Returns the name of the plugin. */
+ virtual const char *getName() const = 0;
+};
+
+#include "engines/metaengine.h"
+
class Engine;
class FSList;
-class MetaEngine;
class OSystem;
/**
@@ -45,10 +59,10 @@ class OSystem;
*/
class Plugin {
protected:
- MetaEngine *_metaengine;
+ PluginObject *_pluginObject;
public:
- Plugin() : _metaengine(0) {}
+ Plugin() : _pluginObject(0) {}
virtual ~Plugin() {
//if (isLoaded())
//unloadPlugin();
@@ -81,16 +95,16 @@ public:
*/
#ifndef DYNAMIC_MODULES
-#define REGISTER_PLUGIN(ID,METAENGINE) \
- MetaEngine *g_##ID##_MetaEngine_alloc() { \
- return new METAENGINE(); \
+#define REGISTER_PLUGIN(ID,PLUGINCLASS) \
+ PluginObject *g_##ID##_getObject() { \
+ return new PLUGINCLASS(); \
} \
void dummyFuncToAllowTrailingSemicolon()
#else
-#define REGISTER_PLUGIN(ID,METAENGINE) \
+#define REGISTER_PLUGIN(ID,PLUGINCLASS) \
extern "C" { \
- PLUGIN_EXPORT MetaEngine *PLUGIN_MetaEngine_alloc() { \
- return new METAENGINE(); \
+ PLUGIN_EXPORT PluginObject *PLUGIN_getObject() { \
+ return new PLUGINCLASS(); \
} \
} \
void dummyFuncToAllowTrailingSemicolon()