61 long DDSLoader::_gensymID = 0
L;
66 _dhi(dhi), _hijacked(false), _filename(
""), _store(0), _containerSymbol(
""), _origAction(
""),
67 _origActionName(
""), _origContainer(0), _origResponse(0)
73 _dhi(proto._dhi), _hijacked(false), _filename(
""), _store(0), _containerSymbol(
""), _origAction(
""),
74 _origActionName(
""), _origContainer(0), _origResponse(0)
81 BESDEBUG(
"ncml",
"DDSLoader::operator=: " << endl);
105 removeContainerFromStorage();
121 if (&_dhi != &rhs._dhi)
137 loadInto(location, type, response.get());
150 _filename = location;
182 pDDS->set_dap_major( pDDSResponse->get_dds()->get_dap_major() );
183 pDDS->set_dap_minor( pDDSResponse->get_dds()->get_dap_major() );
188 BESDEBUG(
"ncml",
"Before BESRequestHandlerList::TheList()->execute_current" << endl);
191 BESDEBUG(
"ncml",
"After BESRequestHandlerList::TheList()->execute_current" << endl);
201 removeContainerFromStorage();
215 DDSLoader::addNewContainerToStorage()
222 throw BESInternalError(
"couldn't find the catalog storage", __FILE__, __LINE__);
228 string newSymbol = getNextContainerName() +
"__" + _filename;
237 _containerSymbol = newSymbol;
242 throw BESInternalError(
"couldn't find the container we just added:" + newSymbol, __FILE__, __LINE__);
248 void DDSLoader::removeContainerFromStorage() throw ()
260 "WARNING: tried to remove symbol " << _containerSymbol <<
" from singleton but unexpectedly it was not there." << endl);
262 _containerSymbol =
"";
267 void DDSLoader::snapshotDHI()
271 BESDEBUG(
"ncml",
"original dhi = " << _dhi << endl ) ;
275 _origAction = _dhi.
action;
283 void DDSLoader::restoreDHI()
294 _dhi.
action = _origAction;
299 BESDEBUG(
"ncml",
"restored dhi = " << _dhi << endl ) ;
303 _origActionName =
"";
311 void DDSLoader::ensureClean() throw ()
320 removeContainerFromStorage();
324 std::string DDSLoader::getNextContainerName()
326 static const string _sPrefix =
"__DDSLoader_Container_ID_";
328 std::ostringstream oss;
329 oss << _sPrefix << (_gensymID);
336 return auto_ptr<BESDapResponse>(
new BESDDSResponse(
new DDS(
new BaseTypeFactory(),
"virtual")));
339 return auto_ptr<BESDapResponse>(
new BESDataDDSResponse(
new DataDDS(
new BaseTypeFactory(),
"virtual")));
345 return auto_ptr<BESDapResponse>(0);
static std::auto_ptr< BESDapResponse > makeResponseForType(ResponseType type)
Make a new response object for the requested type.
string get_dap_client_protocol() const
Return the dap version string sent by the client (e.g., the OLFS)
provides persistent storage for data storage information represented by a container.
ResponseType
For telling the loader what type of BESDapResponse to load and return.
exception thrown if inernal error encountered
virtual BESContainerStorage * find_persistence(const string &persist_name)
find the persistence store with the given name
static std::string getActionNameForType(ResponseType type)
Convert the type in the action name in BESResponseNames.h.
Represents an OPeNDAP DDS DAP2 data object within the BES.
static bool checkResponseIsValidType(ResponseType type, BESDapResponse *pResponse)
Return whether the given response's type matches the given ResposneType.
virtual BESContainer * look_for(const string &sym_name)=0
looks for a container in this persistent store
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
static std::string getActionForType(ResponseType type)
Convert the type into the action in BESResponseNames.h for the type.
static libdap::DDS * getDDSFromEitherResponse(BESDapResponse *response)
Return the DDS* for the given response object.
virtual BESResponseObject * set_response_object(BESResponseObject *o)
replaces the current response object with the specified one, returning the current response object ...
void make_copy(const BESDataHandlerInterface ©_from)
deprecated
virtual string get_file()
get the file name where the exception was thrown
virtual string get_message()
get the error message for this exception
DDSLoader & operator=(const DDSLoader &)
virtual BESResponseObject * get_response_object()
return the current response object
Abstract exception class for the BES with basic string message.
void loadInto(const std::string &location, ResponseType type, BESDapResponse *pResponse)
Load a DDX or DataDDS response into the given pResponse object, which must be non-null.
BESResponseHandler * response_handler
Provides a mechanism for accessing container information from different container stores registered w...
virtual void add_container(const string &sym_name, const string &real_name, const string &type)=0
adds a container with the provided information
Represents an OPeNDAP DataDDS DAP2 data object within the BES.
string get_request_xml_base() const
Return the xml:base URL for this request.
virtual ~DDSLoader()
Dtor restores the state of dhi Restores the state of the dhi to what it was when object if it is stil...
Represents an OPeNDAP DAP response object within the BES.
#define THROW_NCML_INTERNAL_ERROR(msg)
static BESRequestHandlerList * TheList()
Structure storing information used by the BES to handle the request.
static BESContainerStorageList * TheList()
virtual void execute_current(BESDataHandlerInterface &dhi)
Execute a single method for the current container that will fill in the response object rather than i...
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
virtual bool del_container(const string &s_name)=0
removes a container with the given symbolic name
A container is something that holds data.
DDSLoader(BESDataHandlerInterface &dhi)
Create a loader that will hijack dhi on a load call, then restore it's state.
#define DATA_RESPONSE_STR
string action
the response object requested, e.g.
BESContainer * container
pointer to current container in this interface
std::auto_ptr< BESDapResponse > load(const std::string &location, ResponseType type)
Load and return a new DDX or DataDDS structure for the local dataset referred to by location...
virtual int get_line()
get the line number where the exception was thrown
void cleanup()
restore dhi to clean state