bes  Updated for version 3.20.6
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 
42 class BESCatalog;
43 class 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 
84 class BESCatalogList: public BESObj {
85 private:
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 
101 public:
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 
BESCatalogList::num_catalogs
virtual int num_catalogs() const
The number of non-default catalogs.
Definition: BESCatalogList.h:112
BESCatalogList::~BESCatalogList
virtual ~BESCatalogList()
list destructor deletes all registered catalogs
Definition: BESCatalogList.cc:138
BESCatalogList::end_catalog
virtual catalog_citer end_catalog() const
Iterator to the last catalog.
Definition: BESCatalogList.h:133
BESCatalogList::BESCatalogList
BESCatalogList()
construct a catalog list
Definition: BESCatalogList.cc:114
BESCatalogList::default_catalog
virtual BESCatalog * default_catalog() const
The the default catalog.
Definition: BESCatalogList.h:118
BESCatalogList::TheCatalogList
static BESCatalogList * TheCatalogList()
Get the singleton BESCatalogList instance.
Definition: BESCatalogList.cc:81
BESCatalogList
List of all registered catalogs.
Definition: BESCatalogList.h:84
BESObj
top level BES object to house generic methods
Definition: BESObj.h:49
BESCatalogList::add_catalog
virtual bool add_catalog(BESCatalog *catalog)
adds the specified catalog to the list
Definition: BESCatalogList.cc:162
BESCatalogEntry
Definition: BESCatalogEntry.h:46
BESCatalog
Catalogs provide a hierarchical organization for data.
Definition: BESCatalog.h:51
BESCatalogList::default_catalog_name
virtual std::string default_catalog_name() const
The name of the default catalog.
Definition: BESCatalogList.h:116
BESCatalogList::first_catalog
virtual catalog_citer first_catalog() const
Iterator to the first catalog.
Definition: BESCatalogList.h:130
BESCatalogList::dump
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream