libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
Connect.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) 2002,2003 OPeNDAP, Inc.
8// Author: James Gallagher <jgallagher@opendap.org>
9// Dan Holloway <dan@hollywood.gso.uri.edu>
10// Reza Nekovei <reza@intcomm.net>
11//
12// This library is free software; you can redistribute it and/or
13// modify it under the terms of the GNU Lesser General Public
14// License as published by the Free Software Foundation; either
15// version 2.1 of the License, or (at your option) any later version.
16//
17// This library is distributed in the hope that it will be useful,
18// but WITHOUT ANY WARRANTY; without even the implied warranty of
19// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20// Lesser General Public License for more details.
21//
22// You should have received a copy of the GNU Lesser General Public
23// License along with this library; if not, write to the Free Software
24// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
25//
26// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
27
28// (c) COPYRIGHT URI/MIT 1994-1999,2001,2002
29// Please first read the full copyright statement in the file COPYRIGHT_URI.
30//
31// Authors:
32// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
33// dan Dan Holloway <dholloway@gso.uri.edu>
34// reza Reza Nekovei <rnekovei@ieee.org>
35
36// Connect objects are used as containers for information pertaining to a
37// connection that a user program makes to a dataset. The dataset may be
38// either local (i.e., a file on the user's own computer) or a remote
39// dataset. In the later case a DAP2 URL will be used to reference the
40// dataset.
41//
42// Connect contains methods which can be used to read the DOS DAS and DDS
43// objects from the remote dataset as well as reading reading data. The class
44// understands in a rudimentary way how DAP2 constraint expressions are
45// formed and how to manage the CEs generated by a API to request specific
46// variables with the URL initially presented to the class when the object
47// was instantiated.
48//
49// Connect also provides additional services such as error processing.
50//
51// Connect is not intended for use on the server-side.
52//
53// jhrg 9/29/94
54
55#ifndef _connect_h
56#define _connect_h
57
58#include <string>
59
60#ifndef _das_h
61#include "DAS.h"
62#endif
63
64#ifndef _dds_h
65#include "DDS.h"
66#endif
67
68#ifndef _error_h
69#include "Error.h"
70#endif
71
72#ifndef _util_h
73#include "util.h"
74#endif
75
76#ifndef _datadds_h
77#include "DataDDS.h"
78#endif
79
80#ifndef _httpconnect_h
81#include "HTTPConnect.h"
82#endif
83
84#ifndef response_h
85#include "Response.h"
86#endif
87
88using std::string;
89
90namespace libdap {
91
126
127class Connect {
128private:
129 bool _local; // Is this a local connection?
130
131 HTTPConnect *d_http;
132 string _URL; // URL to remote dataset (minus CE)
133 string _proj; // Projection part of initial CE.
134 string _sel; // Selection of initial CE
135
136 string d_version; // Server implementation information
137 string d_protocol; // DAP protocol from the server
138
139 void process_data(DataDDS &data, Response *rs);
140 void process_data(DDS &data, Response *rs);
141
142 // Use when you cannot use libwww/libcurl. Reads HTTP response.
143 void parse_mime(Response *rs);
144
145protected:
149 Connect(const Connect &);
152
153public:
154 Connect(const string &name, string uname = "", string password = "");
155
156 virtual ~Connect();
157
158 bool is_local();
159
160 // *** Add get_* versions of accessors. 02/27/03 jhrg
161 virtual string URL(bool CE = true);
162 virtual string CE();
163
164 void set_credentials(string u, string p);
165 void set_accept_deflate(bool deflate);
166 void set_xdap_protocol(int major, int minor);
167
168 void set_cache_enabled(bool enabled);
169 bool is_cache_enabled();
170
171 void set_xdap_accept(int major, int minor);
172
182 string get_version() { return d_version; }
183
187 string get_protocol() { return d_protocol; }
188
189 virtual string request_version();
190 virtual string request_protocol();
191
192 virtual void request_das(DAS &das);
193 virtual void request_das_url(DAS &das);
194
195 virtual void request_dds(DDS &dds, string expr = "");
196 virtual void request_dds_url(DDS &dds);
197
198 virtual void request_ddx(DDS &dds, string expr = "");
199 virtual void request_ddx_url(DDS &dds);
200
201 virtual void request_data(DataDDS &data, string expr = "");
202 virtual void request_data_url(DataDDS &data);
203
204 virtual void request_data_ddx(DataDDS &data, string expr = "");
205 virtual void request_data_ddx_url(DataDDS &data);
206
207 virtual void read_data(DataDDS &data, Response *rs);
208 virtual void read_data_no_mime(DataDDS &data, Response *rs);
209 virtual void read_data(DDS &data, Response *rs);
210 virtual void read_data_no_mime(DDS &data, Response *rs);
211};
212
213} // namespace libdap
214
215#endif // _connect_h
bool is_cache_enabled()
Definition Connect.cc:1136
virtual void request_dds_url(DDS &dds)
Get the DDS from a server.
Definition Connect.cc:621
virtual string CE()
Get the Connect's constraint expression.
Definition Connect.cc:1093
void set_accept_deflate(bool deflate)
Definition Connect.cc:1113
void set_cache_enabled(bool enabled)
Definition Connect.cc:1131
string get_version()
Definition Connect.h:182
string get_protocol()
Definition Connect.h:187
virtual void request_ddx(DDS &dds, string expr="")
Get the DDX from a server.
Definition Connect.cc:681
virtual void read_data_no_mime(DataDDS &data, Response *rs)
Read data from a file which does not have response MIME headers. This method is a companion to read_d...
Definition Connect.cc:1016
void set_xdap_protocol(int major, int minor)
Definition Connect.cc:1123
virtual string URL(bool CE=true)
Get the object's URL.
Definition Connect.cc:1075
Connect & operator=(const Connect &)
Connect(const Connect &)
virtual void request_data(DataDDS &data, string expr="")
Get the DAS from a server.
Definition Connect.cc:814
virtual void request_das(DAS &das)
Get the DAS from a server.
Definition Connect.cc:419
void set_credentials(string u, string p)
Set the credentials for responding to challenges while dereferencing URLs.
Definition Connect.cc:1105
virtual void request_ddx_url(DDS &dds)
The 'url' version of request_ddx.
Definition Connect.cc:745
virtual string request_protocol()
Definition Connect.cc:389
virtual void request_data_ddx_url(DataDDS &data)
Definition Connect.cc:915
virtual void request_dds(DDS &dds, string expr="")
Get the DDS from a server.
Definition Connect.cc:545
virtual void request_data_ddx(DataDDS &data, string expr="")
Definition Connect.cc:883
void set_xdap_accept(int major, int minor)
virtual void request_das_url(DAS &das)
Get the DAS from a server.
Definition Connect.cc:482
virtual string request_version()
Definition Connect.cc:355
virtual void request_data_url(DataDDS &data)
Get the DAS from a server.
Definition Connect.cc:862
virtual ~Connect()
Definition Connect.cc:338
virtual void read_data(DataDDS &data, Response *rs)
Read data which is preceded by MIME headers. This method works for both data dds and data ddx respons...
Definition Connect.cc:948
Hold attribute data for a DAP2 dataset.
Definition DAS.h:119
Holds a DAP2 DDS.
Definition DataDDS.h:76
top level DAP object to house generic methods
Definition AISConnect.cc:30