43 using std::ostringstream;
45 #include "BESCatalogList.h" 46 #include "BESCatalog.h" 47 #include "BESCatalogEntry.h" 49 #include "BESSyntaxUserError.h" 50 #include "TheBESKeys.h" 53 static pthread_once_t BESCatalogList_instance_control = PTHREAD_ONCE_INIT;
62 pthread_once(&BESCatalogList_instance_control, initialize_instance);
69 void BESCatalogList::initialize_instance() {
73 atexit(delete_instance);
81 void BESCatalogList::delete_instance() {
92 string key =
"BES.Catalog.Default";
99 if (!found || _default_catalog.empty()) {
100 _default_catalog = BES_DEFAULT_CATALOG;
108 BESCatalogList::~BESCatalogList() {
109 catalog_iter i = _catalogs.begin();
110 catalog_iter e = _catalogs.end();
111 for (; i != e; i++) {
113 if (catalog)
delete catalog;
129 _catalogs[catalog->get_catalog_name()] = catalog;
131 string name = catalog->get_catalog_name();
132 std::pair<const std::string, BESCatalog*> p = std::make_pair(name, catalog);
133 result = _catalogs.insert(p).second;
155 BESCatalogList::catalog_iter i;
156 i = _catalogs.find(catalog_name);
157 if (i != _catalogs.end()) {
159 cat->reference_catalog();
179 BESCatalogList::catalog_iter i;
180 i = _catalogs.find(catalog_name);
181 if (i != _catalogs.end()) {
183 if (!cat->dereference_catalog()) {
201 BESCatalogList::catalog_citer i;
202 i = _catalogs.find(catalog_name);
203 if (i != _catalogs.end()) {
227 catalog_citer i = _catalogs.begin();
228 catalog_citer e = _catalogs.end();
229 for (; i != e; i++) {
233 if (show_default || (*i).first != default_catalog()) {
235 catalog->show_catalog(
"", SHOW_INFO_RESPONSE, myentry);
250 strm << BESIndent::LMarg <<
"BESCatalogList::dump - (" << (
void *)
this <<
")" << endl;
252 strm << BESIndent::LMarg <<
"default catalog: " << _default_catalog << endl;
253 if (_catalogs.size()) {
254 strm << BESIndent::LMarg <<
"catalog list:" << endl;
256 catalog_citer i = _catalogs.begin();
257 catalog_citer e = _catalogs.end();
258 for (; i != e; i++) {
260 strm << BESIndent::LMarg << (*i).first << catalog << endl;
262 BESIndent::UnIndent();
265 strm << BESIndent::LMarg <<
"catalog list: empty" << endl;
267 BESIndent::UnIndent();
virtual BESCatalog * find_catalog(const string &catalog_name)
find the catalog in the list with the specified name
virtual bool add_catalog(BESCatalog *catalog)
adds the speciifed catalog to the list
virtual BESCatalogEntry * show_catalogs(BESDataHandlerInterface &dhi, BESCatalogEntry *entry, bool show_default=true)
show the list of catalogs
virtual void dump(ostream &strm) const
dumps information about this object
void get_value(const string &s, string &val, bool &found)
Retrieve the value of a given key, if set.
virtual bool ref_catalog(const string &catalog_name)
reference the specified catalog
List of all registered catalogs.
Abstract exception class for the BES with basic string message.
static TheBESKeys * TheKeys()
virtual bool deref_catalog(const string &catalog_name)
de-reference the specified catalog and remove from list if no longer referenced
BESCatalogList()
construct a catalog list
abstract base class catalog object. Derived classes know how to show nodes and leaves in a catalog...
Structure storing information used by the BES to handle the request.
static BESCatalogList * TheCatalogList()
returns the singleton BESCatalogList instance. The pthreads library insures that only one instance ca...