mirror of
https://github.com/halpz/re3.git
synced 2025-01-02 19:25:30 +00:00
fix compile
This commit is contained in:
parent
8cbdf27228
commit
b67a087448
|
@ -4,6 +4,7 @@
|
|||
|
||||
// TODO - implement
|
||||
|
||||
template<>
|
||||
cCustomSoundTrack* base::cSingleton<cCustomSoundTrack>::mspInstance = nil;
|
||||
|
||||
cCustomSoundTrack::cCustomSoundTrack() :
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue