00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00018
#ifndef _VHDSINGLETON_H__
00019
#define _VHDSINGLETON_H__
00020
00021
#include <assert.h>
00022
00023
00026 template <
typename T>
class vhdSingleton
00027 {
00028
protected:
00029
00030
static T* ms_Singleton;
00031
00032
public:
00033
vhdSingleton(
void )
00034 {
00035 assert( !ms_Singleton );
00036 ms_Singleton = static_cast <T*> (
this);
00037 }
00038 ~
vhdSingleton(
void )
00039 { assert( ms_Singleton ); ms_Singleton = 0; }
00040
static T& getSingleton(
void )
00041 { assert( ms_Singleton );
return ( *ms_Singleton ); }
00042
static T* getSingletonPtr(
void )
00043 {
return ( ms_Singleton ); }
00044
static void setSingletonPtr(T* ptrT)
00045 {
00046 ms_Singleton=ptrT;
00047 }
00048 };
00049
00050
00051
#endif