libdap++
Updated for version 3.8.2
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
SignalHandler.h
Go to the documentation of this file.
1
2
// -*- mode: c++; c-basic-offset:4 -*-
3
4
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
5
// Access Protocol.
6
7
// Copyright (c) 2002,2003 OPeNDAP, Inc.
8
// Author: James Gallagher <jgallagher@opendap.org>
9
//
10
// This library is free software; you can redistribute it and/or
11
// modify it under the terms of the GNU Lesser General Public
12
// License as published by the Free Software Foundation; either
13
// version 2.1 of the License, or (at your option) any later version.
14
//
15
// This library is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
// Lesser General Public License for more details.
19
//
20
// You should have received a copy of the GNU Lesser General Public
21
// License along with this library; if not, write to the Free Software
22
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
//
24
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25
26
#ifndef signal_handler_h
27
#define signal_handler_h
28
29
#include <signal.h>
30
31
#include "
EventHandler.h
"
32
#include "
InternalErr.h
"
33
34
namespace
libdap
35
{
36
37
typedef
void
Sigfunc
(
int
);
// Plauger, 1992
38
66
class
SignalHandler
67
{
68
private
:
69
// Ensure we're a Singleton.
70
SignalHandler
()
71
{}
72
73
// Singleton pointer.
74
static
SignalHandler
*d_instance;
75
76
// Table of pointers to instances of EventHandlers. Since EventHandler is
77
// abstract, the pointers will actually reference instances that are
78
// children of EventHandler. NSIG is defined in signal.h but this may be
79
// a portability issue.
80
static
EventHandler
*d_signal_handlers[NSIG];
81
82
// This array holds the old signal handlers. Once the handler in
83
// d_signal_handler[signum] is run, look here to see what the original
84
// action was. This is important since libdap++ is often embedded in code
85
// that already has a non-default signal handler for things like SIGINT.
86
static
Sigfunc
*d_old_handlers[NSIG];
87
88
// Entry point adapter installed into sigaction(). This must be static
89
// method (or a regular C-function) to conform to sigaction's interface.
90
// this is the part of SignalHandler that uses the Adapter pattern.
91
static
void
dispatcher(
int
signum);
92
93
// Delete the global instance. Call this with atexit().
94
static
void
delete_instance();
95
96
// Call this using pthread_once() to ensure there's only one instance
97
// when running in a MT world.
98
static
void
initialize_instance();
99
100
friend
class
SignalHandlerTest
;
101
friend
class
HTTPCacheTest
;
102
103
public
:
104
static
SignalHandler
*
instance
();
105
107
virtual
~SignalHandler
()
108
{}
109
110
EventHandler
*
register_handler
(
int
signum,
EventHandler
*eh,
111
bool
override
=
false
);
112
113
EventHandler
*
remove_handler
(
int
signum);
114
};
115
116
}
// namespace libdap
117
118
#endif // signal_handler_h
SignalHandler.h
Generated by
1.8.3.1