33#include <libdap/DMR.h>
34#include <libdap/XMLWriter.h>
38#include "BESInternalFatalError.h"
40#include "DmrppParserSax2.h"
41#include "DmrppTypeFactory.h"
42#include "DmrppMetadataStore.h"
46#define DEBUG_KEY "dmrpp_store"
47#define MAINTAIN_STORE_SIZE_EVEN_WHEN_UNLIMITED 0
50#define AT_EXIT(x) atexit((x))
64#undef SYMETRIC_ADD_RESPONSES
73bool DmrppMetadataStore::d_enabled =
true;
108DmrppMetadataStore::get_instance(
const string &cache_dir,
const string &prefix,
unsigned long long size)
110 if (d_enabled && d_instance == 0) {
117 BESDEBUG(DEBUG_KEY,
"DmrppMetadataStore::"<<__func__ <<
"() - " <<
"Cache is DISABLED"<< endl);
120 AT_EXIT(delete_instance);
122 BESDEBUG(DEBUG_KEY,
"DmrppMetadataStore::"<<__func__ <<
"() - " <<
"Cache is ENABLED"<< endl);
126 BESDEBUG(DEBUG_KEY,
"DmrppMetadataStore::get_instance(dir,prefix,size) - d_instance: " << d_instance << endl);
140 if (d_enabled && d_instance == 0) {
146 BESDEBUG(DEBUG_KEY,
"DmrppMetadataStore::"<<__func__ <<
"() - " <<
"Cache is DISABLED"<< endl);
149 AT_EXIT(delete_instance);
151 BESDEBUG(DEBUG_KEY,
"DmrppMetadataStore::"<<__func__ <<
"() - " <<
"Cache is ENABLED"<< endl);
155 BESDEBUG(DEBUG_KEY,
"DmrppMetadataStore::get_instance() - d_instance: " << (
void *) d_instance << endl);
161void DmrppMetadataStore::StreamDMRpp::operator()(ostream &os)
169 dmrpp->set_print_chunks(
true);
175 static_cast<dmrpp::DMRpp*
>(d_dmr)->print_dmrpp(xml, href);
181 throw BESInternalFatalError(
"StreamDMRpp output operator call with non-DMRpp instance.", __FILE__, __LINE__);
201 bool stored_dmrpp =
false;
203 d_ledger_entry = string(
"add DMR++ ").append(name);
214 return(stored_dmr && stored_dmrpp);
218DmrppMetadataStore::add_dmrpp_response(libdap::DMR *dmrpp,
const std::string &name)
220 bool stored_dmrpp =
false;
222 d_ledger_entry = string(
"add DMR++ ").append(name);
224 StreamDMRpp write_the_dmrpp_response(dmrpp);
233 return(stored_dmrpp);
252 unique_ptr<DMRpp> dmrpp(
new DMRpp(&dmrpp_btf,
"mds"));
255 parser.
intern(oss.str(), dmrpp.get());
257 dmrpp->set_factory(0);
259 return dmrpp.release();
281 unique_ptr<DMRpp> dmrpp(
new DMRpp(&dmrpp_btf,
"mds"));
284 parser.
intern(oss.str(), dmrpp.get());
286 dmrpp->set_factory(0);
288 return dmrpp.release();
bool cache_enabled() const
exception thrown if an internal error is found and is fatal to the BES
Provide a way to print the DMR++ response.
void print_dap4(libdap::XMLWriter &xml, bool constrained=false)
override DMR::print_dap4() so the chunk info will print too.
void intern(std::istream &f, libdap::DMR *dest_dmr)