1 /*************************************************************************
2 ** SignalHandler.h                                                      **
3 **                                                                      **
4 ** This file is part of dvisvgm -- the DVI to SVG converter             **
5 ** Copyright (C) 2005-2015 Martin Gieseking <martin.gieseking@uos.de>   **
6 **                                                                      **
7 ** This program is free software; you can redistribute it and/or        **
8 ** modify it under the terms of the GNU General Public License as       **
9 ** published by the Free Software Foundation; either version 3 of       **
10 ** the License, or (at your option) any later version.                  **
11 **                                                                      **
12 ** This program is distributed in the hope that it will be useful, but  **
13 ** WITHOUT ANY WARRANTY; without even the implied warranty of           **
14 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the         **
15 ** GNU General Public License for more details.                         **
16 **                                                                      **
17 ** You should have received a copy of the GNU General Public License    **
18 ** along with this program; if not, see <http://www.gnu.org/licenses/>. **
19 *************************************************************************/
20 
21 #ifndef DVISVGM_SIGNALHANDLER_H
22 #define DVISVGM_SIGNALHANDLER_H
23 
24 #include <exception>
25 
26 struct SignalException : public std::exception {
27 };
28 
29 
30 class SignalHandler
31 {
32 	public:
33 		~SignalHandler ();
34 		static SignalHandler& instance ();
35 		bool start ();
36 		void stop ();
37 		void check ();
38 		void trigger (bool notify);
active()39 		bool active () const {return _active;}
40 
41 	protected:
SignalHandler()42 		SignalHandler () : _active(false) {}
43 		static void callback (int signal);
44 
45 	private:
46 		bool _active;       ///< true if listening for signals
47 		static bool _break; ///< true if signal has been caught
48 };
49 
50 #endif
51