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_ce;
52  std::string d_btp_func_ce;
53  int d_timeout;
54  std::string d_default_protocol;
55 
57 
58  void initialize();
59 
60 public:
61 
66  {
67  initialize();
68  }
69 
70  virtual ~BESDapResponseBuilder();
71 
72  virtual std::string get_ce() const;
73  virtual void set_ce(std::string _ce);
74 
75  virtual std::string get_btp_func_ce() const
76  {
77  return d_btp_func_ce;
78  }
79  virtual void set_btp_func_ce(std::string _ce)
80  {
81  d_btp_func_ce = _ce;
82  }
83 
84  virtual std::string get_dataset_name() const;
85  virtual void set_dataset_name(const std::string _dataset);
86 
87  void set_timeout(int timeout = 0);
88  int get_timeout() const;
89 
90  virtual void establish_timeout(std::ostream &stream) const;
91 
92  virtual void split_ce(libdap::ConstraintEvaluator &eval, const std::string &expr = "");
93 
95 
96  virtual void send_das(std::ostream &out, libdap::DAS &das, bool with_mime_headers = true) const;
97  virtual void send_das(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained =
98  false, bool with_mime_headers = true);
99 
100  virtual void send_dds(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool constrained =
101  false, bool with_mime_headers = true);
102 
103  virtual void dataset_constraint(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
104  bool ce_eval = true);
105  virtual void send_data(std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
106  bool with_mime_headers = true);
107 
108  virtual void send_ddx(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
109  bool with_mime_headers = true);
110 
111  virtual void dataset_constraint_ddx(std::ostream &out, libdap::DDS & dds, libdap::ConstraintEvaluator & eval,
112  const std::string &boundary, const std::string &start, bool ce_eval = true);
113 #if 0
114  virtual void send_dmr(std::ostream &out, libdap::DMR &dmr, libdap::ConstraintEvaluator &eval, bool constrained =
115  false, bool with_mime_headers = true);
116 
117  virtual void send_dap4_data(std::ostream &data_stream, libdap::DMR & dmr, libdap::ConstraintEvaluator & eval,
118  bool with_mime_headers);
119 #endif
120  // TODO
121  // Is this used by the code that caches function results? If not, remove.
122  virtual void send_data_ddx(std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval,
123  const std::string &start, const std::string &boundary, bool with_mime_headers = true);
124 };
125 
126 #endif // _response_builder_h
virtual void dataset_constraint(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool ce_eval=true)
Build/return the BLOB part of the DAP2 data response.
virtual std::string get_ce() const
Return the entire constraint expression in a string.
virtual std::string get_btp_func_ce() const
std::string d_ce
Name of the dataset/database.
std::string d_default_protocol
Response timeout after N seconds.
This class is used to cache DAP2 response objects.
virtual void send_das(std::ostream &out, libdap::DAS &das, bool with_mime_headers=true) const
BESDapResponseBuilder()
Make an empty instance.
virtual void send_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 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.
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...
std::string d_btp_func_ce
Constraint expression.
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 send_ddx(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers=true)
Send the DDX response.
virtual void send_data_ddx(std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, const std::string &start, const std::string &boundary, bool with_mime_headers=true)
Send the data in the DDS object back to the client program.
This class is used to build responses for/by the BES.
int get_timeout() const
Get the server's timeout value.
virtual void dataset_constraint_ddx(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, const std::string &boundary, const std::string &start, bool ce_eval=true)
Build/return the DDX and the BLOB part of the DAP3.x data response.
virtual void set_ce(std::string _ce)
Set the constraint expression.
virtual void establish_timeout(std::ostream &stream) const
Use values of this instance to establish a timeout alarm for the server.
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 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.
BESDapResponseCache * d_response_cache
Version std::string for the library's default protocol version.