[Scummvm-cvs-logs] SF.net SVN: scummvm: [30789] scummvm/trunk
jvprat at users.sourceforge.net
jvprat at users.sourceforge.net
Mon Feb 4 19:38:23 CET 2008
Revision: 30789
http://scummvm.svn.sourceforge.net/scummvm/?rev=30789&view=rev
Author: jvprat
Date: 2008-02-04 10:38:22 -0800 (Mon, 04 Feb 2008)
Log Message:
-----------
Change MetaEngine references to PluginObject where possible to make its semantics more generic.
Modified Paths:
--------------
scummvm/trunk/backends/plugins/dynamic-plugin.h
scummvm/trunk/base/plugins.cpp
scummvm/trunk/base/plugins.h
scummvm/trunk/engines/metaengine.h
scummvm/trunk/plugin.exp
Modified: scummvm/trunk/backends/plugins/dynamic-plugin.h
===================================================================
--- scummvm/trunk/backends/plugins/dynamic-plugin.h 2008-02-04 17:04:03 UTC (rev 30788)
+++ scummvm/trunk/backends/plugins/dynamic-plugin.h 2008-02-04 18:38:22 UTC (rev 30789)
@@ -27,27 +27,27 @@
#define BACKENDS_PLUGINS_DYNAMICPLUGIN_H
#include "base/plugins.h"
-#include "engines/metaengine.h"
class DynamicPlugin : public Plugin {
protected:
typedef void (*VoidFunc)();
- typedef MetaEngine *(*MetaAllocFunc)();
+ typedef PluginObject *(*GetObjectFunc)();
virtual VoidFunc findSymbol(const char *symbol) = 0;
public:
virtual bool loadPlugin() {
- // Query the plugin's name
- MetaAllocFunc metaAlloc = (MetaAllocFunc)findSymbol("PLUGIN_MetaEngine_alloc");
- if (!metaAlloc) {
+ // Get the plugin's instantiator object
+ GetObjectFunc getObject = (GetObjectFunc)findSymbol("PLUGIN_getObject");
+ if (!getObject) {
unloadPlugin();
return false;
}
- _metaengine = metaAlloc();
- if (!_metaengine) {
+ // Get the plugin object
+ _pluginObject = getObject();
+ if (!_pluginObject) {
unloadPlugin();
return false;
}
@@ -56,7 +56,7 @@
}
virtual void unloadPlugin() {
- delete _metaengine;
+ delete _pluginObject;
}
};
Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp 2008-02-04 17:04:03 UTC (rev 30788)
+++ scummvm/trunk/base/plugins.cpp 2008-02-04 18:38:22 UTC (rev 30789)
@@ -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 @@
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.
Modified: scummvm/trunk/base/plugins.h
===================================================================
--- scummvm/trunk/base/plugins.h 2008-02-04 17:04:03 UTC (rev 30788)
+++ scummvm/trunk/base/plugins.h 2008-02-04 18:38:22 UTC (rev 30789)
@@ -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 Plugin {
protected:
- MetaEngine *_metaengine;
+ PluginObject *_pluginObject;
public:
- Plugin() : _metaengine(0) {}
+ Plugin() : _pluginObject(0) {}
virtual ~Plugin() {
//if (isLoaded())
//unloadPlugin();
@@ -81,16 +95,16 @@
*/
#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()
Modified: scummvm/trunk/engines/metaengine.h
===================================================================
--- scummvm/trunk/engines/metaengine.h 2008-02-04 17:04:03 UTC (rev 30788)
+++ scummvm/trunk/engines/metaengine.h 2008-02-04 18:38:22 UTC (rev 30789)
@@ -28,8 +28,10 @@
#include "common/scummsys.h"
#include "common/str.h"
#include "common/error.h"
+#include "common/fs.h"
#include "base/game.h"
+#include "base/plugins.h"
class Engine;
class OSystem;
@@ -42,13 +44,10 @@
* This is then in turn used by the frontend code to detect games,
* and instantiate actual Engine objects.
*/
-class MetaEngine {
+class MetaEngine : public PluginObject {
public:
virtual ~MetaEngine() {}
- /** Returns the name of the engine. */
- virtual const char *getName() const = 0;
-
/** Returns some copyright information about the engine. */
virtual const char *getCopyright() const = 0;
Modified: scummvm/trunk/plugin.exp
===================================================================
--- scummvm/trunk/plugin.exp 2008-02-04 17:04:03 UTC (rev 30788)
+++ scummvm/trunk/plugin.exp 2008-02-04 18:38:22 UTC (rev 30789)
@@ -1 +1 @@
-_PLUGIN_MetaEngine_alloc
+_PLUGIN_getObject
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list