bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESCatalogUtils.h
1// BESCatalogUtils.h
2
3// This file is part of bes, A C++ back-end server implementation framework
4// for the OPeNDAP Data Access Protocol.
5
6// Copyright (c) 2004-2009 University Corporation for Atmospheric Research
7// Author: Patrick West <pwest@ucar.edu> and Jose Garcia <jgarcia@ucar.edu>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22//
23// You can contact University Corporation for Atmospheric Research at
24// 3080 Center Green Drive, Boulder, CO 80301
25
26// (c) COPYRIGHT University Corporation for Atmospheric Research 2004-2005
27// Please read the full copyright statement in the file COPYRIGHT_UCAR.
28//
29// Authors:
30// pwest Patrick West <pwest@ucar.edu>
31// jgarcia Jose Garcia <jgarcia@ucar.edu>
32
33#ifndef S_BESCatalogUtils_h
34#define S_BESCatalogUtils_h 1
35
36#include <sys/types.h>
37#include <sys/stat.h>
38#include <dirent.h>
39
40#include <map>
41#include <vector>
42#include <list>
43#include <string>
44
45#include "BESObj.h"
46#include "BESUtil.h"
47
48class BESInfo;
49class BESCatalogEntry;
50
51#if 0
52// Refactored the 'singleton list of CatalogUtils out/ jhrg 7/27/18
53
54// This seems odd - to have a singleton that is actually a map of
55// instances and have that a member of (each of?) the instances...
56// I think this should be a member of a catalog, not a singleton with
57// a list of classes. jhrg 2.25.18
58#endif
59
60
61class BESCatalogUtils: public BESObj {
62private:
63#if 0
64 static std::map<std::string, BESCatalogUtils *> _instances;
65#endif
66
67 std::string d_name;
68 std::string d_root_dir;
69 std::list<std::string> d_exclude;
70 std::list<std::string> d_include;
71 bool d_follow_syms;
72
75 struct handler_regex {
76 std::string handler;
77 std::string regex;
78 };
79
80 std::vector<handler_regex> d_match_list;
81
82 typedef std::vector<handler_regex>::const_iterator match_citer;
83 BESCatalogUtils::match_citer match_list_begin() const;
84 BESCatalogUtils::match_citer match_list_end() const;
85
86 BESCatalogUtils():d_follow_syms(false) {}
87
88 static void bes_add_stat_info(BESCatalogEntry *entry, struct stat &buf);
89
90public:
91 BESCatalogUtils(const std::string &name, bool strict = true);
92
93 virtual ~BESCatalogUtils()
94 {
95 }
96
102 const std::string & get_root_dir() const
103 {
104 return d_root_dir;
105 }
106
107 bool follow_sym_links() const
108 {
109 return d_follow_syms;
110 }
111
112 virtual bool include(const std::string &inQuestion) const;
113 virtual bool exclude(const std::string &inQuestion) const;
114
115 std::string get_handler_name(const std::string &item) const;
116 bool is_data(const std::string &item) const;
117
118 // TODO remove these once we no longer need showCatalog. jhrg 7/27/18
119#if 1
120 virtual unsigned int get_entries(DIR *dip, const std::string &fullnode, const std::string &use_node,
121 BESCatalogEntry *entry, bool dirs_only);
122
123 static void display_entry(BESCatalogEntry *entry, BESInfo *info);
124
125 static void bes_add_stat_info(BESCatalogEntry *entry, const std::string &fullnode);
126
127 static bool isData(const std::string &inQuestion, const std::string &catalog, std::list<std::string> &services);
128#endif
129
130 virtual void dump(std::ostream &strm) const;
131
132#if 0
133 static BESCatalogUtils * Utils(const std::string &name);
134#endif
135
136
137#if 0
138 // Added because of reported memory leaks. jhrg 12/24/12
139 static void delete_all_catalogs();
140#endif
141
142};
143
144#endif // S_BESCatalogUtils_h
const std::string & get_root_dir() const
Get the root directory of the catalog.
virtual bool exclude(const std::string &inQuestion) const
Should this file/directory be excluded in the catalog?
virtual unsigned int get_entries(DIR *dip, const std::string &fullnode, const std::string &use_node, BESCatalogEntry *entry, bool dirs_only)
virtual bool include(const std::string &inQuestion) const
Should this file/directory be included in the catalog?
std::string get_handler_name(const std::string &item) const
Find the handler name that will process.
bool is_data(const std::string &item) const
is there a handler that can process this
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
informational response object
Definition BESInfo.h:63
top level BES object to house generic methods
Definition BESObj.h:54