[Scummvm-cvs-logs] CVS: scummvm/common config-manager.h,1.21,1.22 singleton.h,1.9,1.10 system.cpp,1.16,1.17 system.h,1.78,1.79
Max Horn
fingolfin at users.sourceforge.net
Thu Jan 6 10:39:34 CET 2005
Update of /cvsroot/scummvm/scummvm/common
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8186/common
Modified Files:
config-manager.h singleton.h system.cpp system.h
Log Message:
Modify the singleton code once more to help overcome an issue with MSVC 7 (see also patch #1095133)
Index: config-manager.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/config-manager.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- config-manager.h 1 Jan 2005 19:19:05 -0000 1.21
+++ config-manager.h 6 Jan 2005 18:38:33 -0000 1.22
@@ -114,7 +114,7 @@
*/
private:
- friend SingletonBaseType *makeInstance<>();
+ friend class Singleton<SingletonBaseType>;
ConfigManager();
void loadFile(const String &filename);
Index: singleton.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/singleton.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- singleton.h 1 Jan 2005 19:19:05 -0000 1.9
+++ singleton.h 6 Jan 2005 18:38:33 -0000 1.10
@@ -23,18 +23,6 @@
#ifndef COMMON_SINGLETON_H
#define COMMON_SINGLETON_H
-/**
- * The default object factory used by the template class Singleton.
- * By specialising this template function, one can make a singleton use a
- * custom object factory. For example, to support encapsulation, your
- * singleton class might be pure virtual (or "abstract" in Java terminology),
- * and you specialise makeInstance to return an instance of a subclass.
- */
-template <class T>
-T* makeInstance() {
- return new T();
-}
-
namespace Common {
/**
@@ -49,6 +37,19 @@
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
+ * custom object factory. For example, to support encapsulation, your
+ * singleton class might be pure virtual (or "abstract" in Java terminology),
+ * and you specialise makeInstance to return an instance of a subclass.
+ */
+ //template <class T>
+ static T* makeInstance() {
+ return new T();
+ }
+
+
public:
static T& instance() {
// TODO: We aren't thread safe. For now we ignore it since the
@@ -59,7 +60,7 @@
// order might become an issue. There are various approaches
// to solve that problem, but for now this is sufficient
if (!_singleton)
- _singleton = makeInstance<T>();
+ _singleton = makeInstance();
return *_singleton;
}
protected:
Index: system.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/system.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- system.cpp 1 Jan 2005 19:19:05 -0000 1.16
+++ system.cpp 6 Jan 2005 18:38:34 -0000 1.17
@@ -34,7 +34,7 @@
DECLARE_SINGLETON(OSystem);
template <>
-OSystem *makeInstance<>() {
+OSystem *Common::Singleton<OSystem>::makeInstance() {
// Attention: Do not call parseGraphicsMode() here, nor any other function
// which needs to access the OSystem instance, else you get stuck in an
// endless loop.
Index: system.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/system.h,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- system.h 1 Jan 2005 19:19:05 -0000 1.78
+++ system.h 6 Jan 2005 18:38:34 -0000 1.79
@@ -32,10 +32,10 @@
class OSystem;
/**
- * Custome object factory for OSystem.
+ * Custom object factory for OSystem.
*/
template <>
-OSystem *makeInstance<>();
+extern OSystem *Common::Singleton<OSystem>::makeInstance();
/**
More information about the Scummvm-git-logs
mailing list