libdap Updated for version 3.21.0
libdap4 is an implementation of OPeNDAP's DAP protocol.
HTTPCacheInterruptHandler.h
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 http_cache_interrupt_handler_h
27#define http_cache_interrupt_handler_h
28
29#include <signal.h>
30
31#include <algorithm>
32#include <cassert>
33#include <iostream>
34
35#include "EventHandler.h"
36#include "HTTPCache.h"
37#include "debug.h"
38
39namespace libdap {
40
41static void unlink_file(const string &f) { unlink(f.c_str()); }
42
52class HTTPCacheInterruptHandler : public EventHandler {
53private:
54public:
56 HTTPCacheInterruptHandler() {}
57
59 virtual ~HTTPCacheInterruptHandler() {}
60
68 virtual void handle_signal(int signum) {
69 assert(signum == SIGINT);
70 DBG(cerr << "Inside the HTTPCacheInterruptHandler." << endl);
71
72 vector<string> *of = &HTTPCache::_instance->d_open_files;
73
74 DBG(copy(of->begin(), of->end(), ostream_iterator<string>(cerr, "\n")));
75
76 for_each(of->begin(), of->end(), unlink_file);
77
78 HTTPCache::delete_instance();
79 }
80};
81
82} // namespace libdap
83
84#endif // http_cache_interrupt_handler_h
top level DAP object to house generic methods
Definition AISConnect.cc:30