Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

vhdSingleton.h

00001 00002 /* Original version Copyright (C) Scott Bilas, 2000. 00003 * All rights reserved worldwide. 00004 * 00005 * This software is provided "as is" without express or implied 00006 * warranties. You may freely copy and compile this source into 00007 * applications you distribute provided that the copyright text 00008 * below is included in the resulting source code, for example: 00009 * "Portions Copyright (C) Scott Bilas, 2000" 00010 */ 00011 00012 00018 #ifndef _VHDSINGLETON_H__ 00019 #define _VHDSINGLETON_H__ 00020 00021 #include <assert.h> 00022 00023 // End SJS additions 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

Generated on Sun Oct 3 16:32:22 2004 for vhdABTTree by doxygen 1.3.8