diff options
-rw-r--r-- | TODO | 1 | ||||
-rw-r--r-- | base/gameDetector.cpp | 4 | ||||
-rw-r--r-- | base/main.cpp | 3 | ||||
-rw-r--r-- | base/plugins.cpp | 6 | ||||
-rw-r--r-- | base/plugins.h | 14 | ||||
-rw-r--r-- | gui/launcher.cpp | 3 |
6 files changed, 10 insertions, 21 deletions
@@ -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 diff --git a/base/gameDetector.cpp b/base/gameDetector.cpp index 36ee551b89..30e204e108 100644 --- a/base/gameDetector.cpp +++ b/base/gameDetector.cpp @@ -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) { diff --git a/base/main.cpp b/base/main.cpp index 1ebd405899..2ca7a9966d 100644 --- a/base/main.cpp +++ b/base/main.cpp @@ -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; diff --git a/base/plugins.cpp b/base/plugins.cpp index 04d1460ec2..45ffec8d7f 100644 --- a/base/plugins.cpp +++ b/base/plugins.cpp @@ -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; diff --git a/base/plugins.h b/base/plugins.h index a463861c7b..3e989f66b4 100644 --- a/base/plugins.h +++ b/base/plugins.h @@ -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 diff --git a/gui/launcher.cpp b/gui/launcher.cpp index 743e37bb09..2520028d43 100644 --- a/gui/launcher.cpp +++ b/gui/launcher.cpp @@ -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(); |