Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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