bes Updated for version 3.20.10
DDSLoader.h
1
2// This file is part of the "NcML Module" project, a BES module designed
3// to allow NcML files to be used to be used as a wrapper to add
4// AIS to existing datasets of any format.
5//
6// Copyright (c) 2009 OPeNDAP, Inc.
7// Author: Michael Johnson <m.johnson@opendap.org>
8//
9// For more information, please also see the main website: http://opendap.org/
10//
11// This library is free software; you can redistribute it and/or
12// modify it under the terms of the GNU Lesser General Public
13// License as published by the Free Software Foundation; either
14// version 2.1 of the License, or (at your option) any later version.
15//
16// This library is distributed in the hope that it will be useful,
17// but WITHOUT ANY WARRANTY; without even the implied warranty of
18// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19// Lesser General Public License for more details.
20//
21// You should have received a copy of the GNU Lesser General Public
22// License along with this library; if not, write to the Free Software
23// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24//
25// Please see the files COPYING and COPYRIGHT for more information on the GLPL.
26//
27// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
29#ifndef __NCML_MODULE_DDSLOADER_H__
30#define __NCML_MODULE_DDSLOADER_H__
31
32#include <memory>
33#include <string>
34
36class BESContainer;
38class BESDapResponse;
40
60namespace agg_util {
61
62class DDSLoader {
63private:
64
65 // The dhi to use for the loading, passed in on creation.
66 // Rep Invariant: the dhi state is the same on call exits as it was on call entry.
68
69 // whether we have actually hijacked the dhi, so restore knows.
70 bool _hijacked;
71
72 // The file we are laoding if we're hijacked
73 std::string _filename;
74
75 // Remember the store so we can pull the location out in restoreDHI on exception as well.
76 BESContainerStorage* _store;
77
78 // DHI state we hijack, for putting back on exception.
79 std::string _containerSymbol;
80 std::string _origAction;
81 std::string _origActionName;
82 BESContainer* _origContainer;
83 BESResponseObject* _origResponse;
84
85 // A counter we use to generate a "class-unique" symbol for containers internally.
86 // Incremented by getNextContainerName().
87 static long _gensymID;
88
89public:
90
95 eRT_RequestDDX = 0, eRT_RequestDataDDS, eRT_Num
96 };
97
104
105 DDSLoader(const DDSLoader& proto);
106 DDSLoader& operator=(const DDSLoader&);
107
113 virtual ~DDSLoader();
114
121 {
122 return _dhi;
123 }
124#if 0
142 std::auto_ptr<BESDapResponse> load(const std::string& location, ResponseType type);
143#endif
161 void loadInto(const std::string& location, ResponseType type, BESDapResponse* pResponse);
162
170 void cleanup();
171
173
175 static std::auto_ptr<BESDapResponse> makeResponseForType(ResponseType type);
176
181 static std::string getActionForType(ResponseType type);
182
187 static std::string getActionNameForType(ResponseType type);
188
193 static bool checkResponseIsValidType(ResponseType type, BESDapResponse* pResponse);
194
195private:
196
201 void snapshotDHI();
202
207 void restoreDHI();
208
212 BESContainer* addNewContainerToStorage();
213
216 void removeContainerFromStorage();
217
221 void ensureClean();
222
226 static std::string getNextContainerName();
227
228};
229// class DDSLoader
230}// namespace ncml_module
231
232#endif /* __NCML_MODULE_DDSLOADER_H__ */
provides persistent storage for data storage information represented by a container.
A container is something that holds data. E.G., a netcdf file or a database entry.
Definition: BESContainer.h:65
Represents an OPeNDAP DAP response object within the BES.
Structure storing information used by the BES to handle the request.
Abstract base class representing a specific set of information in response to a request to the BES.
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.
Definition: DDSLoader.cc:148
DDSLoader(BESDataHandlerInterface &dhi)
Create a loader that will hijack dhi on a load call, then restore it's state.
Definition: DDSLoader.cc:73
static bool checkResponseIsValidType(ResponseType type, BESDapResponse *pResponse)
Definition: DDSLoader.cc:472
void cleanup()
restore dhi to clean state
Definition: DDSLoader.cc:256
BESDataHandlerInterface & getDHI() const
Definition: DDSLoader.h:120
static std::auto_ptr< BESDapResponse > makeResponseForType(ResponseType type)
Definition: DDSLoader.cc:433
static std::string getActionForType(ResponseType type)
Definition: DDSLoader.cc:448
static std::string getActionNameForType(ResponseType type)
Definition: DDSLoader.cc:460
virtual ~DDSLoader()
Dtor restores the state of dhi Restores the state of the dhi to what it was when object if it is stil...
Definition: DDSLoader.cc:131
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...