aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2008-02-04 13:14:52 +0000
committerMax Horn2008-02-04 13:14:52 +0000
commit3cd1e60e7adb6ca8e25aaf8b66222c2fe7fb5fab (patch)
tree7722a14a6b22035ddcceac37bd72249a2c189764
parent5fb7f7a4d66c48be928440c3142b196a479ca94c (diff)
downloadscummvm-rg350-3cd1e60e7adb6ca8e25aaf8b66222c2fe7fb5fab.tar.gz
scummvm-rg350-3cd1e60e7adb6ca8e25aaf8b66222c2fe7fb5fab.tar.bz2
scummvm-rg350-3cd1e60e7adb6ca8e25aaf8b66222c2fe7fb5fab.zip
Moved common code from Plugin subclasses to class Plugin itself
svn-id: r30787
-rw-r--r--backends/plugins/dynamic-plugin.h33
-rw-r--r--base/plugins.cpp64
-rw-r--r--base/plugins.h30
3 files changed, 50 insertions, 77 deletions
diff --git a/backends/plugins/dynamic-plugin.h b/backends/plugins/dynamic-plugin.h
index 81d7fbc4c5..410e21c3a8 100644
--- a/backends/plugins/dynamic-plugin.h
+++ b/backends/plugins/dynamic-plugin.h
@@ -33,44 +33,11 @@
class DynamicPlugin : public Plugin {
protected:
typedef void (*VoidFunc)();
-
typedef MetaEngine *(*MetaAllocFunc)();
- MetaEngine *_metaengine;
-
virtual VoidFunc findSymbol(const char *symbol) = 0;
public:
- DynamicPlugin() : _metaengine(0) {}
-
- const char *getName() const {
- return _metaengine->getName();
- }
-
- const char *getCopyright() const {
- return _metaengine->getCopyright();
- }
-
- PluginError createInstance(OSystem *syst, Engine **engine) const {
- return _metaengine->createInstance(syst, engine);
- }
-
- GameList getSupportedGames() const {
- return _metaengine->getSupportedGames();
- }
-
- GameDescriptor findGame(const char *gameid) const {
- return _metaengine->findGame(gameid);
- }
-
- GameList detectGames(const FSList &fslist) const {
- return _metaengine->detectGames(fslist);
- }
-
- SaveStateList listSaves(const char *target) const {
- return _metaengine->listSaves(target);
- }
-
virtual bool loadPlugin() {
// Query the plugin's name
MetaAllocFunc metaAlloc = (MetaAllocFunc)findSymbol("PLUGIN_MetaEngine_alloc");
diff --git a/base/plugins.cpp b/base/plugins.cpp
index da6fe36826..4364cd0215 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -28,49 +28,49 @@
#include "engines/metaengine.h"
-#ifndef DYNAMIC_MODULES
-class StaticPlugin : public Plugin {
- MetaEngine *_metaengine;
-public:
- StaticPlugin(MetaEngine *metaengine)
- : _metaengine(metaengine) {
- assert(_metaengine);
- }
+const char *Plugin::getName() const {
+ return _metaengine->getName();
+}
- ~StaticPlugin() {
- delete _metaengine;
- }
+const char *Plugin::getCopyright() const {
+ return _metaengine->getCopyright();
+}
- virtual bool loadPlugin() { return true; }
- virtual void unloadPlugin() {}
+PluginError Plugin::createInstance(OSystem *syst, Engine **engine) const {
+ return _metaengine->createInstance(syst, engine);
+}
- const char *getName() const {
- return _metaengine->getName();
- }
+GameList Plugin::getSupportedGames() const {
+ return _metaengine->getSupportedGames();
+}
- const char *getCopyright() const {
- return _metaengine->getCopyright();
- }
+GameDescriptor Plugin::findGame(const char *gameid) const {
+ return _metaengine->findGame(gameid);
+}
- PluginError createInstance(OSystem *syst, Engine **engine) const {
- return _metaengine->createInstance(syst, engine);
- }
+GameList Plugin::detectGames(const FSList &fslist) const {
+ return _metaengine->detectGames(fslist);
+}
- GameList getSupportedGames() const {
- return _metaengine->getSupportedGames();
- }
+SaveStateList Plugin::listSaves(const char *target) const {
+ return _metaengine->listSaves(target);
+}
- GameDescriptor findGame(const char *gameid) const {
- return _metaengine->findGame(gameid);
- }
- GameList detectGames(const FSList &fslist) const {
- return _metaengine->detectGames(fslist);
+#ifndef DYNAMIC_MODULES
+class StaticPlugin : public Plugin {
+public:
+ StaticPlugin(MetaEngine *metaengine) {
+ assert(metaengine);
+ _metaengine = metaengine;
}
- SaveStateList listSaves(const char *target) const {
- return _metaengine->listSaves(target);
+ ~StaticPlugin() {
+ delete _metaengine;
}
+
+ virtual bool loadPlugin() { return true; }
+ virtual void unloadPlugin() {}
};
class StaticPluginProvider : public PluginProvider {
diff --git a/base/plugins.h b/base/plugins.h
index 9f8383f165..bc65a13644 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -44,24 +44,30 @@ class OSystem;
* plugins.
*/
class Plugin {
+protected:
+ MetaEngine *_metaengine;
+
public:
- virtual ~Plugin() {}
+ Plugin() : _metaengine(0) {}
+ virtual ~Plugin() {
+ //if (isLoaded())
+ //unloadPlugin();
+ }
// virtual bool isLoaded() const = 0; // TODO
- 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 bool loadPlugin() = 0; // TODO: Rename to load() ?
+ virtual void unloadPlugin() = 0; // TODO: Rename to unload() ?
- virtual GameList getSupportedGames() const = 0;
- virtual GameDescriptor findGame(const char *gameid) const = 0;
- virtual GameList detectGames(const FSList &fslist) const = 0;
+ const char *getName() const;
+ const char *getCopyright() const;
- virtual SaveStateList listSaves(const char *target) const = 0;
+// virtual int getVersion() const { return 0; } // TODO!
- virtual PluginError createInstance(OSystem *syst, Engine **engine) const = 0;
+ PluginError createInstance(OSystem *syst, Engine **engine) const;
+ GameList getSupportedGames() const;
+ GameDescriptor findGame(const char *gameid) const;
+ GameList detectGames(const FSList &fslist) const;
+ SaveStateList listSaves(const char *target) const;
};