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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  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 
31 namespace libdap {
32 
33 class ConstraintEvaluator;
34 class DDS;
35 
36 /**
37  * Used for testing only. This duplicates code in the bes/dap module.
38  * jhrg 6/11/13
39  */
40 
41 class ResponseBuilder
42 {
43 public:
44     friend class ResponseBuilderTest;
45 
46 protected:
47     std::string d_dataset;  		/// Name of the dataset/database
48     std::string d_dap2ce;  		    /// Constraint expression
49     std::string d_dap2_btp_func_ce;   /// The BTP functions, extracted from the CE
50     int d_timeout;  		/// Response timeout after N seconds
51     std::string d_default_protocol;	/// Version std::string for the library's default protocol version
52 
53     void initialize();
54 
55 public:
56 
57     /** Make an empty instance. Use the set_*() methods to load with needed
58         values. You must call at least set_dataset_name() or be requesting
59         version information. */
ResponseBuilder()60     ResponseBuilder() {
61         initialize();
62     }
63 
64     virtual ~ResponseBuilder();
65 
66     virtual std::string get_ce() const;
67     virtual void set_ce(std::string _ce);
68 
69     void split_ce(ConstraintEvaluator &eval, const string &expr = "");
70 
71     virtual std::string get_dataset_name() const;
72     virtual void set_dataset_name(const std::string _dataset);
73 
74     virtual void dataset_constraint(std::ostream &out, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool ce_eval = true);
75     virtual void send_data(std::ostream &data_stream, libdap::DDS &dds, libdap::ConstraintEvaluator &eval, bool with_mime_headers = true);
76 };
77 
78 }
79 #endif // _response_builder_h
80