Last change
on this file since 8236 was
8228,
checked in by patrick, 19 years ago
|
trunk: merged the network branche back to trunk with command: svn merge branches/network trunk -r8150:HEAD
|
File size:
1.7 KB
|
Rev | Line | |
---|
[7361] | 1 | /*! |
---|
| 2 | * @file signalhandler.h |
---|
| 3 | * Defines game rules for this game |
---|
| 4 | */ |
---|
| 5 | |
---|
| 6 | #ifndef _SIGNAL_HANDLER_H |
---|
| 7 | #define _SIGNAL_HANDLER_H |
---|
| 8 | |
---|
| 9 | #include <list> |
---|
| 10 | #include <string> |
---|
| 11 | |
---|
| 12 | #define GDB_BT_FILE "orxonox.backtrace" |
---|
| 13 | |
---|
[7439] | 14 | enum GdbRunType{ |
---|
| 15 | GDB_RUN_WRITE_TO_FILE = 1, |
---|
| 16 | GDB_RUN_IN_FOREGROUND |
---|
| 17 | }; |
---|
| 18 | |
---|
[8228] | 19 | typedef bool (*SignalCallback)( void * someData ); |
---|
[7439] | 20 | |
---|
| 21 | #ifndef __WIN32__ |
---|
| 22 | #include <signal.h> |
---|
| 23 | |
---|
[7361] | 24 | struct SignalRec |
---|
| 25 | { |
---|
| 26 | int signal; |
---|
| 27 | sighandler_t handler; |
---|
| 28 | }; |
---|
| 29 | |
---|
[8228] | 30 | struct SignalCallbackRec |
---|
| 31 | { |
---|
| 32 | SignalCallback cb; |
---|
| 33 | void * someData; |
---|
| 34 | }; |
---|
[7439] | 35 | |
---|
[8228] | 36 | |
---|
[7361] | 37 | typedef std::list<SignalRec> SignalRecList; |
---|
[8228] | 38 | typedef std::list<SignalCallbackRec> SignalCallbackList; |
---|
[7361] | 39 | |
---|
| 40 | class SignalHandler |
---|
| 41 | { |
---|
| 42 | private: |
---|
| 43 | SignalHandler(); |
---|
| 44 | public: |
---|
[8228] | 45 | inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; } |
---|
| 46 | |
---|
| 47 | void registerCallback( SignalCallback cb, void * someData ); |
---|
[7361] | 48 | |
---|
| 49 | void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE ); |
---|
| 50 | void dontCatch(); |
---|
| 51 | |
---|
| 52 | private: |
---|
| 53 | static void sigHandler( int sig ); |
---|
| 54 | |
---|
| 55 | void catchSignal( int sig ); |
---|
| 56 | SignalRecList sigRecList; |
---|
[8228] | 57 | |
---|
| 58 | SignalCallbackList callbackList; |
---|
[7361] | 59 | |
---|
| 60 | static SignalHandler * singletonRef; |
---|
| 61 | |
---|
| 62 | GdbRunType type; |
---|
| 63 | |
---|
| 64 | std::string appName; |
---|
| 65 | }; |
---|
| 66 | |
---|
[7439] | 67 | #else /* if defined __WIN32__ */ |
---|
| 68 | class SignalHandler |
---|
| 69 | { |
---|
[7440] | 70 | public: |
---|
[8228] | 71 | inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }; |
---|
[7439] | 72 | void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE ) {}; |
---|
| 73 | void dontCatch() {}; |
---|
[8228] | 74 | void registerCallback( SignalCallback cb, void * someData ) {}; |
---|
[7439] | 75 | }; |
---|
| 76 | #endif |
---|
[7361] | 77 | |
---|
| 78 | #endif /* _SIGNAL_HANDLER_H */ |
---|
| 79 | |
---|
Note: See
TracBrowser
for help on using the repository browser.