bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
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
62
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;
73 std::string d_default_protocol;
74
79 std::string d_async_accepted;
80
87 std::string d_store_result;
88
89#ifdef DAP2_STORED_RESULTS
90 bool store_dap2_result(ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval);
91#endif
92
93 void send_dap4_data_using_ce(std::ostream &out, libdap::DMR &dmr, bool with_mime_headersr);
94
95 void intern_dap4_data_grp(libdap::D4Group *grp);
96
97public:
98
102 BESDapResponseBuilder() : d_dataset(""), d_dap2ce(""), d_dap4ce(""), d_dap4function(""),
103 d_btp_func_ce(""), d_default_protocol(DAP_PROTOCOL_VERSION),
105
106 virtual ~BESDapResponseBuilder();
107
108 virtual std::string get_ce() const;
109
110 virtual void set_ce(std::string _ce);
111
112 virtual std::string get_dap4ce() const;
113
114 virtual void set_dap4ce(const std::string &_ce);
115
116 virtual std::string get_dap4function() const;
117
118 virtual void set_dap4function(const std::string &_func);
119
120 virtual std::string get_store_result() const;
121
122 virtual void set_store_result(const std::string &_sr);
123
124 virtual std::string get_async_accepted() const;
125
126 virtual void set_async_accepted(const std::string &_aa);
127
128 virtual std::string get_btp_func_ce() const {
129 return d_btp_func_ce;
130 }
131
132 virtual void set_btp_func_ce(const std::string &_ce) {
133 d_btp_func_ce = _ce;
134 }
135
136 virtual std::string get_dataset_name() const;
137
138 virtual void set_dataset_name(const std::string &_dataset);
139
140 virtual void split_ce(libdap::ConstraintEvaluator &eval, const std::string &expr = "");
141
142 virtual void send_das(std::ostream &out, libdap::DAS &das, bool with_mime_headers = true) const;
143
144 virtual void send_das(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained =
145 false, bool with_mime_headers = true);
146
147 virtual void send_dds(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval, bool constrained =
148 false, bool with_mime_headers = true);
149
150 virtual void serialize_dap2_data_dds(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
151 bool ce_eval = true);
152
153 virtual void send_dap2_data(std::ostream &data_stream, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
154 bool with_mime_headers = true);
155
156 virtual void send_dap2_data(BESDataHandlerInterface &dhi, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
157 bool with_mime_headers = true);
158
159 // Added jhrg 9/1/16
160 virtual libdap::DDS *intern_dap2_data(BESResponseObject *obj, BESDataHandlerInterface &dhi);
161
162 virtual libdap::DDS *process_dap2_dds(BESResponseObject *obj, BESDataHandlerInterface &dhi);
163
164 // Add the handling of DMR objects, including the function to handle expression constraints.
165 // May need to improve. 5/13/20
166 virtual libdap::DMR *intern_dap4_data(BESResponseObject *obj, BESDataHandlerInterface &dhi);
167
168 virtual libdap::DMR *process_dap4_dmr(BESResponseObject *obj, BESDataHandlerInterface &dhi);
169
170 virtual void dap4_process_ce_for_intern_data(libdap::DMR &dmr);
171
172 virtual void send_ddx(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator &eval,
173 bool with_mime_headers = true);
174
175#ifdef DAP2_STORED_RESULTS
176 virtual void serialize_dap2_data_ddx(std::ostream &out, libdap::DDS **dds, libdap::ConstraintEvaluator & eval,
177 const std::string &boundary, const std::string &start, bool ce_eval = true);
178#endif
179
180 virtual void send_dmr(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
181
182 virtual void send_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
183
184 virtual void serialize_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
185
186 virtual bool store_dap4_result(std::ostream &out, libdap::DMR &dmr);
187
188 std::unique_ptr<libdap::DMR> setup_dap4_intern_data(BESResponseObject *obj, BESDataHandlerInterface &dhi);
189};
190
191
192#endif // _response_builder_h
Cache the results from server functions.
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 set_dataset_name(const std::string &_dataset)
Set the dataset pathname.
virtual void split_ce(libdap::ConstraintEvaluator &eval, const std::string &expr="")
virtual std::string get_ce() const
Get the constraint expression.
std::string d_dap2ce
Name of the dataset/database.
virtual libdap::DDS * process_dap2_dds(BESResponseObject *obj, BESDataHandlerInterface &dhi)
Transmit data.
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 void set_dap4function(const std::string &_func)
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 set_dap4ce(const std::string &_ce)
std::string d_async_accepted
Version string for the library's default protocol version.
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
The BTP functions, extracted from the CE.
virtual bool store_dap4_result(std::ostream &out, libdap::DMR &dmr)
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.
STL class.