OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
BESDapResponseBuilder.h
Go to the documentation of this file.
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 
31 
32 namespace libdap {
33  class ConstraintEvaluator;
34  class DDS;
35  class DAS;
36 }
37 
46 public:
47  friend class ResponseBuilderTest;
48 
49 protected:
50  std::string d_dataset;
51  std::string d_dap2ce;
52  std::string d_dap4ce;
53  std::string d_dap4function;
54  std::string d_btp_func_ce;
55  int d_timeout;
56  std::string d_default_protocol;
57 
62  std::string d_async_accepted;
63 
70  std::string d_store_result;
71 
72 
74 
75  void initialize();
76  bool store_dap2_result(ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval);
77 
78  void send_dap4_data_using_ce(std::ostream &out, libdap::DMR &dmr, bool with_mime_headersr);
79 
80 public:
81 
86  {
87  initialize();
88  }
89 
90  virtual ~BESDapResponseBuilder();
91 
92  virtual std::string get_ce() const;
93  virtual void set_ce(std::string _ce);
94 
95  virtual std::string get_dap4ce() const;
96  virtual void set_dap4ce(std::string _ce);
97 
98  virtual std::string get_dap4function() const;
99  virtual void set_dap4function(std::string _func);
100 
101  virtual std::string get_store_result() const;
102  virtual void set_store_result(std::string _sr);
103 
104  virtual std::string get_async_accepted() const;
105  virtual void set_async_accepted(std::string _aa);
106 
107  virtual std::string get_btp_func_ce() const
108  {
109  return d_btp_func_ce;
110  }
111  virtual void set_btp_func_ce(std::string _ce)
112  {
113  d_btp_func_ce = _ce;
114  }
115 
116  virtual std::string get_dataset_name() const;
117  virtual void set_dataset_name(const std::string _dataset);
118 
119  void set_timeout(int timeout = 0);
120  int get_timeout() const;
121 
122  virtual void establish_timeout(std::ostream &stream) const;
123  virtual void remove_timeout() const;
124 
125  virtual void split_ce(libdap::ConstraintEvaluator &eval, const std::string &expr = "");
126 
128 
129  virtual void send_das(std::ostream &out, libdap::DAS &das, bool with_mime_headers = true) const;
130  virtual void send_das(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained =
131  false, bool with_mime_headers = true);
132 
133  virtual void send_dds(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained =
134  false, bool with_mime_headers = true);
135 
136  virtual void serialize_dap2_data_dds(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
137  bool ce_eval = true);
138  virtual void send_dap2_data(std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
139  bool with_mime_headers = true);
140 
141  virtual void send_ddx(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
142  bool with_mime_headers = true);
143 
144  virtual void serialize_dap2_data_ddx(std::ostream &out, libdap::DDS & dds, libdap::ConstraintEvaluator & eval,
145  const std::string &boundary, const std::string &start, bool ce_eval = true);
146 
147  virtual void send_dmr(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
148 
149  virtual void send_dap4_data(std::ostream &out, libdap::DMR & dmr, bool with_mime_headers = true);
150 
151  virtual void serialize_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers = true);
152  virtual bool store_dap4_result(ostream &out, libdap::DMR &dmr);
153 };
154 
155 #endif // _response_builder_h
virtual void send_dmr(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
virtual std::string get_ce() const
Return the entire DAP2 constraint expression in a string.
virtual std::string get_btp_func_ce() const
virtual std::string get_dap4ce() const
Return the entire DAP4 constraint expression in a string.
std::string d_dap4function
DAP4 Constraint expression.
virtual void serialize_dap2_data_dds(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool ce_eval=true)
Build/return the BLOB part of the DAP2 data response.
std::string d_async_accepted
Version std::string for the library's default protocol version.
std::string d_default_protocol
Response timeout after N seconds.
This class is used to cache DAP2 response objects.
virtual void send_dap2_data(std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
Send the data in the DDS object back to the client program.
virtual void send_das(std::ostream &out, libdap::DAS &das, bool with_mime_headers=true) const
BESDapResponseBuilder()
Make an empty instance.
virtual std::string get_dap4function() const
Return the entire DAP4 server side function expression in a string.
static class NCMLUtil overview
virtual void set_btp_func_ce(std::string _ce)
virtual BESDapResponseCache * responseCache()
Lazy getter for the ResponseCache.
void initialize()
Called when initializing a ResponseBuilder that's not going to be passed command line arguments...
int d_timeout
The BTP functions, extracted from the CE.
std::string d_dap4ce
DAP2 Constraint expression.
virtual void split_ce(libdap::ConstraintEvaluator &eval, const std::string &expr="")
Split the CE so that the server functions that compute new values are separated into their own string...
virtual std::string get_store_result() const
virtual void remove_timeout() const
std::string d_btp_func_ce
DAP4 Server Side Function expression.
virtual void set_async_accepted(std::string _aa)
void set_timeout(int timeout=0)
Set the server's timeout value.
virtual void set_dataset_name(const std::string _dataset)
Set the dataset name, which is a string used to access the dataset on the machine running the server...
virtual void set_dap4function(std::string _func)
Set the DAP4 Server Side Fucntion expression.
virtual void send_ddx(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
Send the DDX response.
virtual void send_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
virtual void serialize_dap2_data_ddx(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, const std::string &boundary, const std::string &start, bool ce_eval=true)
Serialize a DAP3.2 DataDDX to the stream "out".
This class is used to build responses for/by the BES.
int get_timeout() const
Get the server's timeout value.
virtual std::string get_async_accepted() const
virtual void set_ce(std::string _ce)
Set the DAP2 constraint expression.
bool store_dap2_result(ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval)
Should this result be returned using the asynchronous response mechanism? Look at the 'store_result' ...
std::string d_dap2ce
Name of the dataset/database.
virtual void establish_timeout(std::ostream &stream) const
Use values of this instance to establish a timeout alarm for the server.
virtual bool store_dap4_result(ostream &out, libdap::DMR &dmr)
Should this DAP4 result be stored and the client sent an Asynchronous response? This code looks at th...
virtual std::string get_dataset_name() const
The ``dataset name'' is the filename or other string that the filter program will use to access the d...
virtual void set_dap4ce(std::string _ce)
Set the DAP4 constraint expression.
virtual void set_store_result(std::string _sr)
virtual void serialize_dap4_data(std::ostream &out, libdap::DMR &dmr, bool with_mime_headers=true)
Serialize the DAP4 data response to the passed stream.
virtual void send_dds(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true)
This function formats and prints an ASCII representation of a DDS on stdout.
void send_dap4_data_using_ce(std::ostream &out, libdap::DMR &dmr, bool with_mime_headersr)
std::string d_store_result
If set (i.e.
BESDapResponseCache * d_response_cache