Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/libraries/util/SignalHandler.h @ 6916

Last change on this file since 6916 was 5738, checked in by landauf, 15 years ago

merged libraries2 back to trunk

  • Property svn:eol-style set to native
File size: 2.8 KB
RevLine 
[1505]1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Christoph Renner
24 *   Co-authors:
25 *      ...
26 *
27 */
[682]28
[1505]29/**
[2030]30    @file
[1755]31    @brief Declaration of the SignalHandler class.
[1505]32*/
33
[497]34#ifndef _SignalHandler_H__
35#define _SignalHandler_H__
36
[2030]37#include "UtilPrereqs.h"
[1062]38
[2662]39#include <cassert>
[497]40#include <list>
41#include <string>
[3370]42#include "Singleton.h"
[497]43
[2171]44namespace orxonox
45{
46    typedef int (*SignalCallback)( void * someData );
47}
[497]48
[2710]49#ifdef ORXONOX_PLATFORM_LINUX
[497]50#include <signal.h>
51
[2171]52namespace orxonox
[497]53{
[2171]54    struct SignalRec
55    {
56        int signal;
57        sig_t handler;
58    };
[497]59
[2171]60    struct SignalCallbackRec
61    {
62        SignalCallback cb;
63        void * someData;
64    };
[497]65
66
[2171]67    typedef std::list<SignalRec> SignalRecList;
68    typedef std::list<SignalCallbackRec> SignalCallbackList;
[497]69
[3370]70    class SignalHandler : public Singleton<SignalHandler>
[2171]71    {
[3370]72        friend class Singleton<SignalHandler>;
[2171]73    public:
[3370]74        SignalHandler()  { }
75        ~SignalHandler() { }
[497]76
[2171]77        void registerCallback( SignalCallback cb, void * someData );
[497]78
[2171]79        void doCatch( const std::string & appName, const std::string & filename );
80        void dontCatch();
[497]81
[2171]82    private:
83        static void sigHandler( int sig );
[497]84
[2171]85        void catchSignal( int sig );
86        SignalRecList sigRecList;
[497]87
[2171]88        SignalCallbackList callbackList;
[497]89
[3370]90        static SignalHandler* singletonPtr_s;
[497]91
[2171]92        std::string appName;
93        std::string filename;
94    };
95}
[497]96
[2710]97#else /* ORXONOX_PLATFORM_LINUX */
[682]98
[2171]99namespace orxonox
[497]100{
[3370]101    class _UtilExport SignalHandler : public Singleton<SignalHandler>
[2171]102    {
[3370]103        friend class Singleton<SignalHandler>;
[2171]104    public:
[3370]105        SignalHandler()  { }
106        ~SignalHandler() { }
[2662]107        void doCatch( const std::string & appName, const std::string & filename ) {}
108        void dontCatch() {}
109        void registerCallback( SignalCallback cb, void * someData ) {}
[497]110
[2171]111    private:
[3370]112        static SignalHandler* singletonPtr_s;
[2171]113    };
114}
[497]115
[2710]116#endif /* ORXONOX_PLATFORM_LINUX */
[1607]117
[497]118#endif /* _SignalHandler_H__ */
Note: See TracBrowser for help on using the repository browser.