turned PluginManager into a proper singleton

svn-id: r10688
This commit is contained in:
Max Horn 2003-10-08 22:10:59 +00:00
parent d177364715
commit 6e09d35090
6 changed files with 10 additions and 21 deletions

1
TODO
View File

@ -9,7 +9,6 @@ General
* fix the Map<> template, make it more robust; maybe use a red-black tree?
* add iterators to List<> template and make use of them
* allow for return-to-launcher instead of a normal "quit" ?
* turn g_pluginManager into a proper singleton
* improve the argv (command line args) parser
* extend the Plugin API to provide for "game detection": instead of the
TargetSettings::detectname "hack" to detect files, provide a callback

View File

@ -238,7 +238,7 @@ void GameDetector::list_games() {
// what this code does, but without the "Config" column.
// 2) List all available (configured) targets, including those with custom
// names, e.g. "monkey-mac", "skycd-demo", ...
const PluginList &plugins = g_pluginManager->getPlugins();
const PluginList &plugins = PluginManager::instance().getPlugins();
const TargetSettings *v;
printf("Game Full Title \n"
@ -262,7 +262,7 @@ void GameDetector::list_games() {
const TargetSettings *GameDetector::findTarget(const String &targetName, const Plugin **plugin) const {
// Find the TargetSettings for this target
const TargetSettings *target;
const PluginList &plugins = g_pluginManager->getPlugins();
const PluginList &plugins = PluginManager::instance().getPlugins();
PluginList::ConstIterator iter = plugins.begin();
for (iter = plugins.begin(); iter != plugins.end(); ++iter) {

View File

@ -237,8 +237,7 @@ int main(int argc, char *argv[]) {
ConfMan.set("versioninfo", gScummVMVersion, "scummvm");
// Load the plugins
g_pluginManager = new PluginManager();
g_pluginManager->loadPlugins();
PluginManager::instance().loadPlugins();
// Parse the command line information
GameDetector detector;

View File

@ -74,12 +74,6 @@ extern Engine *Engine_QUEEN_create(GameDetector *detector, OSystem *syst);
#pragma mark -
PluginManager *g_pluginManager = 0;
#pragma mark -
int Plugin::countTargets() const {
const TargetSettings *target = getTargets();
int count;

View File

@ -24,6 +24,7 @@
#define COMMON_PLUGINS_H
#include "common/list.h"
#include "common/singleton.h"
class Engine;
class GameDetector;
@ -84,25 +85,22 @@ typedef Common::List<Plugin *> PluginList;
*
* @todo Add support for dynamic plugins (this may need additional API, e.g. for a plugin path)
*/
class PluginManager {
protected:
using Common::Singleton;
class PluginManager : public Singleton<PluginManager> {
private:
PluginList _plugins;
bool tryLoadPlugin(Plugin *plugin);
public:
friend class Singleton<PluginManager>;
PluginManager();
~PluginManager();
public:
void loadPlugins();
void unloadPlugins();
const PluginList &getPlugins() { return _plugins; }
};
/**
* Global, shared plugin manager.
*/
extern PluginManager *g_pluginManager;
#endif

View File

@ -281,8 +281,7 @@ GameList findGame(FilesystemNode *dir) {
// Iterate over all known games and for each check if it might be
// the game in the presented directory.
assert(g_pluginManager);
const PluginList &plugins = g_pluginManager->getPlugins();
const PluginList &plugins = PluginManager::instance().getPlugins();
int p;
for (p = 0; p < plugins.size(); p++) {
const TargetSettings *v = plugins[p]->getTargets();