libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 <csignal>
30#include <vector>
31
32#include "EventHandler.h"
33#include "InternalErr.h"
34
35namespace libdap {
36
37typedef void Sigfunc(int); // Plauger, 1992
38
67private:
68 // Table of pointers to instances of EventHandlers. Since EventHandler is
69 // abstract, the pointers will actually reference instances that are
70 // children of EventHandler. NSIG is defined in signal.h but this may be
71 // a portability issue. This has to be static because it is used by a
72 // static method.
73 static std::vector<EventHandler *> d_signal_handlers;
74
75 // This array holds the old signal handlers. Once the handler in
76 // d_signal_handler[signum] is run, look here to see what the original
77 // action was. This is important since libdap++ is often embedded in code
78 // that already has a non-default signal handler for things like SIGINT.
79 static std::vector<Sigfunc *> d_old_handlers;
80
81 // Entry point adapter installed into sigaction(). This must be a static
82 // method (or a regular C-function) to conform to sigaction's interface.
83 // this is the part of SignalHandler that uses the Adapter pattern.
84 static void dispatcher(int signum);
85
86 friend class SignalHandlerTest;
87
88 friend class HTTPCacheTest;
89
90public:
91 SignalHandler() = default;
92
93 SignalHandler(const SignalHandler &) = delete;
97
98 static SignalHandler *instance();
99
100 virtual ~SignalHandler() = default;
101
102 static EventHandler *register_handler(int signum, EventHandler *eh, bool ignore_by_default = false);
103
104 static EventHandler *remove_handler(int signum);
105};
106
107} // namespace libdap
108
109#endif // signal_handler_h
SignalHandler & operator=(SignalHandler &&)=delete
static EventHandler * register_handler(int signum, EventHandler *eh, bool ignore_by_default=false)
friend class SignalHandlerTest
SignalHandler(SignalHandler &&)=delete
friend class HTTPCacheTest
static SignalHandler * instance()
virtual ~SignalHandler()=default
SignalHandler(const SignalHandler &)=delete
static EventHandler * remove_handler(int signum)
SignalHandler & operator=(const SignalHandler &)=delete
top level DAP object to house generic methods
Definition AISConnect.cc:30
void Sigfunc(int)