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
This commit is contained in:
Max Horn 2003-09-18 18:23:53 +00:00
parent 209413ed07
commit 6a4663824e
7 changed files with 244 additions and 54 deletions

View file

@ -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();