BioCMAMC-ST
Core::SignalHandler Class Reference

Manages POSIX signals for the application. More...

#include <signal_handling.hpp>

Collaboration diagram for Core::SignalHandler:
[legend]

Public Member Functions

 SignalHandler ()
 Constructor for SignalHandler.
 

Static Public Member Functions

static bool is_usr1_raised () noexcept(false)
 Checks if the SIGUSR1 signal has been raised.
 
static bool is_usr2_raised () noexcept(false)
 
static bool is_sigint_raised () noexcept(false)
 

Static Private Member Functions

static void handle_SIGUSR1 (int signal) noexcept
 Handles the SIGUSR1 signal.
 
static void handle_SIGUSR2 (int signal) noexcept
 Handles the SIGUSR2 signal.
 
static void handle_SIGINT (int signal) noexcept
 

Private Attributes

bool f_sigint_raised
 
bool f_usr1_raised
 Flag to indicate if the SIGUSR1 signal was triggered.
 
bool f_usr2_raised
 

Static Private Attributes

static SignalHandlerinstance = nullptr
 Singleton instance of the SignalHandler.
 

Detailed Description

Manages POSIX signals for the application.

Singleton that captures specific POSIX signals (e.g., SIGUSR1 and SIGUSR2) during the runtime of the application. It provides mechanisms to check if signals have been raised and ensures proper cleanup and handling.

Constructor & Destructor Documentation

◆ SignalHandler()

Core::SignalHandler::SignalHandler ( )
explicit

Constructor for SignalHandler.

Sets up the signal handlers for SIGUSR1 and SIGUSR2. Throws a runtime error if more than one instance of SignalHandler is created.

Here is the call graph for this function:

Member Function Documentation

◆ handle_SIGINT()

void Core::SignalHandler::handle_SIGINT ( int signal)
staticprivatenoexcept
Here is the caller graph for this function:

◆ handle_SIGUSR1()

void Core::SignalHandler::handle_SIGUSR1 ( int signal)
staticprivatenoexcept

Handles the SIGUSR1 signal.

This static function is called when the SIGUSR1 signal is raised. It sets the internal flag to indicate the signal was received.

Parameters
signalThe signal number (ignored in this implementation).
Here is the caller graph for this function:

◆ handle_SIGUSR2()

void Core::SignalHandler::handle_SIGUSR2 ( int signal)
staticprivatenoexcept

Handles the SIGUSR2 signal.

This static function is intended to handle the SIGUSR2 signal. (Implementation pending.)

Parameters
signalThe signal number (ignored in this implementation).
Here is the caller graph for this function:

◆ is_sigint_raised()

static bool Core::SignalHandler::is_sigint_raised ( )
inlinestaticnodiscard

◆ is_usr1_raised()

static bool Core::SignalHandler::is_usr1_raised ( )
inlinestaticnodiscard

Checks if the SIGUSR1 signal has been raised.

This function is used to query the state of the SIGUSR1 signal. If the signal has been raised, the function returns true and resets the internal flag to false.

Exceptions
std::runtime_errorIf the SignalHandler instance has not been initialized.
Returns
true if SIGUSR1 was raised since the last query; false otherwise.

◆ is_usr2_raised()

static bool Core::SignalHandler::is_usr2_raised ( )
inlinestaticnodiscard

Member Data Documentation

◆ f_sigint_raised

bool Core::SignalHandler::f_sigint_raised
private

◆ f_usr1_raised

bool Core::SignalHandler::f_usr1_raised
private

Flag to indicate if the SIGUSR1 signal was triggered.

◆ f_usr2_raised

bool Core::SignalHandler::f_usr2_raised
private

◆ instance

SignalHandler * Core::SignalHandler::instance = nullptr
staticprivate

Singleton instance of the SignalHandler.


The documentation for this class was generated from the following files: