From 9b4d41d2d2a165a95b3b9223f53196fe51c0b14f Mon Sep 17 00:00:00 2001 From: Max Horn Date: Wed, 13 Oct 2010 15:41:34 +0000 Subject: SWORD25: Convert object registries to singletons svn-id: r53431 --- engines/sword25/math/regionregistry.cpp | 7 +++++-- engines/sword25/math/regionregistry.h | 15 ++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) (limited to 'engines/sword25/math') diff --git a/engines/sword25/math/regionregistry.cpp b/engines/sword25/math/regionregistry.cpp index 1509ea9e5e..bcfb2cbc43 100644 --- a/engines/sword25/math/regionregistry.cpp +++ b/engines/sword25/math/regionregistry.cpp @@ -39,9 +39,12 @@ #include "sword25/math/regionregistry.h" #include "sword25/math/region.h" -namespace Sword25 { +// TODO: Destroy the singletons when closing the engine; +// even better, turn them into non-singleton members of +// e.g. Sword25Engine. +DECLARE_SINGLETON(Sword25::RegionRegistry) -Common::SharedPtr RegionRegistry::_instancePtr; +namespace Sword25 { void RegionRegistry::logErrorLn(const char *message) const { BS_LOG_ERRORLN(message); diff --git a/engines/sword25/math/regionregistry.h b/engines/sword25/math/regionregistry.h index 78c2c08fc3..560d4ae4a9 100644 --- a/engines/sword25/math/regionregistry.h +++ b/engines/sword25/math/regionregistry.h @@ -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 @@ namespace Sword25 { class Region; -class RegionRegistry : public ObjectRegistry, public Persistable { +class RegionRegistry : + public ObjectRegistry, + public Persistable, + public Common::Singleton { public: - static RegionRegistry &instance() { - if (!_instancePtr.get()) _instancePtr = Common::SharedPtr(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 _instancePtr; }; } // End of namespace Sword25 -- cgit v1.2.3