template <class T>
class FvSingleton
{
protected:
static T *ms_pkInstance;this
public:
FvSingleton()
{
CCASSERT(ms_pkInstance == NULL,"");
ms_pkInstance = static_cast< T * >( this );
}ast
virtual ~FvSingleton()
{
ms_pkInstance = 0;
}class
static T &Instance()
{
if (ms_pkInstance == nullptr)
{
new T;
}
return *ms_pkInstance;
}static
static T *pInstance()
{
return ms_pkInstance;
}
};vi
#define FV_SINGLETON_STORAGE( TYPE ) \
template <> \
TYPE * FvSingleton< TYPE >::ms_pkInstance = 0; cas