libdap Updated for version 3.20.11
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4Connect.h
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) 2013 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 _d4connect_h
27#define _d4connect_h
28
29#include <string>
30
31#define DAP4_CE_QUERY_KEY "dap4.ce"
32
33namespace libdap
34{
35
36class HTTPConnect;
37class DMR;
38class Response;
39
41{
42private:
43 HTTPConnect *d_http;
44
45 bool d_local; // Is this a local connection?
46 std::string d_URL; // URL to remote dataset (minus CE)
47 std::string d_UrlQueryString; // CE
48
49 std::string d_server; // Server implementation information (the XDAP-Server header)
50 std::string d_protocol; // DAP protocol from the server (XDAP)
51
52 void process_data(DMR &data, Response &rs);
53 void process_dmr(DMR &data, Response &rs);
54
55 // Use when you cannot use but have a complete response with MIME headers
56 void parse_mime(Response &rs);
57
58 std::string build_dap4_ce(const std::string requestSuffix, const std::string expr);
59
60protected:
62 D4Connect();
63 D4Connect(const D4Connect &);
64 D4Connect &operator=(const D4Connect &);
65
66public:
67 D4Connect(const std::string &url, std::string uname = "", std::string password = "");
68
69 virtual ~D4Connect();
70
71 bool is_local() const { return d_local; }
72
73 virtual std::string URL() const { return d_URL; }
74 virtual std::string CE() const { return d_UrlQueryString; }
75
76 void set_credentials(std::string u, std::string p);
77 void set_accept_deflate(bool deflate);
78 void set_xdap_protocol(int major, int minor);
79
80 void set_cache_enabled(bool enabled);
81 bool is_cache_enabled();
82
83 void set_xdap_accept(int major, int minor);
84
94 std::string get_version() { return d_server; }
95
99 std::string get_protocol() { return d_protocol; }
100
101 virtual void request_dmr(DMR &dmr, const std::string expr = "");
102 virtual void request_dap4_data(DMR &dmr, const std::string expr = "");
103#if 0
104 virtual void request_version();
105#endif
106
107 virtual void read_dmr(DMR &dmr, Response &rs);
108 virtual void read_dmr_no_mime(DMR &dmr, Response &rs);
109
110 virtual void read_data(DMR &data, Response &rs);
111 virtual void read_data_no_mime(DMR &data, Response &rs);
112};
113
114} // namespace libdap
115
116#endif // _d4connect_h
std::string get_protocol()
Definition: D4Connect.h:99
void set_accept_deflate(bool deflate)
Definition: D4Connect.cc:483
void set_cache_enabled(bool enabled)
Definition: D4Connect.cc:501
void set_xdap_protocol(int major, int minor)
Definition: D4Connect.cc:493
void set_credentials(std::string u, std::string p)
Set the credentials for responding to challenges while dereferencing URLs.
Definition: D4Connect.cc:475
std::string get_version()
Definition: D4Connect.h:94
top level DAP object to house generic methods
Definition: AlarmHandler.h:36