bes  Updated for version 3.20.6
DDSLoader.h
1 // 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 
36 class BESContainer;
38 class BESDapResponse;
39 class BESResponseObject;
40 
60 namespace agg_util {
61 
62 class DDSLoader {
63 private:
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 
89 public:
90 
94  enum ResponseType {
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
125 
142  std::auto_ptr<BESDapResponse> load(const std::string& location, ResponseType type);
143 #endif
144 
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 
195 private:
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__ */
agg_util::DDSLoader
Definition: DDSLoader.h:62
BESContainerStorage
provides persistent storage for data storage information represented by a container.
Definition: BESContainerStorage.h:67
agg_util::DDSLoader::~DDSLoader
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
BESDapResponse
Represents an OPeNDAP DAP response object within the BES.
Definition: BESDapResponse.h:41
agg_util::DDSLoader::getActionNameForType
static std::string getActionNameForType(ResponseType type)
Definition: DDSLoader.cc:460
agg_util::DDSLoader::DDSLoader
DDSLoader(BESDataHandlerInterface &dhi)
Create a loader that will hijack dhi on a load call, then restore it's state.
Definition: DDSLoader.cc:73
agg_util
Helper class for temporarily hijacking an existing dhi to load a DDX response for one particular file...
Definition: AggMemberDataset.cc:38
agg_util::DDSLoader::makeResponseForType
static std::auto_ptr< BESDapResponse > makeResponseForType(ResponseType type)
Definition: DDSLoader.cc:433
agg_util::DDSLoader::cleanup
void cleanup()
restore dhi to clean state
Definition: DDSLoader.cc:256
agg_util::DDSLoader::ResponseType
ResponseType
Definition: DDSLoader.h:94
BESContainer
A container is something that holds data. E.G., a netcdf file or a database entry.
Definition: BESContainer.h:65
agg_util::DDSLoader::loadInto
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
agg_util::DDSLoader::checkResponseIsValidType
static bool checkResponseIsValidType(ResponseType type, BESDapResponse *pResponse)
Definition: DDSLoader.cc:472
agg_util::DDSLoader::getDHI
BESDataHandlerInterface & getDHI() const
Definition: DDSLoader.h:120
BESDataHandlerInterface
Structure storing information used by the BES to handle the request.
Definition: BESDataHandlerInterface.h:56
agg_util::DDSLoader::getActionForType
static std::string getActionForType(ResponseType type)
Definition: DDSLoader.cc:448
BESResponseObject
Abstract base class representing a specific set of information in response to a request to the BES.
Definition: BESResponseObject.h:45