38#include "BESContainerStorageList.h"
39#include "BESContainerStorage.h"
40#include "BESSyntaxUserError.h"
41#include "BESContainer.h"
42#include "TheBESKeys.h"
53static std::once_flag d_euc_init_once;
55BESContainerStorageList::BESContainerStorageList() :
60BESContainerStorageList::~BESContainerStorageList()
62 BESContainerStorageList::persistence_list *pl = _first;
64 if (pl->_persistence_obj) {
65 delete pl->_persistence_obj;
67 BESContainerStorageList::persistence_list *next = pl->_next;
87 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
91 _first =
new BESContainerStorageList::persistence_list;
92 _first->_persistence_obj = cp;
93 _first->_reference = 1;
98 BESContainerStorageList::persistence_list *pl = _first;
100 while (done ==
false) {
101 if (pl->_persistence_obj->get_name() != cp->
get_name()) {
106 pl->_next =
new BESContainerStorageList::persistence_list;
107 pl->_next->_reference = 1;
108 pl->_next->_persistence_obj = cp;
109 pl->_next->_next = 0;
135 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
138 BESContainerStorageList::persistence_list *pl = _first;
141 while (done ==
false) {
143 if (pl->_persistence_obj && pl->_persistence_obj->get_name() == persist_name) {
173 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
176 BESContainerStorageList::persistence_list *pl = _first;
177 BESContainerStorageList::persistence_list *last = 0;
180 while (done ==
false) {
182 if (pl->_persistence_obj && pl->_persistence_obj->get_name() == persist_name) {
186 if (!pl->_reference) {
188 _first = _first->_next;
192 throw BESInternalError(
"ContainerStorageList last is null", __FILE__, __LINE__);
193 last->_next = pl->_next;
195 delete pl->_persistence_obj;
224 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
227 BESContainerStorageList::persistence_list *pl = _first;
229 while (done ==
false) {
231 if (persist_name == pl->_persistence_obj->get_name()) {
232 ret = pl->_persistence_obj;
246bool BESContainerStorageList::isnice()
248 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
251 string key =
"BES.Container.Persistence";
255 if (isnice ==
"Nice" || isnice ==
"nice" || isnice ==
"NICE")
288 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
291 BESContainerStorageList::persistence_list *pl = _first;
293 while (done ==
false) {
295 ret_container = pl->_persistence_obj->look_for(sym_name);
307 if (!ret_container) {
308 string msg = (string)
"Could not find the symbolic name " + sym_name;
309 ERROR_LOG(msg << endl);
315 return ret_container;
335 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
337 BESContainerStorageList::persistence_list *pl = _first;
339 (void) pl->_persistence_obj->del_container(sym_name);
359 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
361 BESContainerStorageList::persistence_list *pl = _first;
363 std::map<string, string> props;
364 props[
"name"] = pl->_persistence_obj->get_name();
365 info.begin_tag(
"store", &props);
366 pl->_persistence_obj->show_containers(info);
367 info.end_tag(
"store");
381 std::lock_guard<std::recursive_mutex> lock_me(d_cache_lock_mutex);
383 strm << BESIndent::LMarg <<
"BESContainerStorageList::dump - (" << (
void *)
this <<
")" << endl;
385 BESContainerStorageList::persistence_list *pl = _first;
387 strm << BESIndent::LMarg <<
"container storage:" << endl;
390 pl->_persistence_obj->dump(strm);
393 BESIndent::UnIndent();
396 strm << BESIndent::LMarg <<
"container storage: empty" << endl;
398 BESIndent::UnIndent();
402BESContainerStorageList::TheList()
404 std::call_once(d_euc_init_once,BESContainerStorageList::initialize_instance);
408void BESContainerStorageList::initialize_instance() {
411 atexit(delete_instance);
415void BESContainerStorageList::delete_instance() {
Provides a mechanism for accessing container information from different container stores registered w...
virtual bool ref_persistence(const std::string &persist_name)
refence the specified persistent store if in the list
virtual void show_containers(BESInfo &info)
show information for each container in each persistence store
virtual void dump(std::ostream &strm) const
dumps information about this object
virtual bool add_persistence(BESContainerStorage *p)
Add a persistent store to the list.
virtual BESContainer * look_for(const std::string &sym_name)
look for the specified container information in the list of persistent stores.
virtual void delete_container(const std::string &sym_name)
scan all of the container stores and remove any containers called
virtual bool deref_persistence(const std::string &persist_name)
dereference a persistent store in the list.
virtual BESContainerStorage * find_persistence(const std::string &persist_name)
find the persistence store with the given name
provides persistent storage for data storage information represented by a container.
virtual const std::string & get_name() const
retrieve the name of this persistent store
A container is something that holds data. E.G., a netcdf file or a database entry.
informational response object
exception thrown if internal error encountered
error thrown if there is a user syntax error in the request or any other user error
void get_value(const std::string &s, std::string &val, bool &found)
Retrieve the value of a given key, if set.
static TheBESKeys * TheKeys()