43 #include "BESCatalogList.h"
44 #include "BESCatalog.h"
45 #include "BESCatalogDirectory.h"
46 #include "BESCatalogEntry.h"
49 #include "BESSyntaxUserError.h"
50 #include "TheBESKeys.h"
56 static pthread_once_t BESCatalogList_instance_control = PTHREAD_ONCE_INIT;
83 if (d_instance == 0) initialize_instance();
92 void BESCatalogList::initialize_instance()
96 atexit(delete_instance);
104 void BESCatalogList::delete_instance()
117 string key =
"BES.Catalog.Default";
125 if (!found || d_default_catalog_name.empty()) {
126 d_default_catalog_name = BES_DEFAULT_CATALOG;
131 add_catalog(d_default_catalog);
140 catalog_iter i = d_catalogs.begin();
141 catalog_iter e = d_catalogs.end();
142 for (; i != e; i++) {
172 pair<const string, BESCatalog*> p = make_pair(name, catalog);
173 result = d_catalogs.insert(p).second;
219 bool BESCatalogList::ref_catalog(
const string &catalog_name)
223 BESCatalogList::catalog_iter i;
224 i = d_catalogs.find(catalog_name);
225 if (i != d_catalogs.end()) {
250 bool BESCatalogList::deref_catalog(
const string &catalog_name)
254 BESCatalogList::catalog_iter i;
255 i = d_catalogs.find(catalog_name);
256 if (i != d_catalogs.end()) {
274 BESCatalogList::find_catalog(
const string &catalog_name)
const
276 BESCatalogList::catalog_citer i = d_catalogs.find(catalog_name);
277 if (i != d_catalogs.end()) {
312 BESCatalogList::show_catalogs(
BESCatalogEntry *entry,
bool show_default)
318 catalog_citer i = d_catalogs.begin();
319 catalog_citer e = d_catalogs.end();
320 for (; i != e; i++) {
324 if (show_default || (*i).first != default_catalog_name()) {
342 strm << BESIndent::LMarg <<
"BESCatalogList::dump - (" << (
void *)
this <<
")" << endl;
344 strm << BESIndent::LMarg <<
"default catalog: " << d_default_catalog_name << endl;
345 if (d_catalogs.size()) {
346 strm << BESIndent::LMarg <<
"catalog list:" << endl;
348 catalog_citer i = d_catalogs.begin();
349 catalog_citer e = d_catalogs.end();
350 for (; i != e; i++) {
352 strm << BESIndent::LMarg << (*i).first << catalog << endl;
354 BESIndent::UnIndent();
357 strm << BESIndent::LMarg <<
"catalog list: empty" << endl;
359 BESIndent::UnIndent();
Catalogs from a directory structure.
List of all registered catalogs.
BESCatalogList()
construct a catalog list
virtual bool add_catalog(BESCatalog *catalog)
adds the specified catalog to the list
virtual ~BESCatalogList()
list destructor deletes all registered catalogs
static BESCatalogList * TheCatalogList()
Get the singleton BESCatalogList instance.
virtual void dump(std::ostream &strm) const
dump the contents of this object to the specified ostream
Catalogs provide a hierarchical organization for data.
virtual unsigned int dereference_catalog()
Decrement the count of clients that reference this catalog.
virtual BESCatalogEntry * show_catalog(const std::string &container, BESCatalogEntry *entry)=0
virtual std::string get_catalog_name() const
Get the name for this catalog.
virtual void reference_catalog()
Increase the count of clients that reference this catalog.
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()