bes  Updated for version 3.17.0
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 
30 #define DAP_PROTOCOL_VERSION "3.2"
31 
33 
34 namespace libdap {
35  class ConstraintEvaluator;
36  class DDS;
37  class DAS;
38 }
39 
48 public:
49  friend class ResponseBuilderTest;
50 
51 protected:
52  std::string d_dataset;
53  std::string d_dap2ce;
54  std::string d_dap4ce;
55  std::string d_dap4function;
56  std::string d_btp_func_ce;
57  int d_timeout;
58  std::string d_default_protocol;
59 
61 
66  std::string d_async_accepted;
67 
74  std::string d_store_result;
75 
76  void initialize();
77 
78  bool store_dap2_result(ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval);
79 
80  void send_dap4_data_using_ce(std::ostream &out, libdap::DMR &dmr, bool with_mime_headersr);
81 
82 public:
83 
87  BESDapResponseBuilder(): d_dataset(""), d_dap2ce(""), d_dap4ce(""), d_dap4function(""),
88  d_btp_func_ce(""), d_timeout(0), d_default_protocol(DAP_PROTOCOL_VERSION),
89  d_cancel_timeout_on_send(false), d_async_accepted(""), d_store_result("")
90  {
91  initialize();
92  }
93 
94  virtual ~BESDapResponseBuilder();
95 
96  virtual std::string get_ce() const;
97  virtual void set_ce(std::string _ce);
98 
99  virtual std::string get_dap4ce() const;
100  virtual void set_dap4ce(std::string _ce);
101 
102  virtual std::string get_dap4function() const;
103  virtual void set_dap4function(std::string _func);
104 
105  virtual std::string get_store_result() const;
106  virtual void set_store_result(std::string _sr);
107 
108  virtual std::string get_async_accepted() const;
109  virtual void set_async_accepted(std::string _aa);
110 
111  virtual std::string get_btp_func_ce() const
112  {
113  return d_btp_func_ce;
114  }
115  virtual void set_btp_func_ce(std::string _ce)
116  {
117  d_btp_func_ce = _ce;
118  }
119 
120  virtual std::string get_dataset_name() const;
121  virtual void set_dataset_name(const std::string _dataset);
122 
127  void register_timeout() const;
129  void set_timeout(int timeout = 0);
130  int get_timeout() const;
131  void timeout_on() const;
132  void timeout_off();
134 
135  void conditional_timeout_cancel();
136 
137  virtual void establish_timeout(std::ostream &stream) const;
138  virtual void remove_timeout() const;
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  virtual void send_das(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained =
144  false, bool with_mime_headers = true);
145 
146  virtual void send_dds(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained =
147  false, bool with_mime_headers = true);
148 
149  virtual void serialize_dap2_data_dds(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
150  bool ce_eval = true);
151  virtual void send_dap2_data(std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
152  bool with_mime_headers = true);
153 
154  virtual void send_ddx(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
155  bool with_mime_headers = true);
156 
157  virtual void serialize_dap2_data_ddx(std::ostream &out, libdap::DDS & dds, libdap::ConstraintEvaluator & eval,
158  const std::string &boundary, const std::string &start, bool ce_eval = true);
159 
160  virtual void send_dmr(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
161 
162  virtual void send_dap4_data(std::ostream &out, libdap::DMR & dmr, bool with_mime_headers = true);
163 
164  virtual void serialize_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
165  virtual bool store_dap4_result(ostream &out, libdap::DMR &dmr);
166 };
167 
168 #endif // _response_builder_h
std::string d_dap4function
DAP4 Constraint expression.
std::string d_async_accepted
Should a timeout be cancelled once transmission starts?
std::string d_default_protocol
Response timeout after N seconds.
int d_timeout
The BTP functions, extracted from the CE.
std::string d_dap4ce
DAP2 Constraint expression.
std::string d_btp_func_ce
DAP4 Server Side Function expression.
bool d_cancel_timeout_on_send
Version string for the library&#39;s default protocol version.
std::string d_dap2ce
Name of the dataset/database.