[Scummvm-git-logs] scummvm master -> 940b2a20f1cd490afb6e541a3cd26f0d3bdd1687

sev- sev at scummvm.org
Mon Jul 10 21:18:07 CEST 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
940b2a20f1 Revert "COMMON: Change way the Singleton instances are instantiated"


Commit: 940b2a20f1cd490afb6e541a3cd26f0d3bdd1687
    https://github.com/scummvm/scummvm/commit/940b2a20f1cd490afb6e541a3cd26f0d3bdd1687
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2017-07-10T21:17:41+02:00

Commit Message:
Revert "COMMON: Change way the Singleton instances are instantiated"

This reverts commit eefa72afa1978a9dea10f5b1833fcc8f58a3468e.

With this patch ConfigManager is broken.

Changed paths:
    backends/cloud/cloudmanager.cpp
    backends/fs/ds/ds-fs-factory.cpp
    backends/fs/ps2/ps2-fs-factory.cpp
    backends/fs/psp/psp-fs-factory.cpp
    backends/fs/wii/wii-fs-factory.cpp
    backends/graphics/opengl/shader.cpp
    backends/networking/curl/connectionmanager.cpp
    backends/networking/sdl_net/localwebserver.cpp
    backends/platform/psp/display_manager.cpp
    backends/platform/psp/powerman.cpp
    backends/platform/psp/rtc.cpp
    backends/plugins/elf/memory-manager.cpp
    backends/plugins/elf/shorts-segment-manager.cpp
    base/plugins.cpp
    common/archive.cpp
    common/config-manager.cpp
    common/coroutines.cpp
    common/debug.cpp
    common/osd_message_queue.cpp
    common/singleton.h
    common/translation.cpp
    engines/engine.cpp
    engines/lure/sound.cpp
    engines/pegasus/gamestate.cpp
    engines/pegasus/input.cpp
    engines/sword25/gfx/animationtemplateregistry.cpp
    engines/sword25/math/regionregistry.cpp
    engines/sword25/sword25.cpp
    engines/testbed/config-params.cpp
    engines/wintermute/base/base_engine.cpp
    graphics/cursorman.cpp
    graphics/fontman.cpp
    graphics/fonts/ttf.cpp
    graphics/yuv_to_rgb.cpp
    gui/EventRecorder.cpp
    gui/gui-manager.cpp


diff --git a/backends/cloud/cloudmanager.cpp b/backends/cloud/cloudmanager.cpp
index 5499268..5519e4b 100644
--- a/backends/cloud/cloudmanager.cpp
+++ b/backends/cloud/cloudmanager.cpp
@@ -32,6 +32,11 @@
 #include "backends/networking/sdl_net/localwebserver.h"
 #endif
 
+namespace Common {
+
+DECLARE_SINGLETON(Cloud::CloudManager);
+
+}
 
 namespace Cloud {
 
diff --git a/backends/fs/ds/ds-fs-factory.cpp b/backends/fs/ds/ds-fs-factory.cpp
index e99033e..98c522f 100644
--- a/backends/fs/ds/ds-fs-factory.cpp
+++ b/backends/fs/ds/ds-fs-factory.cpp
@@ -28,6 +28,9 @@
 #include "backends/fs/ds/ds-fs.h"
 #include "dsmain.h" //for the isGBAMPAvailable() function
 
+namespace Common {
+DECLARE_SINGLETON(DSFilesystemFactory);
+}
 
 AbstractFSNode *DSFilesystemFactory::makeRootFileNode() const {
 	if (DS::isGBAMPAvailable()) {
diff --git a/backends/fs/ps2/ps2-fs-factory.cpp b/backends/fs/ps2/ps2-fs-factory.cpp
index 93525eb..9c12d27 100644
--- a/backends/fs/ps2/ps2-fs-factory.cpp
+++ b/backends/fs/ps2/ps2-fs-factory.cpp
@@ -28,6 +28,10 @@
 #include "backends/fs/ps2/ps2-fs-factory.h"
 #include "backends/fs/ps2/ps2-fs.h"
 
+namespace Common {
+DECLARE_SINGLETON(Ps2FilesystemFactory);
+}
+
 AbstractFSNode *Ps2FilesystemFactory::makeRootFileNode() const {
 	return new Ps2FilesystemNode();
 }
diff --git a/backends/fs/psp/psp-fs-factory.cpp b/backends/fs/psp/psp-fs-factory.cpp
index fa92bf4..303ea24 100644
--- a/backends/fs/psp/psp-fs-factory.cpp
+++ b/backends/fs/psp/psp-fs-factory.cpp
@@ -44,6 +44,10 @@
 
 #include <unistd.h>
 
+namespace Common {
+DECLARE_SINGLETON(PSPFilesystemFactory);
+}
+
 AbstractFSNode *PSPFilesystemFactory::makeRootFileNode() const {
 	return new PSPFilesystemNode();
 }
diff --git a/backends/fs/wii/wii-fs-factory.cpp b/backends/fs/wii/wii-fs-factory.cpp
index 1c95e4e..f234c1e 100644
--- a/backends/fs/wii/wii-fs-factory.cpp
+++ b/backends/fs/wii/wii-fs-factory.cpp
@@ -43,6 +43,10 @@
 #include <smb.h>
 #endif
 
+namespace Common {
+DECLARE_SINGLETON(WiiFilesystemFactory);
+}
+
 WiiFilesystemFactory::WiiFilesystemFactory() :
 	_dvdMounted(false),
 	_smbMounted(false),
diff --git a/backends/graphics/opengl/shader.cpp b/backends/graphics/opengl/shader.cpp
index b405f3d..0b4c677 100644
--- a/backends/graphics/opengl/shader.cpp
+++ b/backends/graphics/opengl/shader.cpp
@@ -27,6 +27,10 @@
 #include "common/textconsole.h"
 #include "common/util.h"
 
+namespace Common {
+DECLARE_SINGLETON(OpenGL::ShaderManager);
+}
+
 namespace OpenGL {
 
 namespace {
diff --git a/backends/networking/curl/connectionmanager.cpp b/backends/networking/curl/connectionmanager.cpp
index dee4ece..d8662ab 100644
--- a/backends/networking/curl/connectionmanager.cpp
+++ b/backends/networking/curl/connectionmanager.cpp
@@ -29,6 +29,12 @@
 #include "common/timer.h"
 #include <curl/curl.h>
 
+namespace Common {
+
+DECLARE_SINGLETON(Networking::ConnectionManager);
+
+}
+
 namespace Networking {
 
 ConnectionManager::ConnectionManager(): _multi(0), _timerStarted(false), _frame(0) {
diff --git a/backends/networking/sdl_net/localwebserver.cpp b/backends/networking/sdl_net/localwebserver.cpp
index 558bffe..836b90a 100644
--- a/backends/networking/sdl_net/localwebserver.cpp
+++ b/backends/networking/sdl_net/localwebserver.cpp
@@ -51,6 +51,9 @@
 
 namespace Common {
 class MemoryReadWriteStream;
+
+DECLARE_SINGLETON(Networking::LocalWebserver);
+
 }
 
 namespace Networking {
diff --git a/backends/platform/psp/display_manager.cpp b/backends/platform/psp/display_manager.cpp
index ffd3741..2e995c8 100644
--- a/backends/platform/psp/display_manager.cpp
+++ b/backends/platform/psp/display_manager.cpp
@@ -62,6 +62,10 @@ const OSystem::GraphicsMode DisplayManager::_supportedModes[] = {
 
 // Class VramAllocator -----------------------------------
 
+namespace Common {
+DECLARE_SINGLETON(VramAllocator);
+}
+
 //#define __PSP_DEBUG_FUNCS__	/* For debugging the stack */
 //#define __PSP_DEBUG_PRINT__
 
diff --git a/backends/platform/psp/powerman.cpp b/backends/platform/psp/powerman.cpp
index 4b415ef..3cd663e 100644
--- a/backends/platform/psp/powerman.cpp
+++ b/backends/platform/psp/powerman.cpp
@@ -30,6 +30,10 @@
 //#define __PSP_DEBUG_PRINT__
 #include "backends/platform/psp/trace.h"
 
+namespace Common {
+DECLARE_SINGLETON(PowerManager);
+}
+
 // Function to debug the Power Manager (we have no output to screen)
 inline void PowerManager::debugPM() {
 	PSP_DEBUG_PRINT("PM status[%d]. Listcount[%d]. CriticalCount[%d]. ThreadId[%x]. Error[%d]\n",
diff --git a/backends/platform/psp/rtc.cpp b/backends/platform/psp/rtc.cpp
index 67ad36c..d01bd8f 100644
--- a/backends/platform/psp/rtc.cpp
+++ b/backends/platform/psp/rtc.cpp
@@ -34,6 +34,9 @@
 
 
 // Class PspRtc ---------------------------------------------------------------
+namespace Common {
+DECLARE_SINGLETON(PspRtc);
+}
 
 void PspRtc::init() {						// init our starting ticks
 	uint32 ticks[2];
diff --git a/backends/plugins/elf/memory-manager.cpp b/backends/plugins/elf/memory-manager.cpp
index 7be7943..5014718 100644
--- a/backends/plugins/elf/memory-manager.cpp
+++ b/backends/plugins/elf/memory-manager.cpp
@@ -29,6 +29,10 @@
 #include "common/util.h"
 #include <malloc.h>
 
+namespace Common {
+DECLARE_SINGLETON(ELFMemoryManager);
+}
+
 ELFMemoryManager::ELFMemoryManager() :
 	_heap(0), _heapSize(0), _heapAlign(0),
 	_trackAllocs(false), _measuredSize(0), _measuredAlign(0),
diff --git a/backends/plugins/elf/shorts-segment-manager.cpp b/backends/plugins/elf/shorts-segment-manager.cpp
index 2af6c10..4fa03cc 100644
--- a/backends/plugins/elf/shorts-segment-manager.cpp
+++ b/backends/plugins/elf/shorts-segment-manager.cpp
@@ -33,6 +33,10 @@ extern char __plugin_hole_start;	// Indicates start of hole in program file for
 extern char __plugin_hole_end;		// Indicates end of hole in program file
 extern char _gp[];					// Value of gp register
 
+namespace Common {
+DECLARE_SINGLETON(ShortSegmentManager);	// For singleton
+}
+
 ShortSegmentManager::ShortSegmentManager() {
 	_shortsStart = &__plugin_hole_start ;	//shorts segment begins at the plugin hole we made when linking
 	_shortsEnd = &__plugin_hole_end;		//and ends at the end of that hole.
diff --git a/base/plugins.cpp b/base/plugins.cpp
index 2414102..39aaf2f 100644
--- a/base/plugins.cpp
+++ b/base/plugins.cpp
@@ -446,6 +446,10 @@ void PluginManager::addToPluginsInMemList(Plugin *plugin) {
 
 #include "engines/metaengine.h"
 
+namespace Common {
+DECLARE_SINGLETON(EngineManager);
+}
+
 /**
  * This function works for both cached and uncached PluginManagers.
  * For the cached version, most of the logic here will short circuit.
@@ -535,6 +539,10 @@ const EnginePlugin::List &EngineManager::getPlugins() const {
 
 #include "audio/musicplugin.h"
 
+namespace Common {
+DECLARE_SINGLETON(MusicManager);
+}
+
 const MusicPlugin::List &MusicManager::getPlugins() const {
 	return (const MusicPlugin::List &)PluginManager::instance().getPlugins(PLUGIN_TYPE_MUSIC);
 }
diff --git a/common/archive.cpp b/common/archive.cpp
index 07d363a..5a33990 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 91ba3c8..fdd0c6f 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 54e53ff..248777f 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 94517af..5db8990 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 3355295..b8abf18 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 6c36d7a..9bcd590 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 04df9d2..01665bf 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;
 }
diff --git a/engines/engine.cpp b/engines/engine.cpp
index 2edb77b..bb51e77 100644
--- a/engines/engine.cpp
+++ b/engines/engine.cpp
@@ -133,6 +133,10 @@ bool ChainedGamesManager::pop(Common::String &target, int &slot) {
 	return true;
 }
 
+namespace Common {
+DECLARE_SINGLETON(ChainedGamesManager);
+}
+
 Engine::Engine(OSystem *syst)
 	: _system(syst),
 		_mixer(_system->getMixer()),
diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp
index 4cb6c44..bea0dbf 100644
--- a/engines/lure/sound.cpp
+++ b/engines/lure/sound.cpp
@@ -31,6 +31,10 @@
 #include "common/endian.h"
 #include "audio/midiparser.h"
 
+namespace Common {
+DECLARE_SINGLETON(Lure::SoundManager);
+}
+
 namespace Lure {
 
 //#define SOUND_CROP_CHANNELS
diff --git a/engines/pegasus/gamestate.cpp b/engines/pegasus/gamestate.cpp
index 877aeff..dfb4f1c 100644
--- a/engines/pegasus/gamestate.cpp
+++ b/engines/pegasus/gamestate.cpp
@@ -30,6 +30,10 @@
 #include "pegasus/gamestate.h"
 #include "pegasus/scoring.h"
 
+namespace Common {
+DECLARE_SINGLETON(Pegasus::GameStateManager);
+}
+
 namespace Pegasus {
 
 Common::Error GameStateManager::writeGameState(Common::WriteStream *stream) {
diff --git a/engines/pegasus/input.cpp b/engines/pegasus/input.cpp
index 0a29a43..f483403 100644
--- a/engines/pegasus/input.cpp
+++ b/engines/pegasus/input.cpp
@@ -30,6 +30,10 @@
 #include "pegasus/input.h"
 #include "pegasus/pegasus.h"
 
+namespace Common {
+DECLARE_SINGLETON(Pegasus::InputDeviceManager);
+}
+
 namespace Pegasus {
 
 InputDeviceManager::InputDeviceManager() {
diff --git a/engines/sword25/gfx/animationtemplateregistry.cpp b/engines/sword25/gfx/animationtemplateregistry.cpp
index 875483d..4783a31 100644
--- a/engines/sword25/gfx/animationtemplateregistry.cpp
+++ b/engines/sword25/gfx/animationtemplateregistry.cpp
@@ -34,6 +34,10 @@
 #include "sword25/gfx/animationtemplateregistry.h"
 #include "sword25/gfx/animationtemplate.h"
 
+namespace Common {
+DECLARE_SINGLETON(Sword25::AnimationTemplateRegistry);
+}
+
 namespace Sword25 {
 
 bool AnimationTemplateRegistry::persist(OutputPersistenceBlock &writer) {
diff --git a/engines/sword25/math/regionregistry.cpp b/engines/sword25/math/regionregistry.cpp
index bfa82bc..35a5fb4 100644
--- a/engines/sword25/math/regionregistry.cpp
+++ b/engines/sword25/math/regionregistry.cpp
@@ -34,6 +34,10 @@
 #include "sword25/math/regionregistry.h"
 #include "sword25/math/region.h"
 
+namespace Common {
+DECLARE_SINGLETON(Sword25::RegionRegistry);
+}
+
 namespace Sword25 {
 
 bool RegionRegistry::persist(OutputPersistenceBlock &writer) {
diff --git a/engines/sword25/sword25.cpp b/engines/sword25/sword25.cpp
index 1e3a688..b6f2641 100644
--- a/engines/sword25/sword25.cpp
+++ b/engines/sword25/sword25.cpp
@@ -50,6 +50,9 @@
 
 #include "sword25/gfx/animationtemplateregistry.h"	// Needed so we can destroy the singleton
 #include "sword25/gfx/renderobjectregistry.h"		// Needed so we can destroy the singleton
+namespace Common {
+DECLARE_SINGLETON(Sword25::RenderObjectRegistry);
+}
 #include "sword25/math/regionregistry.h"			// Needed so we can destroy the singleton
 
 namespace Sword25 {
diff --git a/engines/testbed/config-params.cpp b/engines/testbed/config-params.cpp
index 3ec47fb..1aa9716 100644
--- a/engines/testbed/config-params.cpp
+++ b/engines/testbed/config-params.cpp
@@ -25,6 +25,10 @@
 
 #include "testbed/config-params.h"
 
+namespace Common {
+DECLARE_SINGLETON(Testbed::ConfigParams);
+}
+
 namespace Testbed {
 
 ConfigParams::ConfigParams() {
diff --git a/engines/wintermute/base/base_engine.cpp b/engines/wintermute/base/base_engine.cpp
index 28bdb53..4ce334a 100644
--- a/engines/wintermute/base/base_engine.cpp
+++ b/engines/wintermute/base/base_engine.cpp
@@ -32,6 +32,9 @@
 #include "engines/wintermute/wintermute.h"
 #include "engines/wintermute/system/sys_class_registry.h"
 #include "common/system.h"
+namespace Common {
+DECLARE_SINGLETON(Wintermute::BaseEngine);
+}
 
 namespace Wintermute {
 
diff --git a/graphics/cursorman.cpp b/graphics/cursorman.cpp
index 53e13da..5fcd2a3 100644
--- a/graphics/cursorman.cpp
+++ b/graphics/cursorman.cpp
@@ -25,6 +25,10 @@
 #include "common/system.h"
 #include "common/stack.h"
 
+namespace Common {
+DECLARE_SINGLETON(Graphics::CursorManager);
+}
+
 namespace Graphics {
 
 CursorManager::~CursorManager() {
diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp
index bb3ee03..5cf5241 100644
--- a/graphics/fontman.cpp
+++ b/graphics/fontman.cpp
@@ -26,6 +26,10 @@
 
 #include "common/translation.h"
 
+namespace Common {
+DECLARE_SINGLETON(Graphics::FontManager);
+}
+
 namespace Graphics {
 
 FORWARD_DECLARE_FONT(g_sysfont);
diff --git a/graphics/fonts/ttf.cpp b/graphics/fonts/ttf.cpp
index cb9520b..76b7f73 100644
--- a/graphics/fonts/ttf.cpp
+++ b/graphics/fonts/ttf.cpp
@@ -668,5 +668,9 @@ Font *loadTTFFont(Common::SeekableReadStream &stream, int size, TTFSizeMode size
 
 } // End of namespace Graphics
 
+namespace Common {
+DECLARE_SINGLETON(Graphics::TTFLibrary);
+} // End of namespace Common
+
 #endif
 
diff --git a/graphics/yuv_to_rgb.cpp b/graphics/yuv_to_rgb.cpp
index 99cd208..2a485fa 100644
--- a/graphics/yuv_to_rgb.cpp
+++ b/graphics/yuv_to_rgb.cpp
@@ -86,6 +86,10 @@
 #include "graphics/surface.h"
 #include "graphics/yuv_to_rgb.h"
 
+namespace Common {
+DECLARE_SINGLETON(Graphics::YUVToRGBManager);
+}
+
 namespace Graphics {
 
 class YUVToRGBLookup {
diff --git a/gui/EventRecorder.cpp b/gui/EventRecorder.cpp
index ccf051f..3f91cfa 100644
--- a/gui/EventRecorder.cpp
+++ b/gui/EventRecorder.cpp
@@ -25,6 +25,10 @@
 
 #ifdef ENABLE_EVENTRECORDER
 
+namespace Common {
+DECLARE_SINGLETON(GUI::EventRecorder);
+}
+
 #include "common/debug-channels.h"
 #include "backends/timer/sdl/sdl-timer.h"
 #include "backends/mixer/sdl/sdl-mixer.h"
diff --git a/gui/gui-manager.cpp b/gui/gui-manager.cpp
index 12a0320..76f5577 100644
--- a/gui/gui-manager.cpp
+++ b/gui/gui-manager.cpp
@@ -41,6 +41,10 @@
 
 #include "graphics/cursorman.h"
 
+namespace Common {
+DECLARE_SINGLETON(GUI::GuiManager);
+}
+
 namespace GUI {
 
 enum {





More information about the Scummvm-git-logs mailing list