PosixSignalDispatcher

Langue: en

Autres versions - même langue

Version: 340933 (ubuntu - 24/10/10)

Section: 3 (Bibliothèques de fonctions)

NAME

PosixSignalDispatcher -

SYNOPSIS


#include <PosixSignalDispatcher.h>

Classes


class CannotAttachHandler
Exception thrown when AttachHandler() fails due to a runtime error.
class CannotDetachHandler
Exception thrown when DetachHandler() fails due to a runtime error.

Public Member Functions


void AttachHandler (const int posixSignalNumber, PosixSignalHandler &signalHandler) throw ( CannotAttachHandler )
Attach a signal handler to the signal dispatcher.
void DetachHandler (const int posixSignalNumber, const PosixSignalHandler &signalHandler) throw ( CannotDetachHandler, std::logic_error )
Detach the specified signal handler from the signal dispatcher.

Static Public Member Functions


static PosixSignalDispatcher & Instance ()
This is a singleton class and there is only one instance of this class per process.

Private Member Functions


PosixSignalDispatcher ()
This is a singleton class and the only instances of this class can only be accessed using the Instance() method.
~PosixSignalDispatcher ()
This class cannot be subclassed.
PosixSignalDispatcher (const PosixSignalDispatcher &otherInstance)
Copying of an instance of this class is not allowed.
const PosixSignalDispatcher & operator= (const PosixSignalDispatcher &otherInstance)
Copying of an instance of this class is not allowed.

Detailed Description

Note:

The signal dispatcher will not interfere with any signals for which there are no signal handlers attached. Similarly, if a signal handler function is already attached to a signal that the dispatcher is asked to administer, that signal handler will be called after all the attached PosixSignalHandlers.

Todo

Make this a singleton class.

Definition at line 33 of file PosixSignalDispatcher.h.

Constructor & Destructor Documentation

PosixSignalDispatcher::PosixSignalDispatcher () [private]

This is a singleton class and the only instances of this class can only be accessed using the Instance() method. This is enforced by making the default constructor a private member disalloweing construction of new instances of this class

PosixSignalDispatcher::~PosixSignalDispatcher () [private]

This class cannot be subclassed. We enforce this by making the destructor a private member.

PosixSignalDispatcher::PosixSignalDispatcher (const PosixSignalDispatcher & otherInstance) [private]

Copying of an instance of this class is not allowed. We enforce this by making the copy constructor and the assignment operator private members.

Member Function Documentation

void PosixSignalDispatcher::AttachHandler (const int posixSignalNumber, PosixSignalHandler & signalHandler) throw ( CannotAttachHandler )

Attach a signal handler to the signal dispatcher. The signal handler's HandlePosixSignal() method will be called every time the specified signal is received. The signal handler should not be destroyed while it attached to the signal dispatcher. Otherwise, weird things are bound to happen (i.e. 'undefined
 behavior' shall ensue). Make sure you call DetachHandler() from the destructor of the signal handler.

If a PosixSignalHandler is attached to the same signal number multiple times, it will be called multiple times. Furthermore, it should also be detached as many times as it was attached before it is destroyed. Otherwise, undefined behavior may result.

Parameters:

posixSignalNumber The signal number that will result in call to the HandlePosixSignal() method of the signal handler.
signalHandler The signal handler to be invoked on receiving a posixSignalNumber signal.

void PosixSignalDispatcher::DetachHandler (const int posixSignalNumber, const PosixSignalHandler & signalHandler) throw ( CannotDetachHandler, std::logic_error )

Detach the specified signal handler from the signal dispatcher. The signal handler will stop being called on receiving the corresponding POSIX signal. If the signal handler is not attached to the signal dispatcher when this method is called then this method has no effect.

Parameters:

posixSignalNumber The signal number corresponding to the signal handler.
signalHandler The signal handler to be detached.

static PosixSignalDispatcher& PosixSignalDispatcher::Instance () [static]

This is a singleton class and there is only one instance of this class per process. This instance can be obtained using the GetInstance() method.

const PosixSignalDispatcher& PosixSignalDispatcher::operator= (const PosixSignalDispatcher & otherInstance) [private]

Copying of an instance of this class is not allowed. We enforce this by making the copy constructor and the assignment operator private members.

Author

Generated automatically by Doxygen for libserial from the source code.