bes Updated for version 3.20.10
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 <memory>
30
31#define DAP_PROTOCOL_VERSION "3.2"
32
33#undef DAP2_STORED_RESULTS
34
36
38
40
41class BRDRequestHandler;
42
43namespace libdap {
44class ConstraintEvaluator;
45
46class DDS;
47
48class DAS;
49
50class DMR;
51
52class D4Group;
53}
54
55
64public:
65 friend class ResponseBuilderTest;
66
67protected:
68 std::string d_dataset;
69 std::string d_dap2ce;
70 std::string d_dap4ce;
71 std::string d_dap4function;
72 std::string d_btp_func_ce;
74 std::string d_default_protocol;
75
77
82 std::string d_async_accepted;
83
90 std::string d_store_result;
91
92 void initialize();
93
94#ifdef DAP2_STORED_RESULTS
95 bool store_dap2_result(ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval);
96#endif
97
98 void send_dap4_data_using_ce(std::ostream &out, libdap::DMR &dmr, bool with_mime_headersr);
99
100 void intern_dap4_data_grp(libdap::D4Group *grp);
101
102public:
103
107 BESDapResponseBuilder() : d_dataset(""), d_dap2ce(""), d_dap4ce(""), d_dap4function(""),
108 d_btp_func_ce(""), d_timeout(0), d_default_protocol(DAP_PROTOCOL_VERSION),
110 initialize();
111 }
112
113 virtual ~BESDapResponseBuilder();
114
115 virtual std::string get_ce() const;
116
117 virtual void set_ce(std::string _ce);
118
119 virtual std::string get_dap4ce() const;
120
121 virtual void set_dap4ce(std::string _ce);
122
123 virtual std::string get_dap4function() const;
124
125 virtual void set_dap4function(std::string _func);
126
127 virtual std::string get_store_result() const;
128
129 virtual void set_store_result(std::string _sr);
130
131 virtual std::string get_async_accepted() const;
132
133 virtual void set_async_accepted(std::string _aa);
134
135 virtual std::string get_btp_func_ce() const {
136 return d_btp_func_ce;
137 }
138
139 virtual void set_btp_func_ce(std::string _ce) {
140 d_btp_func_ce = _ce;
141 }
142
143 virtual std::string get_dataset_name() const;
144
145 virtual void set_dataset_name(const std::string _dataset);
146
152 void register_timeout() const;
153
154 void set_timeout(int timeout = 0);
155
156 int get_timeout() const;
157
158 void timeout_on() const;
159
160 void timeout_off();
161
162 virtual void establish_timeout(std::ostream &stream) const;
163
164 virtual void remove_timeout() const;
166
168
169 virtual void split_ce(libdap::ConstraintEvaluator &eval, const std::string &expr = "");
170
171 virtual void send_das(std::ostream &out, libdap::DAS &das, bool with_mime_headers = true) const;
172
173 virtual void send_das(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained =
174 false, bool with_mime_headers = true);
175
176 virtual void send_dds(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained =
177 false, bool with_mime_headers = true);
178
179 virtual void serialize_dap2_data_dds(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
180 bool ce_eval = true);
181
182 virtual void send_dap2_data(std::ostream &data_stream, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
183 bool with_mime_headers = true);
184
185 virtual void send_dap2_data(BESDataHandlerInterface &dhi, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
186 bool with_mime_headers = true);
187
188 // Added jhrg 9/1/16
189 virtual libdap::DDS *intern_dap2_data(BESResponseObject *obj, BESDataHandlerInterface &dhi);
190
191 virtual libdap::DDS *process_dap2_dds(BESResponseObject *obj, BESDataHandlerInterface &dhi);
192
193 // Add the handling of DMR objects, including the function to handle expression constraints.
194 // May need to improve. 5/13/20
195 virtual libdap::DMR *intern_dap4_data(BESResponseObject *obj, BESDataHandlerInterface &dhi);
196
197 virtual void dap4_process_ce_for_intern_data(libdap::DMR &dmr);
198
199 virtual void send_ddx(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
200 bool with_mime_headers = true);
201
202#ifdef DAP2_STORED_RESULTS
203 virtual void serialize_dap2_data_ddx(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator & eval,
204 const std::string &boundary, const std::string &start, bool ce_eval = true);
205#endif
206
207 virtual void send_dmr(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
208
209 virtual void send_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
210
211 virtual void serialize_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
212
213 virtual bool store_dap4_result(std::ostream &out, libdap::DMR &dmr);
214
215 std::unique_ptr<libdap::DMR> setup_dap4_intern_data(BESResponseObject *obj, BESDataHandlerInterface &dhi);
216};
217
218
219#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 dap4_process_ce_for_intern_data(libdap::DMR &dmr)
Parse the DAP4 CE and throw if the request is too large.
virtual void establish_timeout(std::ostream &stream) const
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)
virtual bool store_dap4_result(std::ostream &out, libdap::DMR &dmr)
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.