libdap  Updated for version 3.20.6
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 <cassert>
32 #include <iostream>
33 #include <algorithm>
34 
35 #include "HTTPCache.h"
36 #include "EventHandler.h"
37 #include "debug.h"
38 
39 namespace libdap
40 {
41 
42 static void
43 unlink_file(const string &f)
44 {
45  unlink(f.c_str());
46 }
47 
58 {
59 private:
60 
61 public:
64  {}
65 
67  virtual ~HTTPCacheInterruptHandler()
68  {}
69 
77  virtual void handle_signal(int signum)
78  {
79  assert(signum == SIGINT);
80  DBG(cerr << "Inside the HTTPCacheInterruptHandler." << endl);
81 
82  vector<string> *of = &HTTPCache::_instance->d_open_files;
83 
84  DBG(copy(of->begin(), of->end(),
85  ostream_iterator<string>(cerr, "\n")));
86 
87  for_each(of->begin(), of->end(), unlink_file);
88 
89  HTTPCache::delete_instance();
90  }
91 };
92 
93 } // namespace libdap
94 
95 #endif // http_cache_interrupt_handler_h
top level DAP object to house generic methods
Definition: AISConnect.cc:30