bes  Updated for version 3.20.8
EffectiveUrlCache.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of the BES http package, part of the Hyrax data server.
4 
5 // Copyright (c) 2020 OPeNDAP, Inc.
6 // Author: Nathan Potter <ndp@opendap.org>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 //
22 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
23 
24 // Authors:
25 // ndp Nathan Potter <ndp@opendap.org>
26 
27 #ifndef _bes_http_EffectiveUrlCache_h_
28 #define _bes_http_EffectiveUrlCache_h_ 1
29 
30 #include <map>
31 #include <string>
32 
33 #include <pthread.h>
34 
35 #include "BESObj.h"
36 #include "BESDataHandlerInterface.h"
37 #include "BESRegex.h"
38 #include "EffectiveUrl.h"
39 
40 
41 namespace http {
42 
46 class EucLock {
47 private:
48  pthread_mutex_t &m_mutex;
49  EucLock();
50  EucLock(const EucLock &rhs);
51 public:
52  EucLock(pthread_mutex_t &lock);
53  ~EucLock();
54 };
55 
56 
60 class EffectiveUrlCache: public BESObj {
61 private:
62  static EffectiveUrlCache * d_instance;
63  static pthread_once_t d_init_control;
64 
65  std::map<std::string , http::EffectiveUrl *> d_effective_urls;
66  pthread_mutex_t d_get_effective_url_cache_mutex;
67 
68  // Things that match get skipped.
69  BESRegex *d_skip_regex;
70 
71  int d_enabled;
72 
73  static void initialize_instance();
74  static void delete_instance();
75 
76  friend class EffectiveUrlCacheTest;
77  http::EffectiveUrl *get(const std::string &source_url);
78  BESRegex *get_skip_regex();
79  bool is_enabled();
80 
82 
83  virtual ~EffectiveUrlCache();
84 
85 public:
86 
87  static EffectiveUrlCache *TheCache();
88 
89  std::string get_effective_url(const std::string &source_url);
90 
91  virtual void dump(std::ostream &strm) const;
92  virtual std::string dump() const;
93 
94 };
95 
96 } // namespace http
97 
98 #endif // BES_http_EffectiveUrlCache_h_
99 
top level BES object to house generic methods
Definition: BESObj.h:50
static EffectiveUrlCache * TheCache()
Get the singleton BESCatalogList instance.
std::string get_effective_url(const std::string &source_url)
virtual std::string dump() const
dumps information about this object
utility class for the HTTP catalog module
Definition: EffectiveUrl.cc:58