Changeset 8228 in orxonox.OLD for trunk/src/util
- Timestamp:
- Jun 8, 2006, 11:19:08 AM (19 years ago)
- Location:
- trunk/src/util
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/util/signal_handler.cc
r8068 r8228 17 17 #include <assert.h> 18 18 19 SignalHandler * SignalHandler::singletonRef = NULL; 20 19 21 #ifndef __WIN32__ 20 21 SignalHandler * SignalHandler::singletonRef = NULL;22 22 23 23 SignalHandler::SignalHandler() … … 59 59 void SignalHandler::sigHandler( int sig ) 60 60 { 61 for ( SignalCallbackList::iterator it = SignalHandler::getInstance()->callbackList.begin(); it != SignalHandler::getInstance()->callbackList.end(); it++ ) 62 { 63 (*(it->cb))( it->someData ); 64 } 65 61 66 std::string sigName = "UNKNOWN"; 62 67 … … 113 118 } 114 119 120 void SignalHandler::registerCallback( SignalCallback cb, void * someData ) 121 { 122 SignalCallbackRec rec; 123 rec.cb = cb; 124 rec.someData = someData; 125 126 callbackList.push_back(rec); 127 } 128 115 129 #endif /* __WIN32__ */ -
trunk/src/util/signal_handler.h
r7440 r8228 17 17 }; 18 18 19 typedef bool (*SignalCallback)( void * someData ); 19 20 20 21 #ifndef __WIN32__ … … 27 28 }; 28 29 30 struct SignalCallbackRec 31 { 32 SignalCallback cb; 33 void * someData; 34 }; 35 29 36 30 37 typedef std::list<SignalRec> SignalRecList; 38 typedef std::list<SignalCallbackRec> SignalCallbackList; 31 39 32 40 class SignalHandler … … 35 43 SignalHandler(); 36 44 public: 37 inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); 38 return SignalHandler::singletonRef; } 45 inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; } 46 47 void registerCallback( SignalCallback cb, void * someData ); 39 48 40 49 void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE ); … … 46 55 void catchSignal( int sig ); 47 56 SignalRecList sigRecList; 57 58 SignalCallbackList callbackList; 48 59 49 60 static SignalHandler * singletonRef; … … 58 69 { 59 70 public: 60 inline static SignalHandler* getInstance() {};71 inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }; 61 72 void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE ) {}; 62 73 void dontCatch() {}; 74 void registerCallback( SignalCallback cb, void * someData ) {}; 63 75 }; 64 76 #endif
Note: See TracChangeset
for help on using the changeset viewer.