aboutsummaryrefslogtreecommitdiff
path: root/base/plugins.h
diff options
context:
space:
mode:
authorMax Horn2006-04-29 00:27:20 +0000
committerMax Horn2006-04-29 00:27:20 +0000
commitbf7359881115a5b041028b032ee28430bc5e36d3 (patch)
tree78c955620bb16d4b4e39f3b887eed35dd552c57b /base/plugins.h
parentb00262a2fe1b8bf1d51794a9da3e735e97dfb5ee (diff)
downloadscummvm-rg350-bf7359881115a5b041028b032ee28430bc5e36d3.tar.gz
scummvm-rg350-bf7359881115a5b041028b032ee28430bc5e36d3.tar.bz2
scummvm-rg350-bf7359881115a5b041028b032ee28430bc5e36d3.zip
* Changed the createEngine() factory function of our plugins to return an error code (the engine is now passed indirectly via a double pointer)
* Removed Engine_Empty (obsolete now that engines can return actual error codes) svn-id: r22199
Diffstat (limited to 'base/plugins.h')
-rw-r--r--base/plugins.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/base/plugins.h b/base/plugins.h
index f0318a8008..b0178f3e89 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -66,6 +66,20 @@ typedef Common::Array<DetectedGame> DetectedGameList;
/**
+ * Error codes which mayb be reported by plugins under various circumstances.
+ * @todo Turn this into a global 'ErrorCode' enum used by all of ScummVM ?
+ */
+enum PluginError {
+ kNoError = 0, // No error occured
+ kInvalidPathError,
+ kNoGameDataFoundError,
+ kUnsupportedGameidError,
+
+ kUnknownError // Catch-all error, used if no other error code matches
+};
+
+
+/**
* Abstract base class for the plugin system.
* Subclasses for this can be used to wrap both static and dynamic
* plugins.
@@ -84,7 +98,7 @@ public:
virtual GameDescriptor findGame(const char *gameid) const = 0;
virtual DetectedGameList detectGames(const FSList &fslist) const = 0;
- virtual Engine *createInstance(OSystem *syst) const = 0;
+ virtual PluginError createInstance(OSystem *syst, Engine **engine) const = 0;
};
@@ -106,7 +120,7 @@ public:
* - DetectedGameList Engine_##ID##_detectGames(const FSList &fslist)
* -> scans through the given file list (usually the contents of a directory),
* and attempts to detects games present in that location.
- * - Engine *Engine_##ID##_create(OSystem *syst)
+ * - PluginError Engine_##ID##_create(OSystem *syst, Engine **engine)
* -> factory function, create an instance of the Engine class.
*
* @todo add some means to query the plugin API version etc.
@@ -130,7 +144,7 @@ public:
PLUGIN_EXPORT const char *PLUGIN_name() { return name; } \
PLUGIN_EXPORT GameList PLUGIN_gameIDList() { return Engine_##ID##_gameIDList(); } \
PLUGIN_EXPORT GameDescriptor PLUGIN_findGameID(const char *gameid) { return Engine_##ID##_findGameID(gameid); } \
- PLUGIN_EXPORT Engine *PLUGIN_createEngine(OSystem *syst) { return Engine_##ID##_create(syst); } \
+ PLUGIN_EXPORT PluginError PLUGIN_createEngine(OSystem *syst, Engine **engine) { return Engine_##ID##_create(syst, engine); } \
PLUGIN_EXPORT DetectedGameList PLUGIN_detectGames(const FSList &fslist) { return Engine_##ID##_detectGames(fslist); } \
} \
void dummyFuncToAllowTrailingSemicolon()
@@ -145,7 +159,7 @@ class PluginRegistrator {
friend class StaticPlugin;
public:
typedef GameDescriptor (*GameIDQueryFunc)(const char *gameid);
- typedef Engine *(*EngineFactory)(OSystem *syst);
+ typedef PluginError (*EngineFactory)(OSystem *syst, Engine **engine);
typedef DetectedGameList (*DetectFunc)(const FSList &fslist);
protected: