Changeset 3366 for code/branches/resource/src/util/Singleton.h
- Timestamp:
- Jul 29, 2009, 10:27:10 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource/src/util/Singleton.h
r3364 r3366 40 40 Usage: 41 41 Inherit publicly from Singleton<MyClass> and provide access to 42 MyClass::singleton Ref_s.43 This can be done with a friend declaration.42 MyClass::singletonPtr_s. 43 This can easily be done with a friend declaration. 44 44 */ 45 45 template <class T> … … 50 50 static T& getInstance() 51 51 { 52 assert(T::singleton Ref_s != NULL);53 return *T::singleton Ref_s;52 assert(T::singletonPtr_s != NULL); 53 return *T::singletonPtr_s; 54 54 } 55 55 56 56 protected: 57 // Constructor sets the singleton instance pointer57 //! Constructor sets the singleton instance pointer 58 58 Singleton() 59 59 { 60 assert(T::singleton Ref_s == NULL);61 T::singleton Ref_s = static_cast<T*>(this);60 assert(T::singletonPtr_s == NULL); 61 T::singletonPtr_s = static_cast<T*>(this); 62 62 } 63 // Constructor resets the singleton instance pointer 63 64 //! Constructor resets the singleton instance pointer 64 65 ~Singleton() 65 66 { 66 assert(T::singleton Ref_s != NULL);67 T::singleton Ref_s = NULL;67 assert(T::singletonPtr_s != NULL); 68 T::singletonPtr_s = NULL; 68 69 } 69 70
Note: See TracChangeset
for help on using the changeset viewer.