Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/network/src/core/SignalHandler.h @ 1494

Last change on this file since 1494 was 1494, checked in by rgrieder, 16 years ago
  • set the svn:eol-style property to all files so, that where ever you check out, you'll get the right line endings (had to change every file with mixed endings to windows in order to set the property)
  • Property svn:eol-style set to native
File size: 2.7 KB
Line 
1/* *   ORXONOX - the hottest 3D action shooter ever to exist *                    > www.orxonox.net < * * *   License notice: * *   This program is free software; you can redistribute it and/or *   modify it under the terms of the GNU General Public License *   as published by the Free Software Foundation; either version 2 *   of the License, or (at your option) any later version. * *   This program is distributed in the hope that it will be useful, *   but WITHOUT ANY WARRANTY; without even the implied warranty of *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the *   GNU General Public License for more details. * *   You should have received a copy of the GNU General Public License *   along with this program; if not, write to the Free Software *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA. * *   Author: *      Christoph Renner *   Co-authors: *      ... * */
2/**    @file SignalHandler.h    @brief Definition of the SignalHandler class.*/#ifndef _SignalHandler_H__
3#define _SignalHandler_H__
4
5#include "CorePrereqs.h"
6
7#include <list>
8#include <string>
9
10typedef int (*SignalCallback)( void * someData );
11
12#ifndef __WIN32__
13#include <signal.h>
14
15struct SignalRec
16{
17  int signal;
18  sig_t handler;
19};
20
21struct SignalCallbackRec
22{
23  SignalCallback cb;
24  void * someData;
25};
26
27
28typedef std::list<SignalRec> SignalRecList;
29typedef std::list<SignalCallbackRec> SignalCallbackList;
30
31class SignalHandler
32{
33  private:
34    SignalHandler();
35  public:
36    inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; }
37    ~SignalHandler(){ SignalHandler::singletonRef = NULL; }
38
39    void registerCallback( SignalCallback cb, void * someData );
40
41    void doCatch( const std::string & appName, const std::string & fileName );
42    void dontCatch();
43
44  private:
45    static void sigHandler( int sig );
46
47    void catchSignal( int sig );
48    SignalRecList sigRecList;
49
50    SignalCallbackList callbackList;
51
52    static SignalHandler * singletonRef;
53
54    std::string appName;
55    std::string fileName;
56
57    // used to turn on KeyAutoRepeat if OIS crashes
58    static bool bXAutoKeyRepeatOn_;
59};
60
61#else /* #ifndef __WIN32__ */
62
63class _CoreExport SignalHandler
64{
65 public:
66   inline static SignalHandler* getInstance() { if (!SignalHandler::singletonRef) SignalHandler::singletonRef = new SignalHandler(); return SignalHandler::singletonRef; };
67   void doCatch( const std::string & appName, const std::string & fileName ) {};
68  void dontCatch() {};
69  void registerCallback( SignalCallback cb, void * someData ) {};
70
71 private:
72    static SignalHandler * singletonRef;
73};
74#endif /* #ifndef __WIN32__ */
75
76#endif /* _SignalHandler_H__ */
Note: See TracBrowser for help on using the repository browser.