mirror of
https://github.com/libretro/scummvm.git
synced 2024-11-27 11:20:40 +00:00
Moved common code from Plugin subclasses to class Plugin itself
svn-id: r30787
This commit is contained in:
parent
5fb7f7a4d6
commit
3cd1e60e7a
@ -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");
|
||||
|
@ -28,13 +28,41 @@
|
||||
#include "engines/metaengine.h"
|
||||
|
||||
|
||||
const char *Plugin::getName() const {
|
||||
return _metaengine->getName();
|
||||
}
|
||||
|
||||
const char *Plugin::getCopyright() const {
|
||||
return _metaengine->getCopyright();
|
||||
}
|
||||
|
||||
PluginError Plugin::createInstance(OSystem *syst, Engine **engine) const {
|
||||
return _metaengine->createInstance(syst, engine);
|
||||
}
|
||||
|
||||
GameList Plugin::getSupportedGames() const {
|
||||
return _metaengine->getSupportedGames();
|
||||
}
|
||||
|
||||
GameDescriptor Plugin::findGame(const char *gameid) const {
|
||||
return _metaengine->findGame(gameid);
|
||||
}
|
||||
|
||||
GameList Plugin::detectGames(const FSList &fslist) const {
|
||||
return _metaengine->detectGames(fslist);
|
||||
}
|
||||
|
||||
SaveStateList Plugin::listSaves(const char *target) const {
|
||||
return _metaengine->listSaves(target);
|
||||
}
|
||||
|
||||
|
||||
#ifndef DYNAMIC_MODULES
|
||||
class StaticPlugin : public Plugin {
|
||||
MetaEngine *_metaengine;
|
||||
public:
|
||||
StaticPlugin(MetaEngine *metaengine)
|
||||
: _metaengine(metaengine) {
|
||||
assert(_metaengine);
|
||||
StaticPlugin(MetaEngine *metaengine) {
|
||||
assert(metaengine);
|
||||
_metaengine = metaengine;
|
||||
}
|
||||
|
||||
~StaticPlugin() {
|
||||
@ -43,34 +71,6 @@ public:
|
||||
|
||||
virtual bool loadPlugin() { return true; }
|
||||
virtual void unloadPlugin() {}
|
||||
|
||||
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);
|
||||
}
|
||||
};
|
||||
|
||||
class StaticPluginProvider : public PluginProvider {
|
||||
|
@ -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 bool loadPlugin() = 0; // TODO: Rename to load() ?
|
||||
virtual void unloadPlugin() = 0; // TODO: Rename to unload() ?
|
||||
|
||||
const char *getName() const;
|
||||
const char *getCopyright() const;
|
||||
|
||||
virtual const char *getName() const = 0;
|
||||
virtual const char *getCopyright() const = 0;
|
||||
// virtual int getVersion() const { return 0; } // TODO!
|
||||
|
||||
virtual GameList getSupportedGames() const = 0;
|
||||
virtual GameDescriptor findGame(const char *gameid) const = 0;
|
||||
virtual GameList detectGames(const FSList &fslist) const = 0;
|
||||
|
||||
virtual SaveStateList listSaves(const char *target) const = 0;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user