All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SignalHandling.h
Go to the documentation of this file.
1 #ifndef SIGNALHANDLING_H
2 #define SIGNALHANDLING_H
3 
4 #include <cstdint>
5 #include <exception>
6 
7 namespace Aux {
8 
9  class SignalHandler {
10  public:
11  SignalHandler();
12 
14 
15  void assureRunning();
16 
17  bool isRunning();
18  };
19 
20 namespace SignalHandling {
24  class InterruptException : public std::exception {
25  public:
26  InterruptException() : std::exception() {}
27  virtual const char* what() const noexcept
28  {
29  return "Received CTRL+C/SIGINT";
30  }
31  };
32 
37  bool gotSIGINT();
38 
43  void setSIGINT(bool received);
44 
50  void init(SignalHandler* caller);
51 
57  void reset(SignalHandler* caller);
58  }
59 
60 }
61 
62 #endif /* SIGNALHANDLING_H */
bool gotSIGINT()
Returns true, if CTRL+C/SIGINT has been received, false otherwise.
Definition: SignalHandling.cpp:23
~SignalHandler()
Definition: SignalHandling.cpp:61
bool isRunning()
Definition: SignalHandling.cpp:71
SignalHandler()
Definition: SignalHandling.cpp:57
Special Exception to indicate, that a SIGINT has been received.
Definition: SignalHandling.h:24
virtual const char * what() const noexcept
Definition: SignalHandling.h:27
void reset(SignalHandler *caller)
Resets receivedSIGINT to false and rootSet to false to allow a new initialization, if the calling object is the same as the root.
Definition: SignalHandling.cpp:42
void init(SignalHandler *caller)
Registers the function setRunning to be invoked, when CTRL+C/SIGINT is received.
Definition: SignalHandling.cpp:31
InterruptException()
Definition: SignalHandling.h:26
void assureRunning()
Definition: SignalHandling.cpp:65
void setSIGINT(bool received)
Sets the value of receivedSIGINT
Definition: SignalHandling.cpp:27
Definition: SignalHandling.h:9