Changeset 3366 for code/branches/resource/src/util
- Timestamp:
- Jul 29, 2009, 10:27:10 PM (15 years ago)
- Location:
- code/branches/resource/src/util
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/resource/src/util/SignalHandler.cc
r3301 r3366 41 41 namespace orxonox 42 42 { 43 SignalHandler* SignalHandler::singleton Ref_s = NULL;43 SignalHandler* SignalHandler::singletonPtr_s = NULL; 44 44 } 45 45 … … 122 122 } 123 123 // if the signalhandler has already been destroyed then don't do anything 124 if( SignalHandler::singleton Ref_s == 0 )124 if( SignalHandler::singletonPtr_s == 0 ) 125 125 { 126 126 COUT(0) << "recieved signal " << sigName.c_str() << std::endl << "can't write backtrace because SignalHandler already destroyed" << std::endl; -
code/branches/resource/src/util/SignalHandler.h
r3068 r3366 40 40 #include <list> 41 41 #include <string> 42 #include "Singleton.h" 42 43 43 44 namespace orxonox … … 67 68 typedef std::list<SignalCallbackRec> SignalCallbackList; 68 69 69 class SignalHandler 70 class SignalHandler : public Singleton<SignalHandler> 70 71 { 72 friend class Singleton<SignalHandler>; 71 73 public: 72 SignalHandler() { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; } 73 ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = NULL; } 74 inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; } 74 SignalHandler() { } 75 ~SignalHandler() { } 75 76 76 77 void registerCallback( SignalCallback cb, void * someData ); … … 87 88 SignalCallbackList callbackList; 88 89 89 static SignalHandler* singleton Ref_s;90 static SignalHandler* singletonPtr_s; 90 91 91 92 std::string appName; … … 98 99 namespace orxonox 99 100 { 100 class _UtilExport SignalHandler 101 class _UtilExport SignalHandler : public Singleton<SignalHandler> 101 102 { 103 friend class Singleton<SignalHandler>; 102 104 public: 103 SignalHandler() { assert(SignalHandler::singletonRef_s == 0); SignalHandler::singletonRef_s = this; } 104 ~SignalHandler() { assert(SignalHandler::singletonRef_s != 0); SignalHandler::singletonRef_s = 0; } 105 inline static SignalHandler& getInstance() { assert(SignalHandler::singletonRef_s); return *SignalHandler::singletonRef_s; } 105 SignalHandler() { } 106 ~SignalHandler() { } 106 107 void doCatch( const std::string & appName, const std::string & filename ) {} 107 108 void dontCatch() {} … … 109 110 110 111 private: 111 static SignalHandler* singleton Ref_s;112 static SignalHandler* singletonPtr_s; 112 113 }; 113 114 } -
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.