fix compile

This commit is contained in:
Nikolay Korolev 2021-08-30 10:58:57 +03:00
parent 8cbdf27228
commit b67a087448
2 changed files with 36 additions and 33 deletions

View File

@ -4,6 +4,7 @@
// TODO - implement
template<>
cCustomSoundTrack* base::cSingleton<cCustomSoundTrack>::mspInstance = nil;
cCustomSoundTrack::cCustomSoundTrack() :

View File

@ -5,39 +5,7 @@
namespace base
{
class cSingletonBase
{
friend class cSingletonManager;
cSingletonBase* next;
public:
virtual ~cSingletonBase() {}
};
template<typename T>
class cSingleton : public cSingletonBase
{
static T* mspInstance;
static void cSingleton<T>::CreateInstance()
{
mspInstance = new T();
SingletonManager().Add(mspInstance);
}
public:
static T* Instance()
{
if (!mspInstance)
CreateInstance();
return mspInstance;
}
~cSingleton<T>()
{
mspInstance = nil;
}
};
class cSingletonBase;
class cSingletonManager
{
@ -57,4 +25,38 @@ public:
cSingletonManager& SingletonManager();
class cSingletonBase
{
friend class cSingletonManager;
cSingletonBase* next;
public:
virtual ~cSingletonBase() {}
};
template<typename T>
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<T>()
{
mspInstance = nil;
}
};
}