OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
DDSLoader.h
Go to the documentation of this file.
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 
41 
61 namespace agg_util
62 {
63 
64 class DDSLoader
65 {
66 private:
67 
68  // The dhi to use for the loading, passed in on creation.
69  // Rep Invariant: the dhi state is the same on call exits as it was on call entry.
71 
72  // whether we have actually hijacked the dhi, so restore knows.
73  bool _hijacked;
74 
75  // The file we are laoding if we're hijacked
76  std::string _filename;
77 
78  // Remember the store so we can pull the location out in restoreDHI on exception as well.
79  BESContainerStorage* _store;
80 
81  // DHI state we hijack, for putting back on exception.
82  std::string _containerSymbol;
83  std::string _origAction;
84  std::string _origActionName;
85  BESContainer* _origContainer;
86  BESResponseObject* _origResponse;
87 
88  // A counter we use to generate a "class-unique" symbol for containers internally.
89  // Incremented by getNextContainerName().
90  static long _gensymID;
91 
92 public:
93 
98 
105 
106  DDSLoader(const DDSLoader& proto);
107  DDSLoader& operator=(const DDSLoader&);
108 
114  virtual ~DDSLoader();
115 
121  BESDataHandlerInterface& getDHI() const { return _dhi; }
122 
140  std::auto_ptr<BESDapResponse> load(const std::string& location, ResponseType type);
141 
159  void loadInto(const std::string& location, ResponseType type, BESDapResponse* pResponse);
160 
168  void cleanup() throw();
169 
171 
173  static std::auto_ptr<BESDapResponse> makeResponseForType(ResponseType type);
174 
179  static std::string getActionForType(ResponseType type);
180 
185  static std::string getActionNameForType(ResponseType type);
186 
191  static bool checkResponseIsValidType(ResponseType type, BESDapResponse* pResponse);
192 
193 
194 private:
195 
200  void snapshotDHI();
201 
206  void restoreDHI();
207 
211  BESContainer* addNewContainerToStorage();
212 
215  void removeContainerFromStorage() throw();
216 
220  void ensureClean() throw();
221 
225  static std::string getNextContainerName();
226 
227  }; // class DDSLoader
228 } // namespace ncml_module
229 
230 #endif /* __NCML_MODULE_DDSLOADER_H__ */
static std::auto_ptr< BESDapResponse > makeResponseForType(ResponseType type)
Make a new response object for the requested type.
Definition: DDSLoader.cc:333
provides persistent storage for data storage information represented by a container.
ResponseType
For telling the loader what type of BESDapResponse to load and return.
Definition: DDSLoader.h:97
static std::string getActionNameForType(ResponseType type)
Convert the type in the action name in BESResponseNames.h.
Definition: DDSLoader.cc:361
static bool checkResponseIsValidType(ResponseType type, BESDapResponse *pResponse)
Return whether the given response's type matches the given ResposneType.
Definition: DDSLoader.cc:373
STL namespace.
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.
Definition: DDSLoader.cc:349
BESDataHandlerInterface & getDHI() const
Return a reference to the dhi we are using.
Definition: DDSLoader.h:121
DDSLoader & operator=(const DDSLoader &)
Definition: DDSLoader.cc:79
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:141
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:127
Represents an OPeNDAP DAP response object within the BES.
Structure storing information used by the BES to handle the request.
A container is something that holds data.
Definition: BESContainer.h:60
DDSLoader(BESDataHandlerInterface &dhi)
Create a loader that will hijack dhi on a load call, then restore it's state.
Definition: DDSLoader.cc:65
Abstract base class representing a specific set of information in response to a request to the BES...
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...
Definition: DDSLoader.cc:132
void cleanup()
restore dhi to clean state
Definition: DDSLoader.cc:209