📄 cmsingleton.h
字号:
#ifndef __Sync_Singleton_H
#define __Sync_Singleton_H
#include <MatrixCore/System/CMObject.h>
namespace MatrixCore
{
namespace Pattern
{
template< class T >
class CMSingleton : public CMObject
{
public:
static T* getInstance();
static void releaseInstance();
virtual void initialize() = 0;
private:
static T* m_pSelfInstance;
};
template < class T >
T* CMSingleton< T >::m_pSelfInstance = NULL;
template < class T >
T* CMSingleton< T >::getInstance()
{
if( m_pSelfInstance == NULL )
{
m_pSelfInstance = new T();
m_pSelfInstance->initialize();
}
return m_pSelfInstance;
}
template < class T >
void CMSingleton< T >::releaseInstance()
{
if( m_pSelfInstance != 0 )
delete m_pSelfInstance;
m_pSelfInstance = NULL;
}
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -