aboutsummaryrefslogtreecommitdiff
path: root/base/plugins.h
diff options
context:
space:
mode:
authorMax Horn2003-09-18 18:23:53 +0000
committerMax Horn2003-09-18 18:23:53 +0000
commit6a4663824e573777c512e0ca21a5c5f61865b83c (patch)
tree78061db44cc3d3731decd51a84865225dd53840f /base/plugins.h
parent209413ed07e931277cf569d260fbfad71406088e (diff)
downloadscummvm-rg350-6a4663824e573777c512e0ca21a5c5f61865b83c.tar.gz
scummvm-rg350-6a4663824e573777c512e0ca21a5c5f61865b83c.tar.bz2
scummvm-rg350-6a4663824e573777c512e0ca21a5c5f61865b83c.zip
added initial support for building our 4 adventure engines as loadable modules; right now only work on OS X; once we add more build rules, other systems with dlopen() should work, too (e.g. Linux); Windows support may come later. This is still very much WIP
svn-id: r10304
Diffstat (limited to 'base/plugins.h')
-rw-r--r--base/plugins.h29
1 files changed, 27 insertions, 2 deletions
diff --git a/base/plugins.h b/base/plugins.h
index 8257bf1a53..d79ff0c5d9 100644
--- a/base/plugins.h
+++ b/base/plugins.h
@@ -37,11 +37,13 @@ struct TargetSettings;
*/
class Plugin {
public:
- virtual void loadPlugin() {}
+ virtual ~Plugin() {}
+
+ virtual bool loadPlugin() { return true; }
virtual void unloadPlugin() {}
virtual const char *getName() const = 0;
- virtual int getVersion() const = 0;
+ virtual int getVersion() const { return 0; } // TODO!
virtual int countTargets() const;
virtual const TargetSettings *getTargets() const = 0;
@@ -51,6 +53,27 @@ public:
};
+/**
+ * The REGISTER_PLUGIN is a convenience macro meant to ease writing
+ * the plugin interface for our modules. In particular, using it
+ * makes it possible to compile the very same code in a module
+ * both as a static and a dynamic plugin.
+ *
+ * @todo add some means to query the plugin API version etc.
+ * @todo on Windows, we might need __declspec(dllexport) ?
+ */
+#ifndef DYNAMIC_MODULES
+#define REGISTER_PLUGIN(name,targetListFactory,engineFactory)
+#else
+#define REGISTER_PLUGIN(name,targetListFactory,engineFactory) \
+ extern "C" { \
+ const char *PLUGIN_name() { return name; } \
+ const TargetSettings *PLUGIN_getTargetList() { return targetListFactory(); } \
+ Engine *PLUGIN_createEngine(GameDetector *detector, OSystem *syst) { return engineFactory(detector, syst); } \
+ }
+#endif
+
+
/** List of plugins. */
typedef ScummVM::List<Plugin *> PluginList;
@@ -65,6 +88,8 @@ class PluginManager {
protected:
PluginList _plugins;
+ bool tryLoadPlugin(Plugin *plugin);
+
public:
PluginManager();
~PluginManager();