diff options
author | Max Horn | 2003-10-08 22:10:59 +0000 |
---|---|---|
committer | Max Horn | 2003-10-08 22:10:59 +0000 |
commit | 6e09d35090ab1fa600c5fe1e2f2006ffb0e9c131 (patch) | |
tree | c13a909e2c682464735c09ef81f4adbb923c6115 /base | |
parent | d1773647159f9ef1393d7a1d33204de5886edce5 (diff) | |
download | scummvm-rg350-6e09d35090ab1fa600c5fe1e2f2006ffb0e9c131.tar.gz scummvm-rg350-6e09d35090ab1fa600c5fe1e2f2006ffb0e9c131.tar.bz2 scummvm-rg350-6e09d35090ab1fa600c5fe1e2f2006ffb0e9c131.zip |
turned PluginManager into a proper singleton
svn-id: r10688
Diffstat (limited to 'base')
-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 |
4 files changed, 9 insertions, 18 deletions
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 |