[Scummvm-cvs-logs] SF.net SVN: scummvm:[53431] scummvm/trunk/engines/sword25
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Oct 13 17:41:34 CEST 2010
Revision: 53431
http://scummvm.svn.sourceforge.net/scummvm/?rev=53431&view=rev
Author: fingolfin
Date: 2010-10-13 15:41:34 +0000 (Wed, 13 Oct 2010)
Log Message:
-----------
SWORD25: Convert object registries to singletons
Modified Paths:
--------------
scummvm/trunk/engines/sword25/gfx/animationtemplateregistry.cpp
scummvm/trunk/engines/sword25/gfx/animationtemplateregistry.h
scummvm/trunk/engines/sword25/gfx/graphicengine.h
scummvm/trunk/engines/sword25/gfx/renderobjectregistry.cpp
scummvm/trunk/engines/sword25/gfx/renderobjectregistry.h
scummvm/trunk/engines/sword25/math/regionregistry.cpp
scummvm/trunk/engines/sword25/math/regionregistry.h
Modified: scummvm/trunk/engines/sword25/gfx/animationtemplateregistry.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/animationtemplateregistry.cpp 2010-10-13 15:41:00 UTC (rev 53430)
+++ scummvm/trunk/engines/sword25/gfx/animationtemplateregistry.cpp 2010-10-13 15:41:34 UTC (rev 53431)
@@ -39,10 +39,13 @@
#include "sword25/gfx/animationtemplateregistry.h"
#include "sword25/gfx/animationtemplate.h"
+// TODO: Destroy the singletons when closing the engine;
+// even better, turn them into non-singleton members of
+// e.g. Sword25Engine.
+DECLARE_SINGLETON(Sword25::AnimationTemplateRegistry)
+
namespace Sword25 {
-Common::ScopedPtr<AnimationTemplateRegistry> AnimationTemplateRegistry::_instancePtr;
-
void AnimationTemplateRegistry::logErrorLn(const char *message) const {
BS_LOG_ERRORLN(message);
}
Modified: scummvm/trunk/engines/sword25/gfx/animationtemplateregistry.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/animationtemplateregistry.h 2010-10-13 15:41:00 UTC (rev 53430)
+++ scummvm/trunk/engines/sword25/gfx/animationtemplateregistry.h 2010-10-13 15:41:34 UTC (rev 53431)
@@ -39,19 +39,17 @@
#include "sword25/kernel/persistable.h"
#include "sword25/kernel/objectregistry.h"
-#include "common/ptr.h"
+#include "common/singleton.h"
namespace Sword25 {
class AnimationTemplate;
-class AnimationTemplateRegistry : public ObjectRegistry<AnimationTemplate>, public Persistable {
+class AnimationTemplateRegistry :
+ public ObjectRegistry<AnimationTemplate>,
+ public Persistable,
+ public Common::Singleton<AnimationTemplateRegistry> {
public:
- static AnimationTemplateRegistry &instance() {
- if (!_instancePtr.get())
- _instancePtr.reset(new AnimationTemplateRegistry);
- return *_instancePtr.get();
- }
virtual bool persist(OutputPersistenceBlock &writer);
virtual bool unpersist(InputPersistenceBlock &reader);
@@ -59,8 +57,6 @@
private:
virtual void logErrorLn(const char *message) const;
virtual void logWarningLn(const char *message) const;
-
- static Common::ScopedPtr<AnimationTemplateRegistry> _instancePtr;
};
} // End of namespace Sword25
Modified: scummvm/trunk/engines/sword25/gfx/graphicengine.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/graphicengine.h 2010-10-13 15:41:00 UTC (rev 53430)
+++ scummvm/trunk/engines/sword25/gfx/graphicengine.h 2010-10-13 15:41:34 UTC (rev 53431)
@@ -46,6 +46,7 @@
// Includes
#include "common/array.h"
#include "common/rect.h"
+#include "common/ptr.h"
#include "common/str.h"
#include "graphics/surface.h"
#include "sword25/kernel/common.h"
Modified: scummvm/trunk/engines/sword25/gfx/renderobjectregistry.cpp
===================================================================
--- scummvm/trunk/engines/sword25/gfx/renderobjectregistry.cpp 2010-10-13 15:41:00 UTC (rev 53430)
+++ scummvm/trunk/engines/sword25/gfx/renderobjectregistry.cpp 2010-10-13 15:41:34 UTC (rev 53431)
@@ -34,14 +34,15 @@
#include "sword25/gfx/renderobjectregistry.h"
-#include "common/ptr.h"
+// TODO: Destroy the singletons when closing the engine;
+// even better, turn them into non-singleton members of
+// e.g. Sword25Engine.
+DECLARE_SINGLETON(Sword25::RenderObjectRegistry)
namespace Sword25 {
#define BS_LOG_PREFIX "RENDEROBJECTREGISTRY"
-Common::ScopedPtr<RenderObjectRegistry> RenderObjectRegistry::_instancePtr;
-
void RenderObjectRegistry::logErrorLn(const char *message) const {
BS_LOG_ERRORLN(message);
}
Modified: scummvm/trunk/engines/sword25/gfx/renderobjectregistry.h
===================================================================
--- scummvm/trunk/engines/sword25/gfx/renderobjectregistry.h 2010-10-13 15:41:00 UTC (rev 53430)
+++ scummvm/trunk/engines/sword25/gfx/renderobjectregistry.h 2010-10-13 15:41:34 UTC (rev 53431)
@@ -42,7 +42,7 @@
#include "sword25/kernel/common.h"
#include "sword25/kernel/objectregistry.h"
-#include "common/ptr.h"
+#include "common/singleton.h"
namespace Sword25 {
@@ -56,21 +56,12 @@
// Klassendeklaration
// -----------------------------------------------------------------------------
-class RenderObjectRegistry : public ObjectRegistry<RenderObject> {
-public:
- static RenderObjectRegistry &instance() {
- if (!_instancePtr.get())
- _instancePtr.reset(new RenderObjectRegistry);
- return *_instancePtr.get();
- }
-
- virtual ~RenderObjectRegistry() {}
-
+class RenderObjectRegistry :
+ public ObjectRegistry<RenderObject>,
+ public Common::Singleton<RenderObjectRegistry> {
private:
virtual void logErrorLn(const char *message) const;
virtual void logWarningLn(const char *message) const;
-
- static Common::ScopedPtr<RenderObjectRegistry> _instancePtr;
};
} // End of namespace Sword25
Modified: scummvm/trunk/engines/sword25/math/regionregistry.cpp
===================================================================
--- scummvm/trunk/engines/sword25/math/regionregistry.cpp 2010-10-13 15:41:00 UTC (rev 53430)
+++ scummvm/trunk/engines/sword25/math/regionregistry.cpp 2010-10-13 15:41:34 UTC (rev 53431)
@@ -39,10 +39,13 @@
#include "sword25/math/regionregistry.h"
#include "sword25/math/region.h"
+// TODO: Destroy the singletons when closing the engine;
+// even better, turn them into non-singleton members of
+// e.g. Sword25Engine.
+DECLARE_SINGLETON(Sword25::RegionRegistry)
+
namespace Sword25 {
-Common::SharedPtr<RegionRegistry> RegionRegistry::_instancePtr;
-
void RegionRegistry::logErrorLn(const char *message) const {
BS_LOG_ERRORLN(message);
}
Modified: scummvm/trunk/engines/sword25/math/regionregistry.h
===================================================================
--- scummvm/trunk/engines/sword25/math/regionregistry.h 2010-10-13 15:41:00 UTC (rev 53430)
+++ scummvm/trunk/engines/sword25/math/regionregistry.h 2010-10-13 15:41:34 UTC (rev 53431)
@@ -35,7 +35,8 @@
#ifndef SWORD25_REGIONREGISTRY_H
#define SWORD25_REGIONREGISTRY_H
-#include "common/ptr.h"
+#include "common/singleton.h"
+
#include "sword25/kernel/common.h"
#include "sword25/kernel/persistable.h"
#include "sword25/kernel/objectregistry.h"
@@ -44,21 +45,17 @@
class Region;
-class RegionRegistry : public ObjectRegistry<Region>, public Persistable {
+class RegionRegistry :
+ public ObjectRegistry<Region>,
+ public Persistable,
+ public Common::Singleton<RegionRegistry> {
public:
- static RegionRegistry &instance() {
- if (!_instancePtr.get()) _instancePtr = Common::SharedPtr<RegionRegistry>(new RegionRegistry());
- return *_instancePtr.get();
- }
-
virtual bool persist(OutputPersistenceBlock &writer);
virtual bool unpersist(InputPersistenceBlock &reader);
private:
virtual void logErrorLn(const char *message) const;
virtual void logWarningLn(const char *message) const;
-
- static Common::SharedPtr<RegionRegistry> _instancePtr;
};
} // End of namespace Sword25
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