libserial  0.6.0rc3
PosixSignalDispatcher.h
Go to the documentation of this file.
1 //
2 // C++ Interface: %{MODULE}
3 //
4 // Description:
5 //
6 //
7 // Author: %{AUTHOR} <%{EMAIL}>, (C) %{YEAR}
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 #ifndef _PosixSignalDispatcher_h_
13 #define _PosixSignalDispatcher_h_
14 
15 #include <stdexcept>
16 
17 /*
18  * Forward declarations.
19  */
20 class PosixSignalHandler ;
21 
34 {
35 public:
42 
47  class CannotAttachHandler : public std::runtime_error
48  {
49  public:
50  CannotAttachHandler( const std::string& whatArg ) :
51  runtime_error(whatArg) { }
52  } ;
53 
58  class CannotDetachHandler : public std::runtime_error
59  {
60  public:
61  CannotDetachHandler( const std::string& whatArg ) :
62  runtime_error(whatArg) { }
63  } ;
64 
85  void AttachHandler( const int posixSignalNumber,
86  PosixSignalHandler& signalHandler )
87  throw( CannotAttachHandler ) ;
88 
101  void DetachHandler( const int posixSignalNumber,
102  const PosixSignalHandler& signalHandler )
103  throw( CannotDetachHandler,
104  std::logic_error ) ;
105 private:
113 
119 
125  PosixSignalDispatcher( const PosixSignalDispatcher& otherInstance ) ;
126 
132  const PosixSignalDispatcher&
133  operator=( const PosixSignalDispatcher& otherInstance ) ;
134 } ;
135 
136 #endif
Gets a method called when the corresponding signal is received.
void DetachHandler(const int posixSignalNumber, const PosixSignalHandler &signalHandler)
Detach the specified signal handler from the signal dispatcher.
Exception thrown when DetachHandler() fails due to a runtime error.
Exception thrown when AttachHandler() fails due to a runtime error.
static PosixSignalDispatcher & Instance()
This is a singleton class and there is only one instance of this class per process.
PosixSignalDispatcher()
This is a singleton class and the only instances of this class can only be accessed using the Instanc...
const PosixSignalDispatcher & operator=(const PosixSignalDispatcher &otherInstance)
Copying of an instance of this class is not allowed.
void AttachHandler(const int posixSignalNumber, PosixSignalHandler &signalHandler)
Attach a signal handler to the signal dispatcher.
~PosixSignalDispatcher()
This class cannot be subclassed.