BioCMAMC-ST
signal_handling.hpp
1#ifndef __SIGNAL_HANDLING_HPP__
2#define __SIGNAL_HANDLING_HPP__
3
4#include <stdexcept>
5
6namespace Core
7{
8
18 {
19 public:
26 explicit SignalHandler();
27
37 [[nodiscard]] static inline bool is_usr1_raised() noexcept(false)
38 {
39 if (instance == nullptr)
40 {
41 throw std::runtime_error("SignalHandler not initialized before use");
42 }
43
44 const auto ret = instance->f_usr1_raised;
45 instance->f_usr1_raised = false;
46 return ret;
47 }
48
49 [[nodiscard]] static inline bool is_usr2_raised() noexcept(false)
50 {
51 if (instance == nullptr)
52 {
53 throw std::runtime_error("SignalHandler not initialized before use");
54 }
55
56 const auto ret = instance->f_usr2_raised;
57 instance->f_usr2_raised = false;
58 return ret;
59 }
60
61 [[nodiscard]] static inline bool is_sigint_raised() noexcept(false)
62 {
63 if (instance == nullptr)
64 {
65 throw std::runtime_error("SignalHandler not initialized before use");
66 }
67
68 const auto ret = instance->f_sigint_raised;
70 return ret;
71 }
72
73 private:
82 static void handle_SIGUSR1(int signal) noexcept;
83
91 static void handle_SIGUSR2(int signal) noexcept;
92
93
94 static void handle_SIGINT(int signal) noexcept;
95
100 };
101
102} // namespace Core
103
104#endif //__SIGNAL_HANDLING_HPP__
Manages POSIX signals for the application.
Definition signal_handling.hpp:18
SignalHandler()
Constructor for SignalHandler.
Definition signal_handling.cpp:10
static SignalHandler * instance
Singleton instance of the SignalHandler.
Definition signal_handling.hpp:99
static void handle_SIGINT(int signal) noexcept
Definition signal_handling.cpp:39
bool f_usr2_raised
Definition signal_handling.hpp:98
static bool is_sigint_raised() noexcept(false)
Definition signal_handling.hpp:61
static void handle_SIGUSR2(int signal) noexcept
Handles the SIGUSR2 signal.
Definition signal_handling.cpp:31
bool f_sigint_raised
Definition signal_handling.hpp:96
static void handle_SIGUSR1(int signal) noexcept
Handles the SIGUSR1 signal.
Definition signal_handling.cpp:23
static bool is_usr1_raised() noexcept(false)
Checks if the SIGUSR1 signal has been raised.
Definition signal_handling.hpp:37
static bool is_usr2_raised() noexcept(false)
Definition signal_handling.hpp:49
bool f_usr1_raised
Flag to indicate if the SIGUSR1 signal was triggered.
Definition signal_handling.hpp:97
Core component to perform simulation.
Definition data_exporter.hpp:18