libassa  3.5.1
SigHandler.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 //------------------------------------------------------------------------------
3 // SigHandler.h
4 //------------------------------------------------------------------------------
5 // Copyright (c) 1997 by Vladislav Grinchenko
6 //
7 // This library is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU Library General Public
9 // License as published by the Free Software Foundation; either
10 // version 2 of the License, or (at your option) any later version.
11 //------------------------------------------------------------------------------
12 #ifndef _SigHandler_h
13 #define _SigHandler_h
14 
15 // System includes
16 
17 #include <signal.h>
18 #include <errno.h>
19 
20 #include "assa/Logger.h"
21 #include "assa/IdSet.h"
22 #include "assa/SigSet.h"
23 #include "assa/SigAction.h"
24 #include "assa/EventHandler.h"
25 
26 namespace ASSA {
27 
28 #if !defined(WIN32)
29 
50 {
51 public:
54  virtual ~SigHandler () { /* no-op */ }
55 
71  virtual int install (int signum_,
72  EventHandler* new_hand_,
73  SigAction* new_disp_ = 0,
74  EventHandler** old_hand_ = 0,
75  SigAction* old_disp_ = 0);
76 
89  virtual int remove (int signum_,
90  EventHandler* eh_ = 0,
91  SigAction* new_disp_ = 0,
92  SigAction* old_disp_ = 0);
93 
103  static void dispatch (int signum_);
104 
111  EventHandler* handler (int signum_, EventHandler* new_);
112 
115  EventHandler* handler (int signum_);
116 
117 protected:
121  int in_range(int signum_);
122 
123 private:
128 };
129 
130 #endif // !defined(WIN32)
131 
132 } // end namespace ASSA
133 
134 #endif /* _SigHandler_h */
An abstract interface for handling I/O events, timers, and such.
Class IdSet implements a set of reusable unique IDs, up to 1024.
An abstraction to message logging facility.
SigAction is a C++ wrapper around sigaction structure.
SigSet is a wrapper for UNIX sigset_t structure that provides all manipulators on this structure as w...
EventHandler class.
Definition: EventHandler.h:103
static EventHandler * m_signal_handlers[NSIG]
Static array that stores one user-defined event handler pointer for every signal.
Definition: SigHandler.h:127
virtual int remove(int signum_, EventHandler *eh_=0, SigAction *new_disp_=0, SigAction *old_disp_=0)
Remove EventHandler associated with signum_.
Definition: SigHandler.cpp:107
virtual ~SigHandler()
No-op virtual destructor.
Definition: SigHandler.h:54
static void dispatch(int signum_)
Here is the heart of SigHandler class.
Definition: SigHandler.cpp:130
int in_range(int signum_)
Check that signum_ is in valid range.
Definition: SigHandler.cpp:27
EventHandler * handler(int signum_, EventHandler *new_)
Set new event handler for signal signum_ and return an existing one.
Definition: SigHandler.cpp:42
virtual int install(int signum_, EventHandler *new_hand_, SigAction *new_disp_=0, EventHandler **old_hand_=0, SigAction *old_disp_=0)
Add new signal handler and new disposition for the signal.
Definition: SigHandler.cpp:70
Definition: Acceptor.h:40