diff options
author | Max Horn | 2008-02-02 00:54:52 +0000 |
---|---|---|
committer | Max Horn | 2008-02-02 00:54:52 +0000 |
commit | dc979b03cf915ab10a6cf76bdb22f1f95b12612e (patch) | |
tree | 15a50ca3f6991733dcbe1dcaed63ee1f17f8e6ed /common | |
parent | 249877fa82e6af59e6084bb3fa92cda49fb281aa (diff) | |
download | scummvm-rg350-dc979b03cf915ab10a6cf76bdb22f1f95b12612e.tar.gz scummvm-rg350-dc979b03cf915ab10a6cf76bdb22f1f95b12612e.tar.bz2 scummvm-rg350-dc979b03cf915ab10a6cf76bdb22f1f95b12612e.zip |
New MetaEngine class (work in progress to replace the current Engine plugin API with a more object oriented approach)
svn-id: r30726
Diffstat (limited to 'common')
-rw-r--r-- | common/advancedDetector.h | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/common/advancedDetector.h b/common/advancedDetector.h index f0d6c88e4e..171673771c 100644 --- a/common/advancedDetector.h +++ b/common/advancedDetector.h @@ -26,10 +26,11 @@ #define COMMON_ADVANCED_DETECTOR_H #include "common/fs.h" +#include "common/error.h" #include "base/game.h" // For PlainGameDescriptor and GameList -#include "base/plugins.h" // For PluginError +#include "engines/metaengine.h" namespace Common { @@ -273,4 +274,41 @@ void reportUnknown(StringList &files, int md5Bytes); } // End of namespace Common +/** + * A MetaEngine implementation based around the advanced detector code. + */ +class AdvancedMetaEngine : public MetaEngine { + const Common::ADParams ¶ms; +public: + AdvancedMetaEngine(const Common::ADParams &dp) : params(dp) {} + + // To be provided by subclasses + virtual bool createInstance(OSystem *syst, Engine **engine, const Common::EncapsulatedADGameDesc &encapsulatedDesc) const = 0; + + +protected: + virtual GameList getSupportedGames() const { + return Common::AdvancedDetector::gameIDList(params); + } + virtual GameDescriptor findGame(const char *gameid) const { + return Common::AdvancedDetector::findGameID(gameid, params.list, params.obsoleteList); + } + virtual GameList detectGames(const FSList &fslist) const { + return Common::AdvancedDetector::detectAllGames(fslist, params); + } + + virtual PluginError createInstance(OSystem *syst, Engine **engine) const { + assert(engine); + Common::AdvancedDetector::upgradeTargetIfNecessary(params); + Common::EncapsulatedADGameDesc encapsulatedDesc = Common::AdvancedDetector::detectBestMatchingGame(params); + if (encapsulatedDesc.realDesc == 0) { + return kNoGameDataFoundError; + } + if (!createInstance(syst,engine,encapsulatedDesc)) { + return kNoGameDataFoundError; + } + return kNoError; + } +}; + #endif |