bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
BESCatalogList.h
1// BESCatalogList.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 BESCatalogList_h_
34#define BESCatalogList_h_ 1
35
36#include <map>
37#include <string>
38
39#include "BESObj.h"
40#include "BESDataHandlerInterface.h"
41
42class BESCatalog;
43class BESCatalogEntry;
44
45#define BES_DEFAULT_CATALOG "catalog"
46
47// TODO Oddly, users of this class must register the default catalog
48// just like any other catalog. I think this is a design bug - since
49// the default is _required_ it should be registered by the BESCatalogList
50// constructor. If that change is made, then handlers that call add_catlog()
51// and ref_catalog() should be examined and all those that do so should be
52// modified.
53//
54// One way to make this change and not leave the whole ref/deref model
55// looking odd would be to make a single BESCatalog instance that is
56// the default catalog and have that be separate from the list of added
57// catalogs. jhrg 2.25.18
58
59
84class BESCatalogList: public BESObj {
85private:
86 std::map<std::string, BESCatalog *> d_catalogs;
87
88 // Record the default catalog name and hold a pointer to the object.
89 // The BESCatalog* should also be in the d_catalogs map (above) so
90 // that clients which search for it will find it that way.
91 std::string d_default_catalog_name;
92 BESCatalog *d_default_catalog;
93
94 static BESCatalogList * d_instance;
95
96 static void initialize_instance(); // originally used with pthread_once(). jhrg 7/22/18
97 static void delete_instance();
98
99 friend class BESCatalogListTest;
100
101public:
102 typedef std::map<std::string, BESCatalog *>::iterator catalog_iter;
103 typedef std::map<std::string, BESCatalog *>::const_iterator catalog_citer;
104
105 static BESCatalogList * TheCatalogList();
106
107 BESCatalogList();
108 virtual ~BESCatalogList();
109
112 virtual int num_catalogs() const { return d_catalogs.size(); }
113 virtual int empty() const { return d_catalogs.empty(); }
114
116 virtual std::string default_catalog_name() const { return d_default_catalog_name; }
118 virtual BESCatalog *default_catalog() const { return d_default_catalog; }
119
120 virtual bool add_catalog(BESCatalog *catalog);
121 virtual bool ref_catalog(const std::string &catalog_name);
122 virtual bool deref_catalog(const std::string &catalog_name);
123
124 virtual BESCatalog * find_catalog(const std::string &catalog_name) const;
125
126 // TODO Remove this ASAP. jhrg 7/22/18
127 virtual BESCatalogEntry * show_catalogs(BESCatalogEntry *entry, bool show_default = true);
128
130 virtual catalog_citer first_catalog() const { return d_catalogs.begin(); }
131
133 virtual catalog_citer end_catalog() const { return d_catalogs.end(); }
134
135 virtual void dump(std::ostream &strm) const;
136};
137
138#endif // BESCatalogList_h_
139
virtual BESCatalog * default_catalog() const
The the default catalog.
virtual std::string default_catalog_name() const
The name of the default catalog.
virtual int num_catalogs() const
The number of non-default catalogs.
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
virtual catalog_citer end_catalog() const
Iterator to the last catalog.
virtual catalog_citer first_catalog() const
Iterator to the first catalog.
Catalogs provide a hierarchical organization for data.
Definition BESCatalog.h:51
top level BES object to house generic methods
Definition BESObj.h:54