--- smsdaemon/serialport/PosixSignalDispatcher.h 2008/12/18 06:47:26 195 +++ smsdaemon/serialport/PosixSignalDispatcher.h 2008/12/18 06:53:29 196 @@ -33,104 +33,104 @@ class PosixSignalDispatcher { public: - /** - * 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. - */ - static PosixSignalDispatcher& Instance() ; - - /** - * Exception thrown when AttachHandler() fails due to a runtime - * error. - */ - class CannotAttachHandler : public std::runtime_error - { - public: - CannotAttachHandler( const std::string& whatArg ) : - runtime_error(whatArg) { } - } ; - - /** - * Exception thrown when DetachHandler() fails due to a runtime - * error. - */ - class CannotDetachHandler : public std::runtime_error - { - public: - CannotDetachHandler( const std::string& whatArg ) : - runtime_error(whatArg) { } - } ; - - /** - * 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. - * - * @param posixSignalNumber The signal number that will result in - * call to the HandlePosixSignal() method of the signal handler. - * - * @param signalHandler The signal handler to be invoked on receiving - * a posixSignalNumber signal. - */ - void AttachHandler( const int posixSignalNumber, - PosixSignalHandler& signalHandler ) - throw( CannotAttachHandler ) ; - - /** - * 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. - * - * @param posixSignalNumber The signal number corresponding to - * the signal handler. - * - * @param signalHandler The signal handler to be detached. - */ - void DetachHandler( const int posixSignalNumber, - const PosixSignalHandler& signalHandler ) - throw( CannotDetachHandler, - std::logic_error ) ; + /** + * 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. + */ + static PosixSignalDispatcher& Instance() ; + + /** + * Exception thrown when AttachHandler() fails due to a runtime + * error. + */ + class CannotAttachHandler : public std::runtime_error + { + public: + CannotAttachHandler( const std::string& whatArg ) : + runtime_error(whatArg) { } + } ; + + /** + * Exception thrown when DetachHandler() fails due to a runtime + * error. + */ + class CannotDetachHandler : public std::runtime_error + { + public: + CannotDetachHandler( const std::string& whatArg ) : + runtime_error(whatArg) { } + } ; + + /** + * 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. + * + * @param posixSignalNumber The signal number that will result in + * call to the HandlePosixSignal() method of the signal handler. + * + * @param signalHandler The signal handler to be invoked on receiving + * a posixSignalNumber signal. + */ + void AttachHandler( const int posixSignalNumber, + PosixSignalHandler& signalHandler ) + throw( CannotAttachHandler ) ; + + /** + * 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. + * + * @param posixSignalNumber The signal number corresponding to + * the signal handler. + * + * @param signalHandler The signal handler to be detached. + */ + void DetachHandler( const int posixSignalNumber, + const PosixSignalHandler& signalHandler ) + throw( CannotDetachHandler, + std::logic_error ) ; 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() ; - - /** - * This class cannot be subclassed. We enforce this by making - * the destructor a private member. - */ - ~PosixSignalDispatcher() ; - - /** - * Copying of an instance of this class is not allowed. We - * enforce this by making the copy constructor and the - * assignment operator private members. - */ - PosixSignalDispatcher( const PosixSignalDispatcher& otherInstance ) ; - - /** - * Copying of an instance of this class is not allowed. We - * enforce this by making the copy constructor and the - * assignment operator private members. - */ - const PosixSignalDispatcher& - operator=( const PosixSignalDispatcher& otherInstance ) ; + /** + * 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() ; + + /** + * This class cannot be subclassed. We enforce this by making + * the destructor a private member. + */ + ~PosixSignalDispatcher() ; + + /** + * Copying of an instance of this class is not allowed. We + * enforce this by making the copy constructor and the + * assignment operator private members. + */ + PosixSignalDispatcher( const PosixSignalDispatcher& otherInstance ) ; + + /** + * Copying of an instance of this class is not allowed. We + * enforce this by making the copy constructor and the + * assignment operator private members. + */ + const PosixSignalDispatcher& + operator=( const PosixSignalDispatcher& otherInstance ) ; } ; #endif