|
Last change
on this file since 7821 was
7440,
checked in by bensch, 20 years ago
|
|
orxonox/trunk: merged the Signal-Handler-Branche back to the TRUNK
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 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 | |
|---|
| 14 | enum GdbRunType{ |
|---|
| 15 | GDB_RUN_WRITE_TO_FILE = 1, |
|---|
| 16 | GDB_RUN_IN_FOREGROUND |
|---|
| 17 | }; |
|---|
| 18 | |
|---|
| 19 | |
|---|
| 20 | #ifndef __WIN32__ |
|---|
| 21 | #include <signal.h> |
|---|
| 22 | |
|---|
| 23 | struct SignalRec |
|---|
| 24 | { |
|---|
| 25 | int signal; |
|---|
| 26 | sighandler_t handler; |
|---|
| 27 | }; |
|---|
| 28 | |
|---|
| 29 | |
|---|
| 30 | typedef std::list<SignalRec> SignalRecList; |
|---|
| 31 | |
|---|
| 32 | class SignalHandler |
|---|
| 33 | { |
|---|
| 34 | private: |
|---|
| 35 | SignalHandler(); |
|---|
| 36 | public: |
|---|
| 37 | inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); |
|---|
| 38 | return SignalHandler::singletonRef; } |
|---|
| 39 | |
|---|
| 40 | void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE ); |
|---|
| 41 | void dontCatch(); |
|---|
| 42 | |
|---|
| 43 | private: |
|---|
| 44 | static void sigHandler( int sig ); |
|---|
| 45 | |
|---|
| 46 | void catchSignal( int sig ); |
|---|
| 47 | SignalRecList sigRecList; |
|---|
| 48 | |
|---|
| 49 | static SignalHandler * singletonRef; |
|---|
| 50 | |
|---|
| 51 | GdbRunType type; |
|---|
| 52 | |
|---|
| 53 | std::string appName; |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | #else /* if defined __WIN32__ */ |
|---|
| 57 | class SignalHandler |
|---|
| 58 | { |
|---|
| 59 | public: |
|---|
| 60 | inline static SignalHandler* getInstance() {}; |
|---|
| 61 | void doCatch( std::string appName, GdbRunType type = GDB_RUN_WRITE_TO_FILE ) {}; |
|---|
| 62 | void dontCatch() {}; |
|---|
| 63 | }; |
|---|
| 64 | #endif |
|---|
| 65 | |
|---|
| 66 | #endif /* _SIGNAL_HANDLER_H */ |
|---|
| 67 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.