Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/doc/src/libraries/util/SignalHandler.h @ 7660

Last change on this file since 7660 was 7327, checked in by landauf, 14 years ago

added documentation

  • Property svn:eol-style set to native
File size: 3.0 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
[7327]31    @ingroup Util
[1755]32    @brief Declaration of the SignalHandler class.
[1505]33*/
34
[497]35#ifndef _SignalHandler_H__
36#define _SignalHandler_H__
37
[2030]38#include "UtilPrereqs.h"
[1062]39
[2662]40#include <cassert>
[497]41#include <list>
42#include <string>
[3370]43#include "Singleton.h"
[497]44
[2171]45namespace orxonox
46{
47    typedef int (*SignalCallback)( void * someData );
48}
[497]49
[2710]50#ifdef ORXONOX_PLATFORM_LINUX
[497]51#include <signal.h>
52
[2171]53namespace orxonox
[497]54{
[2171]55    struct SignalRec
56    {
57        int signal;
58        sig_t handler;
59    };
[497]60
[2171]61    struct SignalCallbackRec
62    {
63        SignalCallback cb;
64        void * someData;
65    };
[497]66
67
[2171]68    typedef std::list<SignalRec> SignalRecList;
69    typedef std::list<SignalCallbackRec> SignalCallbackList;
[497]70
[7327]71    /// The SignalHandler is used to catch signals like SIGSEGV and write a backtrace to the logfile.
[3370]72    class SignalHandler : public Singleton<SignalHandler>
[2171]73    {
[3370]74        friend class Singleton<SignalHandler>;
[2171]75    public:
[3370]76        SignalHandler()  { }
77        ~SignalHandler() { }
[497]78
[2171]79        void registerCallback( SignalCallback cb, void * someData );
[497]80
[2171]81        void doCatch( const std::string & appName, const std::string & filename );
82        void dontCatch();
[497]83
[2171]84    private:
85        static void sigHandler( int sig );
[497]86
[2171]87        void catchSignal( int sig );
88        SignalRecList sigRecList;
[497]89
[2171]90        SignalCallbackList callbackList;
[497]91
[3370]92        static SignalHandler* singletonPtr_s;
[497]93
[2171]94        std::string appName;
95        std::string filename;
96    };
97}
[497]98
[2710]99#else /* ORXONOX_PLATFORM_LINUX */
[682]100
[2171]101namespace orxonox
[497]102{
[7327]103    /// The SignalHandler is used to catch signals like SIGSEGV and write a backtrace to the logfile. Not implemented on Windows.
[3370]104    class _UtilExport SignalHandler : public Singleton<SignalHandler>
[2171]105    {
[3370]106        friend class Singleton<SignalHandler>;
[2171]107    public:
[3370]108        SignalHandler()  { }
109        ~SignalHandler() { }
[2662]110        void doCatch( const std::string & appName, const std::string & filename ) {}
111        void dontCatch() {}
112        void registerCallback( SignalCallback cb, void * someData ) {}
[497]113
[2171]114    private:
[3370]115        static SignalHandler* singletonPtr_s;
[2171]116    };
117}
[497]118
[2710]119#endif /* ORXONOX_PLATFORM_LINUX */
[1607]120
[497]121#endif /* _SignalHandler_H__ */
Note: See TracBrowser for help on using the repository browser.