bes  Updated for version 3.20.8
BESDapResponseBuilder.h
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
4 // Access Protocol.
5 
6 // Copyright (c) 2011 OPeNDAP, Inc.
7 // Author: James Gallagher <jgallagher@opendap.org>
8 //
9 // This library is free software; you can redistribute it and/or
10 // modify it under the terms of the GNU Lesser General Public
11 // License as published by the Free Software Foundation; either
12 // version 2.1 of the License, or (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful,
15 // but WITHOUT ANY WARRANTY; without even the implied warranty of
16 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 // Lesser General Public License for more details.
18 //
19 // You should have received a copy of the GNU Lesser General Public
20 // License along with this library; if not, write to the Free Software
21 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 //
23 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24 
25 #ifndef _response_builder_h
26 #define _response_builder_h
27 
28 #include <string>
29 //#include <D4Group.h>
30 
31 #define DAP_PROTOCOL_VERSION "3.2"
32 
33 #undef DAP2_STORED_RESULTS
34 
37 class BESResponseObject;
38 class BRDRequestHandler;
39 
40 namespace libdap {
41  class ConstraintEvaluator;
42  class DDS;
43  class DAS;
44 }
45 
46 
55 public:
56  friend class ResponseBuilderTest;
57 
58 protected:
59  std::string d_dataset;
60  std::string d_dap2ce;
61  std::string d_dap4ce;
62  std::string d_dap4function;
63  std::string d_btp_func_ce;
64  int d_timeout;
65  std::string d_default_protocol;
66 
68 
73  std::string d_async_accepted;
74 
81  std::string d_store_result;
82 
83  void initialize();
84 
85 #ifdef DAP2_STORED_RESULTS
86  bool store_dap2_result(ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval);
87 #endif
88 
89  void send_dap4_data_using_ce(std::ostream &out, libdap::DMR &dmr, bool with_mime_headersr);
90  void intern_dap4_data_grp(libdap::D4Group* grp);
91 
92 public:
93 
97  BESDapResponseBuilder(): d_dataset(""), d_dap2ce(""), d_dap4ce(""), d_dap4function(""),
98  d_btp_func_ce(""), d_timeout(0), d_default_protocol(DAP_PROTOCOL_VERSION),
100  {
101  initialize();
102  }
103 
104  virtual ~BESDapResponseBuilder();
105 
106  virtual std::string get_ce() const;
107  virtual void set_ce(std::string _ce);
108 
109  virtual std::string get_dap4ce() const;
110  virtual void set_dap4ce(std::string _ce);
111 
112  virtual std::string get_dap4function() const;
113  virtual void set_dap4function(std::string _func);
114 
115  virtual std::string get_store_result() const;
116  virtual void set_store_result(std::string _sr);
117 
118  virtual std::string get_async_accepted() const;
119  virtual void set_async_accepted(std::string _aa);
120 
121  virtual std::string get_btp_func_ce() const
122  {
123  return d_btp_func_ce;
124  }
125  virtual void set_btp_func_ce(std::string _ce)
126  {
127  d_btp_func_ce = _ce;
128  }
129 
130  virtual std::string get_dataset_name() const;
131  virtual void set_dataset_name(const std::string _dataset);
132 
138  void register_timeout() const;
139  void set_timeout(int timeout = 0);
140  int get_timeout() const;
141  void timeout_on() const;
142  void timeout_off();
143 
144  virtual void establish_timeout(std::ostream &stream) const;
145  virtual void remove_timeout() const;
147 
149 
150  virtual void split_ce(libdap::ConstraintEvaluator &eval, const std::string &expr = "");
151 
152  virtual void send_das(std::ostream &out, libdap::DAS &das, bool with_mime_headers = true) const;
153  virtual void send_das(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained =
154  false, bool with_mime_headers = true);
155 
156  virtual void send_dds(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained =
157  false, bool with_mime_headers = true);
158 
159  virtual void serialize_dap2_data_dds(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
160  bool ce_eval = true);
161  virtual void send_dap2_data(std::ostream &data_stream, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
162  bool with_mime_headers = true);
163  virtual void send_dap2_data(BESDataHandlerInterface &dhi, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
164  bool with_mime_headers = true);
165 
166 
167  // Added jhrg 9/1/16
168  virtual libdap::DDS *intern_dap2_data(BESResponseObject *obj, BESDataHandlerInterface &dhi);
169  virtual libdap::DDS *process_dap2_dds(BESResponseObject *obj, BESDataHandlerInterface &dhi);
170 
171  // Add the handling of DMR objects, including the function to handle expression constrainta.
172  // May need to improve. 5/13/20
173  virtual libdap::DMR *intern_dap4_data(BESResponseObject *obj, BESDataHandlerInterface &dhi);
174  virtual void intern_dap4_data_using_ce(libdap::DMR &dmr);
175 
176  virtual void send_ddx(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
177  bool with_mime_headers = true);
178 
179 #ifdef DAP2_STORED_RESULTS
180  virtual void serialize_dap2_data_ddx(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator & eval,
181  const std::string &boundary, const std::string &start, bool ce_eval = true);
182 #endif
183  virtual void send_dmr(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
184 
185  virtual void send_dap4_data(std::ostream &out, libdap::DMR & dmr, bool with_mime_headers = true);
186 
187  virtual void serialize_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
188 
189  virtual bool store_dap4_result(ostream &out, libdap::DMR &dmr);
190 };
191 
192 
193 #endif // _response_builder_h
Cache the results from server functions.
virtual void set_dataset_name(const std::string _dataset)
Set the dataset pathname.
virtual std::string get_dataset_name() const
Get the dataset name.
virtual libdap::DMR * intern_dap4_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
std::string d_dap4function
DAP4 Constraint expression.
virtual std::string get_dap4function() const
Get the DAP4 server side function expression.
virtual void split_ce(libdap::ConstraintEvaluator &eval, const std::string &expr="")
virtual std::string get_ce() const
Get the constraint expression.
int d_timeout
The BTP functions, extracted from the CE.
std::string d_dap2ce
Name of the dataset/database.
virtual void set_dap4ce(std::string _ce)
virtual void remove_timeout() const
Transmit data.
virtual libdap::DDS * process_dap2_dds(BESResponseObject *obj, BESDataHandlerInterface &dhi)
Process a DDS (i.e., apply a constraint) for a non-DAP transmitter.
virtual void serialize_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
virtual libdap::DDS * intern_dap2_data(BESResponseObject *obj, BESDataHandlerInterface &dhi)
virtual void send_dds(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
Transmit a DDS.
virtual std::string get_dap4ce() const
Get the DAP4 constraint expression.
virtual void establish_timeout(std::ostream &stream) const
virtual bool store_dap4_result(ostream &out, libdap::DMR &dmr)
bool d_cancel_timeout_on_send
Version string for the library's default protocol version.
std::string d_async_accepted
Should a timeout be cancelled once transmission starts?
virtual void send_ddx(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
virtual void serialize_dap2_data_dds(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool ce_eval=true)
std::string d_default_protocol
Response timeout after N seconds.
virtual void set_dap4function(std::string _func)
void set_timeout(int timeout=0)
virtual void set_ce(std::string _ce)
std::string d_btp_func_ce
DAP4 Server Side Function expression.
std::string d_dap4ce
DAP2 Constraint expression.
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.