From b67a08744849c2d0912ac818de92b752ee563e19 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Mon, 30 Aug 2021 10:58:57 +0300 Subject: [PATCH] fix compile --- src/leeds/CustomSoundTrack.cpp | 1 + src/leeds/base/singletonManager.h | 68 ++++++++++++++++--------------- 2 files changed, 36 insertions(+), 33 deletions(-) diff --git a/src/leeds/CustomSoundTrack.cpp b/src/leeds/CustomSoundTrack.cpp index bcbfb82f..a71a66cc 100644 --- a/src/leeds/CustomSoundTrack.cpp +++ b/src/leeds/CustomSoundTrack.cpp @@ -4,6 +4,7 @@ // TODO - implement +template<> cCustomSoundTrack* base::cSingleton::mspInstance = nil; cCustomSoundTrack::cCustomSoundTrack() : diff --git a/src/leeds/base/singletonManager.h b/src/leeds/base/singletonManager.h index 833e178b..9c980bb2 100644 --- a/src/leeds/base/singletonManager.h +++ b/src/leeds/base/singletonManager.h @@ -5,39 +5,7 @@ namespace base { -class cSingletonBase -{ - friend class cSingletonManager; - - cSingletonBase* next; - -public: - virtual ~cSingletonBase() {} -}; - -template -class cSingleton : public cSingletonBase -{ - static T* mspInstance; - static void cSingleton::CreateInstance() - { - mspInstance = new T(); - SingletonManager().Add(mspInstance); - } - -public: - static T* Instance() - { - if (!mspInstance) - CreateInstance(); - return mspInstance; - } - - ~cSingleton() - { - mspInstance = nil; - } -}; +class cSingletonBase; class cSingletonManager { @@ -57,4 +25,38 @@ public: cSingletonManager& SingletonManager(); +class cSingletonBase +{ + friend class cSingletonManager; + + cSingletonBase* next; + +public: + virtual ~cSingletonBase() {} +}; + +template +class cSingleton : public cSingletonBase +{ + static T* mspInstance; + static void CreateInstance() + { + mspInstance = new T(); + SingletonManager().Add(mspInstance); + } + +public: + static T* Instance() + { + if (!mspInstance) + CreateInstance(); + return mspInstance; + } + + ~cSingleton() + { + mspInstance = nil; + } +}; + } \ No newline at end of file