bes  Updated for version 3.20.13
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  // The dhi to use for the loading, passed in on creation.
65  // Rep Invariant: the dhi state is the same on call exits as it was on call entry.
67 
68  // whether we have actually hijacked the dhi, so restore knows.
69  bool _hijacked;
70 
71  // The file we are laoding if we're hijacked
72  std::string _filename;
73 
74  // Remember the store so we can pull the location out in restoreDHI on exception as well.
75  BESContainerStorage* _store;
76 
77  // DHI state we hijack, for putting back on exception.
78  std::string _containerSymbol;
79  std::string _origAction;
80  std::string _origActionName;
81  BESContainer* _origContainer;
82  BESResponseObject* _origResponse;
83 
84  // A counter we use to generate a "class-unique" symbol for containers internally.
85  // Incremented by getNextContainerName().
86  static long _gensymID;
87 
88 public:
89 
93  enum ResponseType {
94  eRT_RequestDDX = 0, eRT_RequestDataDDS // Not used. jhrg 3/31/22 eRT_Num
95  };
96 
102  explicit DDSLoader(BESDataHandlerInterface &dhi);
103 
104  DDSLoader(const DDSLoader& proto);
105  DDSLoader& operator=(const DDSLoader&);
106 
112  virtual ~DDSLoader();
113 
120  {
121  return _dhi;
122  }
123 
124 #if 0
142  std::unique_ptr<BESDapResponse> load(const std::string& location, ResponseType type);
143 #endif
144 
162  void loadInto(const std::string& location, ResponseType type, BESDapResponse* pResponse);
163 
171  void cleanup();
172 
174 
176  static std::unique_ptr<BESDapResponse> makeResponseForType(ResponseType type);
177 
182  static std::string getActionForType(ResponseType type);
183 
188  static std::string getActionNameForType(ResponseType type);
189 
194  static bool checkResponseIsValidType(ResponseType type, BESDapResponse* pResponse);
195 
196 private:
197 
202  void snapshotDHI();
203 
208  void restoreDHI();
209 
213  BESContainer* addNewContainerToStorage();
214 
217  void removeContainerFromStorage();
218 
222  void ensureClean();
223 
227  static std::string getNextContainerName();
228 
229 };
230 // class DDSLoader
231 }// namespace ncml_module
232 
233 #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.
static std::unique_ptr< BESDapResponse > makeResponseForType(ResponseType type)
Definition: DDSLoader.cc:431
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:470
BESDataHandlerInterface & getDHI() const
Definition: DDSLoader.h:119
void cleanup()
restore dhi to clean state
Definition: DDSLoader.cc:256
static std::string getActionForType(ResponseType type)
Definition: DDSLoader.cc:446
static std::string getActionNameForType(ResponseType type)
Definition: DDSLoader.cc:458
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...