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