00001 // 00002 // C++ Interface: %{MODULE} 00003 // 00004 // Description: 00005 // 00006 // 00007 // Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR} 00008 // 00009 // Copyright: See COPYING file that comes with this distribution 00010 // 00011 // 00012 #ifndef _PosixSignalDispatcher_h_ 00013 #define _PosixSignalDispatcher_h_ 00014 00015 #include <stdexcept> 00016 00017 /* 00018 * Forward declarations. 00019 */ 00020 class PosixSignalHandler ; 00021 00033 class PosixSignalDispatcher 00034 { 00035 public: 00041 static PosixSignalDispatcher& Instance() ; 00042 00047 class CannotAttachHandler : public std::runtime_error 00048 { 00049 public: 00050 CannotAttachHandler( const std::string& whatArg ) : 00051 runtime_error(whatArg) { }} 00052 ; 00053 00058 class CannotDetachHandler : public std::runtime_error 00059 { 00060 public: 00061 CannotDetachHandler( const std::string& whatArg ) : 00062 runtime_error(whatArg) { }} 00063 ; 00064 00085 void AttachHandler( const int posixSignalNumber, 00086 PosixSignalHandler& signalHandler ) 00087 throw( CannotAttachHandler ) ; 00088 00101 void DetachHandler( const int posixSignalNumber, 00102 const PosixSignalHandler& signalHandler ) 00103 throw( CannotDetachHandler, 00104 std::logic_error ) ; 00105 private: 00112 PosixSignalDispatcher() ; 00113 00118 ~PosixSignalDispatcher() ; 00119 00125 PosixSignalDispatcher( const PosixSignalDispatcher& otherInstance ) ; 00126 00132 const PosixSignalDispatcher& 00133 operator=( const PosixSignalDispatcher& otherInstance ) ; 00134 }; 00135 00136 #endif