libdap++  Updated for version 3.8.2
ResponseBuilder.h
Go to the documentation of this file.
1 
2 // -*- mode: c++; c-basic-offset:4 -*-
3 
4 // This file is part of libdap, A C++ implementation of the OPeNDAP Data
5 // Access Protocol.
6 
7 // Copyright (c) 2011 OPeNDAP, Inc.
8 // Author: James Gallagher <jgallagher@opendap.org>
9 //
10 // This library is free software; you can redistribute it and/or
11 // modify it under the terms of the GNU Lesser General Public
12 // License as published by the Free Software Foundation; either
13 // version 2.1 of the License, or (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18 // Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public
21 // License along with this library; if not, write to the Free Software
22 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 #ifndef _response_builder_h
27 #define _response_builder_h
28 
29 #include <string>
30 #include <set>
31 
32 #ifndef _das_h
33 #include "DAS.h"
34 #endif
35 
36 #ifndef _dds_h
37 #include "DDS.h"
38 #endif
39 
40 #ifndef constraint_evaluator_h
41 #include "ConstraintEvaluator.h"
42 #endif
43 
44 #ifndef _object_type_h
45 #include "ObjectType.h"
46 #endif
47 
48 #ifndef _encodingtype_h
49 #include "EncodingType.h"
50 #endif
51 
52 namespace libdap
53 {
54 
61 {
62 public:
63  friend class ResponseBuilderTest;
64 
65 protected:
66  string d_dataset;
67  string d_ce;
68  int d_timeout;
70 
71 #if 0 // Keyword support moved to Keywords class
72  set<string> d_keywords;
73  set<string> d_known_keywords;
74 #endif
75  void initialize();
76 
77 public:
78 
83  initialize();
84  }
85 
86  virtual ~ResponseBuilder();
87 #if 0
88  virtual void add_keyword(const string &kw);
89  virtual bool is_keyword(const string &kw) const;
90  virtual list<string> get_keywords() const;
91  // This method holds all of the keywords that this version of libdap groks
92  virtual bool is_known_keyword(const string &w) const;
93 #endif
94 
95  virtual string get_ce() const;
96  virtual void set_ce(string _ce);
97 
98  virtual string get_dataset_name() const;
99  virtual void set_dataset_name(const string _dataset);
100 
101  void set_timeout(int timeout = 0);
102  int get_timeout() const;
103 
104  virtual void establish_timeout(ostream &stream) const;
105 
106  virtual void send_das(ostream &out, DAS &das,
107  bool with_mime_headers = true) const;
108  virtual void send_dds(ostream &out, DDS &dds, ConstraintEvaluator &eval,
109  bool constrained = false,
110  bool with_mime_headers = true) const;
111 
112  virtual void dataset_constraint(ostream &out, DDS &dds, ConstraintEvaluator &eval,
113  bool ce_eval = true) const;
114  virtual void dataset_constraint_ddx(ostream &out, DDS & dds, ConstraintEvaluator & eval,
115  const string &boundary, const string &start,
116  bool ce_eval = true) const;
117 
118  virtual void send_data(ostream &data_stream, DDS &dds, ConstraintEvaluator &eval,
119  bool with_mime_headers = true) const;
120 
121  virtual void send_ddx(ostream &out, DDS &dds, ConstraintEvaluator &eval,
122  bool with_mime_headers = true) const;
123 
124  virtual void send_data_ddx(ostream &data_stream, DDS &dds, ConstraintEvaluator &eval,
125  const string &start, const string &boundary,
126  bool with_mime_headers = true) const;
127 
128  // These functions are used both by the methods above and by other code
129 
130  void set_mime_text(ostream &out, ObjectType type = unknown_type,
131  EncodingType enc = x_plain,
132  const time_t last_modified = 0,
133  const string &protocol = "") const;
134 
135  void set_mime_html(ostream &out, ObjectType type = unknown_type,
136  EncodingType enc = x_plain,
137  const time_t last_modified = 0,
138  const string &protocol = "") const;
139 
140  void set_mime_binary(ostream &out, ObjectType type = unknown_type,
141  EncodingType enc = x_plain,
142  const time_t last_modified = 0,
143  const string &protocol = "") const;
144 
145  void set_mime_multipart(ostream &out, const string &boundary,
146  const string &start, ObjectType type = unknown_type,
147  EncodingType enc = x_plain,
148  const time_t last_modified = 0,
149  const string &protocol = "") const;
150 
151  void set_mime_ddx_boundary(ostream &out, const string &boundary,
152  const string &start, ObjectType type = unknown_type,
153  EncodingType enc = x_plain) const;
154 
155  void set_mime_data_boundary(ostream &out, const string &boundary,
156  const string &cid, ObjectType type = unknown_type,
157  EncodingType enc = x_plain) const;
158 
159  void set_mime_error(ostream &out, int code = 404,
160  const string &reason = "Dataset not found",
161  const string &protocol = "") const;
162 };
163 
164 } // namespace libdap
165 
166 #endif // _response_builder_h
void set_mime_html(ostream &out, ObjectType type=unknown_type, EncodingType enc=x_plain, const time_t last_modified=0, const string &protocol="") const
int d_timeout
Constraint expression.
Build responses for Hyrax server modules/handlers.
void initialize()
Version string for the library's default protocol version.
void set_mime_text(ostream &out, ObjectType type=unknown_type, EncodingType enc=x_plain, const time_t last_modified=0, const string &protocol="") const
virtual void set_dataset_name(const string _dataset)
virtual void set_ce(string _ce)
string d_default_protocol
Response timeout after N seconds.
ObjectType
The type of object in the stream coming from the data server.
Definition: ObjectType.h:57
virtual void send_ddx(ostream &out, DDS &dds, ConstraintEvaluator &eval, bool with_mime_headers=true) const
virtual void establish_timeout(ostream &stream) const
string d_ce
Name of the dataset/database.
virtual void send_data(ostream &data_stream, DDS &dds, ConstraintEvaluator &eval, bool with_mime_headers=true) const
Transmit data.
void set_mime_data_boundary(ostream &out, const string &boundary, const string &cid, ObjectType type=unknown_type, EncodingType enc=x_plain) const
void set_mime_ddx_boundary(ostream &out, const string &boundary, const string &start, ObjectType type=unknown_type, EncodingType enc=x_plain) const
virtual string get_dataset_name() const
Get the dataset name.
friend class ResponseBuilderTest
virtual void send_data_ddx(ostream &data_stream, DDS &dds, ConstraintEvaluator &eval, const string &start, const string &boundary, bool with_mime_headers=true) const
Transmit data.
Evaluate a constraint expression.
void set_mime_multipart(ostream &out, const string &boundary, const string &start, ObjectType type=unknown_type, EncodingType enc=x_plain, const time_t last_modified=0, const string &protocol="") const
virtual void send_das(ostream &out, DAS &das, bool with_mime_headers=true) const
Transmit a DAS.
void set_timeout(int timeout=0)
bool is_keyword(string id, const string &keyword)
Definition: parser-util.cc:175
virtual void dataset_constraint_ddx(ostream &out, DDS &dds, ConstraintEvaluator &eval, const string &boundary, const string &start, bool ce_eval=true) const
Hold attribute data for a DAP2 dataset.
Definition: DAS.h:123
EncodingType
The type of encoding used on the current stream.
Definition: EncodingType.h:48
virtual void dataset_constraint(ostream &out, DDS &dds, ConstraintEvaluator &eval, bool ce_eval=true) const
void set_mime_binary(ostream &out, ObjectType type=unknown_type, EncodingType enc=x_plain, const time_t last_modified=0, const string &protocol="") const
void set_mime_error(ostream &out, int code=404, const string &reason="Dataset not found", const string &protocol="") const
virtual void send_dds(ostream &out, DDS &dds, ConstraintEvaluator &eval, bool constrained=false, bool with_mime_headers=true) const
Transmit a DDS.
virtual string get_ce() const
Get the constraint expression.