・シングルトン
template< typename To_ > class CSingleton
{
public:
typedef To_ object_type;
public:
static object_type* GetInstance( void )
{
if ( m_pInstance == NULL )
{
m_pInstance = new object_type();
}
return m_pInstance;
};
static void ReleaseInstance( void )
{
if ( m_pInstance != NULL )
{
delete m_pInstance;
m_pInstance = NULL;
}
};
static bool IsInstance( void )
{
return (m_pInstance != NULL);
};
protected:
CSingleton( void ) {
};
virtual ~CSingleton( void ) {
};
private:
CSingleton( const CSingleton& );
CSingleton& operator=( const CSingleton& );
private:
static object_type* m_pInstance;
};
template< typename To_ > typename CSingleton< To_ >::object_type*
CSingleton< To_ >::m_pInstance = NULL;
最終更新:2008年02月11日 13:24