52 lines
981 B
C++
52 lines
981 B
C++
#pragma once
|
|
|
|
/**************************************************************************************************
|
|
|
|
작성일: 2008-07-08
|
|
작성자: 문상현 (youngmoon@webzen.co.kr)
|
|
|
|
설명: 싱클톤 지원
|
|
|
|
**************************************************************************************************/
|
|
|
|
#define _instance(_class) WZPUBLIC::CSingleton<_class>::GetInstance()
|
|
#define _releaseinstance(_class) WZPUBLIC::CSingleton<_class>::ReleaseInstance()
|
|
|
|
namespace WZPUBLIC
|
|
{
|
|
template <typename _TInstance>
|
|
|
|
class CSingleton
|
|
{
|
|
public:
|
|
CSingleton(void);
|
|
~CSingleton(void);
|
|
|
|
static _TInstance* GetInstance()
|
|
{
|
|
if(NULL == m_Instance)
|
|
{
|
|
m_Instance = new _TInstance();
|
|
}
|
|
|
|
return m_Instance;
|
|
};
|
|
|
|
static void ReleaseInstance()
|
|
{
|
|
if( NULL != m_Instance )
|
|
{
|
|
delete m_Instance;
|
|
m_Instance = NULL;
|
|
}
|
|
};
|
|
|
|
private:
|
|
static _TInstance* m_Instance;
|
|
};
|
|
|
|
|
|
template <typename _TInstance> _TInstance* CSingleton<_TInstance>::m_Instance = NULL;
|
|
|
|
}
|