libdap++  Updated for version 3.14.0
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 namespace libdap
32 {
33 
34 class HTTPConnect;
35 class DMR;
36 class Response;
37 
38 class D4Connect
39 {
40 private:
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_dap4ce; // 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 protected:
58  D4Connect();
59  D4Connect(const D4Connect &);
60  D4Connect &operator=(const D4Connect &);
61 
62 public:
63  D4Connect(const std::string &url, std::string uname = "", std::string password = "");
64 
65  virtual ~D4Connect();
66 
67  bool is_local() const { return d_local; }
68 
69  virtual std::string URL() const { return d_URL; }
70  virtual std::string CE() const { return d_dap4ce; }
71 
72  void set_credentials(std::string u, std::string p);
73  void set_accept_deflate(bool deflate);
74  void set_xdap_protocol(int major, int minor);
75 
76  void set_cache_enabled(bool enabled);
77  bool is_cache_enabled();
78 
79  void set_xdap_accept(int major, int minor);
80 
90  std::string get_version() { return d_server; }
91 
95  std::string get_protocol() { return d_protocol; }
96 
97  virtual void request_dmr(DMR &dmr, const std::string expr = "");
98  virtual void request_dap4_data(DMR &dmr, const std::string expr = "");
99 #if 0
100  virtual void request_version();
101 #endif
102 
103  virtual void read_dmr(DMR &dmr, Response &rs);
104  virtual void read_dmr_no_mime(DMR &dmr, Response &rs);
105 
106  virtual void read_data(DMR &data, Response &rs);
107  virtual void read_data_no_mime(DMR &data, Response &rs);
108 };
109 
110 } // namespace libdap
111 
112 #endif // _d4connect_h
void set_credentials(std::string u, std::string p)
Set the credentials for responding to challenges while dereferencing URLs.
Definition: D4Connect.cc:1107
std::string get_version()
Definition: D4Connect.h:90
void set_xdap_protocol(int major, int minor)
Definition: D4Connect.cc:1127
D4Connect & operator=(const D4Connect &)
std::string get_protocol()
Definition: D4Connect.h:95
void set_accept_deflate(bool deflate)
Definition: D4Connect.cc:1116
virtual ~D4Connect()
Definition: D4Connect.cc:281
void set_cache_enabled(bool enabled)
Definition: D4Connect.cc:1136
virtual void request_dmr(DMR &dmr, const std::string expr="")
Definition: D4Connect.cc:286
void set_xdap_accept(int major, int minor)
virtual std::string CE() const
Definition: D4Connect.h:70
virtual void read_dmr(DMR &dmr, Response &rs)
Definition: D4Connect.cc:1048
virtual void request_dap4_data(DMR &dmr, const std::string expr="")
Definition: D4Connect.cc:329
virtual void read_dmr_no_mime(DMR &dmr, Response &rs)
Definition: D4Connect.cc:1058
virtual void read_data_no_mime(DMR &data, Response &rs)
Definition: D4Connect.cc:1085
bool is_cache_enabled()
Definition: D4Connect.cc:1142
virtual std::string URL() const
Definition: D4Connect.h:69
virtual void read_data(DMR &data, Response &rs)
Definition: D4Connect.cc:1076
bool is_local() const
Definition: D4Connect.h:67