diff options
author | Eugene Sandulenko | 2017-07-10 21:17:41 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2017-07-10 21:17:41 +0200 |
commit | 940b2a20f1cd490afb6e541a3cd26f0d3bdd1687 (patch) | |
tree | ed080d2edfcc191e2edd4ad61cb8e778e660d422 /common | |
parent | c61c0cb0ff6edb53d2ff32efa559e76dd4d086ec (diff) | |
download | scummvm-rg350-940b2a20f1cd490afb6e541a3cd26f0d3bdd1687.tar.gz scummvm-rg350-940b2a20f1cd490afb6e541a3cd26f0d3bdd1687.tar.bz2 scummvm-rg350-940b2a20f1cd490afb6e541a3cd26f0d3bdd1687.zip |
Revert "COMMON: Change way the Singleton instances are instantiated"
This reverts commit eefa72afa1978a9dea10f5b1833fcc8f58a3468e.
With this patch ConfigManager is broken.
Diffstat (limited to 'common')
-rw-r--r-- | common/archive.cpp | 2 | ||||
-rw-r--r-- | common/config-manager.cpp | 2 | ||||
-rw-r--r-- | common/coroutines.cpp | 2 | ||||
-rw-r--r-- | common/debug.cpp | 2 | ||||
-rw-r--r-- | common/osd_message_queue.cpp | 2 | ||||
-rw-r--r-- | common/singleton.h | 9 | ||||
-rw-r--r-- | common/translation.cpp | 2 |
7 files changed, 20 insertions, 1 deletions
diff --git a/common/archive.cpp b/common/archive.cpp index 07d363a9a8..5a339900b6 100644 --- a/common/archive.cpp +++ b/common/archive.cpp @@ -284,4 +284,6 @@ void SearchManager::clear() { addDirectory(".", ".", -2); } +DECLARE_SINGLETON(SearchManager); + } // namespace Common diff --git a/common/config-manager.cpp b/common/config-manager.cpp index 91ba3c867b..fdd0c6f033 100644 --- a/common/config-manager.cpp +++ b/common/config-manager.cpp @@ -36,6 +36,8 @@ static bool isValidDomainName(const Common::String &domName) { namespace Common { +DECLARE_SINGLETON(ConfigManager); + char const *const ConfigManager::kApplicationDomain = "scummvm"; char const *const ConfigManager::kTransientDomain = "__TRANSIENT"; diff --git a/common/coroutines.cpp b/common/coroutines.cpp index 54e53ff7d3..248777febd 100644 --- a/common/coroutines.cpp +++ b/common/coroutines.cpp @@ -33,6 +33,8 @@ namespace Common { /** Helper null context instance */ CoroContext nullContext = NULL; +DECLARE_SINGLETON(CoroutineScheduler); + #ifdef COROUTINE_DEBUG namespace { /** Count of active coroutines */ diff --git a/common/debug.cpp b/common/debug.cpp index 94517afab6..5db8990db8 100644 --- a/common/debug.cpp +++ b/common/debug.cpp @@ -34,6 +34,8 @@ bool gDebugChannelsOnly = false; namespace Common { +DECLARE_SINGLETON(DebugManager); + namespace { struct DebugLevelComperator { diff --git a/common/osd_message_queue.cpp b/common/osd_message_queue.cpp index 3355295bbe..b8abf18bb5 100644 --- a/common/osd_message_queue.cpp +++ b/common/osd_message_queue.cpp @@ -24,6 +24,8 @@ #include "common/system.h" namespace Common { + +DECLARE_SINGLETON(OSDMessageQueue); OSDMessageQueue::OSDMessageQueue() : _lastUpdate(0) { } diff --git a/common/singleton.h b/common/singleton.h index 6c36d7a37d..9bcd590183 100644 --- a/common/singleton.h +++ b/common/singleton.h @@ -88,7 +88,14 @@ protected: static T *_singleton; }; -template<class T> T *Singleton<T>::_singleton = 0; +/** + * Note that you need to use this macro from the Common namespace. + * + * This is because C++ requires initial explicit specialization + * to be placed in the same namespace as the template. + */ +#define DECLARE_SINGLETON(T) \ + template<> T *Singleton<T>::_singleton = 0 } // End of namespace Common diff --git a/common/translation.cpp b/common/translation.cpp index 04df9d213d..01665bf876 100644 --- a/common/translation.cpp +++ b/common/translation.cpp @@ -40,6 +40,8 @@ namespace Common { +DECLARE_SINGLETON(TranslationManager); + bool operator<(const TLanguage &l, const TLanguage &r) { return strcmp(l.name, r.name) < 0; } |