Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/util/signal_handler.h @ 10769

Last change on this file since 10769 was 9877, checked in by bensch, 18 years ago

orxonox compiles in Windows again… but it does not run anymore

File size: 1.7 KB
RevLine 
[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
[8623]12typedef int (*SignalCallback)( void * someData );
[7439]13
14#ifndef __WIN32__
15#include <signal.h>
16
[7361]17struct SignalRec
18{
19  int signal;
[8293]20  sig_t handler;
[7361]21};
22
[8228]23struct SignalCallbackRec
24{
25  SignalCallback cb;
26  void * someData;
27};
[7439]28
[8228]29
[7361]30typedef std::list<SignalRec> SignalRecList;
[8228]31typedef std::list<SignalCallbackRec> SignalCallbackList;
[7361]32
33class SignalHandler
34{
35  private:
36    SignalHandler();
37  public:
[8228]38    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
[9110]39    ~SignalHandler(){ SignalHandler::singletonRef = NULL; }
[8623]40
[8228]41    void registerCallback( SignalCallback cb, void * someData );
[7361]42
[9406]43    void doCatch( const std::string & appName, const std::string & fileName );
[7361]44    void dontCatch();
45
46  private:
47    static void sigHandler( int sig );
48
49    void catchSignal( int sig );
50    SignalRecList sigRecList;
[8623]51
[8228]52    SignalCallbackList callbackList;
[7361]53
54    static SignalHandler * singletonRef;
55
56    std::string appName;
[9406]57    std::string fileName;
[7361]58};
59
[7439]60#else /* if defined __WIN32__ */
61class SignalHandler
62{
[7440]63 public:
[8228]64   inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; };
[9877]65   void doCatch( const std::string & appName, const std::string & fileName ) {};
[7439]66  void dontCatch() {};
[8228]67  void registerCallback( SignalCallback cb, void * someData ) {};
[8523]68
69 private:
70    static SignalHandler * singletonRef;
[7439]71};
72#endif
[7361]73
74#endif /* _SIGNAL_HANDLER_H */
75
Note: See TracBrowser for help on using the repository browser.