[Scummvm-cvs-logs] SF.net SVN: scummvm: [26922] scummvm/trunk
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Tue May 22 16:17:45 CEST 2007
Revision: 26922
http://scummvm.svn.sourceforge.net/scummvm/?rev=26922&view=rev
Author: lordhoto
Date: 2007-05-22 07:17:44 -0700 (Tue, 22 May 2007)
Log Message:
-----------
Simpilified Singleton implementation and usage.
Modified Paths:
--------------
scummvm/trunk/base/plugins.cpp
scummvm/trunk/common/config-manager.cpp
scummvm/trunk/common/singleton.h
scummvm/trunk/graphics/cursorman.cpp
scummvm/trunk/graphics/fontman.cpp
scummvm/trunk/graphics/imageman.cpp
scummvm/trunk/gui/newgui.cpp
scummvm/trunk/sound/audiocd.cpp
Modified: scummvm/trunk/base/plugins.cpp
===================================================================
--- scummvm/trunk/base/plugins.cpp 2007-05-22 14:08:43 UTC (rev 26921)
+++ scummvm/trunk/base/plugins.cpp 2007-05-22 14:17:44 UTC (rev 26922)
@@ -139,8 +139,6 @@
#pragma mark -
-DECLARE_SINGLETON(PluginManager);
-
PluginManager::PluginManager() {
#ifndef DYNAMIC_MODULES
// Add the static plugin provider if we do not build with dynamic
Modified: scummvm/trunk/common/config-manager.cpp
===================================================================
--- scummvm/trunk/common/config-manager.cpp 2007-05-22 14:08:43 UTC (rev 26921)
+++ scummvm/trunk/common/config-manager.cpp 2007-05-22 14:17:44 UTC (rev 26922)
@@ -33,8 +33,6 @@
#include "common/file.h"
#include "common/util.h"
-DECLARE_SINGLETON(Common::ConfigManager);
-
#ifdef __PLAYSTATION2__
#include "backends/platform/ps2/systemps2.h"
#endif
Modified: scummvm/trunk/common/singleton.h
===================================================================
--- scummvm/trunk/common/singleton.h 2007-05-22 14:08:43 UTC (rev 26921)
+++ scummvm/trunk/common/singleton.h 2007-05-22 14:17:44 UTC (rev 26922)
@@ -37,8 +37,6 @@
Singleton<T>(const Singleton<T>&);
Singleton<T>& operator= (const Singleton<T>&);
- static T* _singleton;
-
/**
* The default object factory used by the template class Singleton.
* By specialising this template function, one can make a singleton use a
@@ -58,16 +56,13 @@
public:
static T& instance() {
- // TODO: We aren't thread safe. For now we ignore it since the
- // only thing using this singleton template is the config manager,
- // and that is first instantiated long before any threads.
+ // TODO: We aren't thread safe.
// TODO: We don't leak, but the destruction order is nevertheless
// semi-random. If we use multiple singletons, the destruction
// order might become an issue. There are various approaches
// to solve that problem, but for now this is sufficient
- if (!_singleton)
- _singleton = T::makeInstance();
- return *_singleton;
+ static T *instance = T::makeInstance();
+ return *instance;
}
protected:
Singleton<T>() { }
@@ -80,8 +75,6 @@
typedef T SingletonBaseType;
};
-#define DECLARE_SINGLETON(T) template<> T* Common::Singleton<T>::_singleton=0
-
} // End of namespace Common
#endif
Modified: scummvm/trunk/graphics/cursorman.cpp
===================================================================
--- scummvm/trunk/graphics/cursorman.cpp 2007-05-22 14:08:43 UTC (rev 26921)
+++ scummvm/trunk/graphics/cursorman.cpp 2007-05-22 14:17:44 UTC (rev 26922)
@@ -24,8 +24,6 @@
#include "common/system.h"
#include "common/stack.h"
-DECLARE_SINGLETON(Graphics::CursorManager);
-
namespace Graphics {
static bool g_initialized = false;
Modified: scummvm/trunk/graphics/fontman.cpp
===================================================================
--- scummvm/trunk/graphics/fontman.cpp 2007-05-22 14:08:43 UTC (rev 26921)
+++ scummvm/trunk/graphics/fontman.cpp 2007-05-22 14:17:44 UTC (rev 26922)
@@ -22,8 +22,6 @@
#include "graphics/fontman.h"
//#include "gui/consolefont.h"
-DECLARE_SINGLETON(Graphics::FontManager);
-
namespace Graphics {
#if !(defined(PALMOS_ARM) || defined(PALMOS_DEBUG) || defined(__GP32__))
Modified: scummvm/trunk/graphics/imageman.cpp
===================================================================
--- scummvm/trunk/graphics/imageman.cpp 2007-05-22 14:08:43 UTC (rev 26921)
+++ scummvm/trunk/graphics/imageman.cpp 2007-05-22 14:17:44 UTC (rev 26922)
@@ -23,14 +23,13 @@
#include "graphics/imageman.h"
#include "graphics/surface.h"
-DECLARE_SINGLETON(Graphics::ImageManager);
-
namespace Graphics {
ImageManager::ImageManager() : _surfaces()
#ifdef USE_ZLIB
, _archives()
#endif
{
+ debug("foo");
}
ImageManager::~ImageManager() {
Modified: scummvm/trunk/gui/newgui.cpp
===================================================================
--- scummvm/trunk/gui/newgui.cpp 2007-05-22 14:08:43 UTC (rev 26921)
+++ scummvm/trunk/gui/newgui.cpp 2007-05-22 14:17:44 UTC (rev 26922)
@@ -32,8 +32,6 @@
#include "common/config-manager.h"
-DECLARE_SINGLETON(GUI::NewGui);
-
namespace GUI {
/*
Modified: scummvm/trunk/sound/audiocd.cpp
===================================================================
--- scummvm/trunk/sound/audiocd.cpp 2007-05-22 14:08:43 UTC (rev 26921)
+++ scummvm/trunk/sound/audiocd.cpp 2007-05-22 14:17:44 UTC (rev 26922)
@@ -32,8 +32,6 @@
#include "common/util.h"
#include "common/system.h"
-DECLARE_SINGLETON(Audio::AudioCDManager);
-
namespace Audio {
AudioCDManager::AudioCDManager() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list