libdap++  Updated for version 3.12.0
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 
59 #include <string>
60 
61 #ifndef _das_h
62 #include "DAS.h"
63 #endif
64 
65 #ifndef _dds_h
66 #include "DDS.h"
67 #endif
68 
69 #ifndef _error_h
70 #include "Error.h"
71 #endif
72 
73 #ifndef _util_h
74 #include "util.h"
75 #endif
76 
77 #ifndef _datadds_h
78 #include "DataDDS.h"
79 #endif
80 
81 #ifndef _httpconnect_h
82 #include "HTTPConnect.h"
83 #endif
84 
85 #ifndef response_h
86 #include "Response.h"
87 #endif
88 
89 using std::string;
90 
91 namespace libdap
92 {
93 
129 class Connect
130 {
131 private:
132  bool _local; // Is this a local connection?
133 
134  HTTPConnect *d_http;
135  string _URL; // URL to remote dataset (minus CE)
136  string _proj; // Projection part of initial CE.
137  string _sel; // Selection of initial CE
138 
139  string d_version; // Server implementation information
140  string d_protocol; // DAP protocol from the server
141 
142  void process_data(DataDDS &data, Response *rs);
143  void process_data(DDS &data, Response *rs);
144 
145  // Use when you cannot use libwww/libcurl. Reads HTTP response.
146  void parse_mime(Response *rs);
147 
148 protected:
151  Connect() : d_http(0)
152  { }
153  Connect(const Connect &) : d_http(0)
154  { }
156  {
157  throw InternalErr(__FILE__, __LINE__, "Unimplemented assignment");
158  }
160 
161 public:
162  Connect(const string &name, string uname = "", string password = "")
163  throw(Error, InternalErr);
164 
165  virtual ~Connect();
166 
167  bool is_local();
168 
169  // *** Add get_* versions of accessors. 02/27/03 jhrg
170  virtual string URL(bool CE = true);
171  virtual string CE();
172 
173  void set_credentials(string u, string p);
174  void set_accept_deflate(bool deflate);
175  void set_xdap_protocol(int major, int minor);
176 
177  void set_cache_enabled(bool enabled);
178  bool is_cache_enabled();
179 
180  void set_xdap_accept(int major, int minor);
181 
191  string get_version()
192  {
193  return d_version;
194  }
195 
199  string get_protocol()
200  {
201  return d_protocol;
202  }
203 
204  virtual string request_version();
205  virtual string request_protocol();
206 
207  virtual void request_das(DAS &das);
208  virtual void request_das_url(DAS &das);
209 
210  virtual void request_dds(DDS &dds, string expr = "");
211  virtual void request_dds_url(DDS &dds);
212 
213  virtual void request_ddx(DDS &dds, string expr = "");
214  virtual void request_ddx_url(DDS &dds);
215 
216  virtual void request_data(DataDDS &data, string expr = "");
217  virtual void request_data_url(DataDDS &data);
218 
219  virtual void request_data_ddx(DataDDS &data, string expr = "");
220  virtual void request_data_ddx_url(DataDDS &data);
221 
222  virtual void read_data(DataDDS &data, Response *rs);
223  virtual void read_data_no_mime(DataDDS &data, Response *rs);
224  virtual void read_data(DDS &data, Response *rs);
225  virtual void read_data_no_mime(DDS &data, Response *rs);
226 };
227 
228 } // namespace libdap
229 
230 #endif // _connect_h
virtual string CE()
Get the Connect's constraint expression.
Definition: Connect.cc:1180
virtual void request_das_url(DAS &das)
Get the DAS from a server.
Definition: Connect.cc:516
virtual void request_ddx(DDS &dds, string expr="")
Get the DDX from a server.
Definition: Connect.cc:725
virtual string URL(bool CE=true)
Get the object's URL.
Definition: Connect.cc:1161
Connect & operator=(const Connect &)
Definition: Connect.h:155
void set_xdap_protocol(int major, int minor)
Definition: Connect.cc:1213
virtual void request_dds_url(DDS &dds)
Get the DDS from a server.
Definition: Connect.cc:662
Holds information about the link from a DAP2 client to a dataset.
Definition: Connect.h:129
bool is_local()
Definition: Connect.cc:1140
A class for software fault reporting.
Definition: InternalErr.h:64
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:1029
void set_cache_enabled(bool enabled)
Definition: Connect.cc:1222
void set_xdap_accept(int major, int minor)
bool is_cache_enabled()
Definition: Connect.cc:1228
virtual void request_dds(DDS &dds, string expr="")
Get the DDS from a server.
Definition: Connect.cc:582
void set_accept_deflate(bool deflate)
Definition: Connect.cc:1202
virtual void request_data(DataDDS &data, string expr="")
Get the DAS from a server.
Definition: Connect.cc:887
string get_protocol()
Definition: Connect.h:199
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:1096
virtual void request_das(DAS &das)
Get the DAS from a server.
Definition: Connect.cc:450
Connect(const Connect &)
Definition: Connect.h:153
virtual string request_version()
Definition: Connect.cc:382
virtual void request_data_ddx_url(DataDDS &data)
Definition: Connect.cc:994
virtual void request_data_ddx(DataDDS &data, string expr="")
Definition: Connect.cc:960
void set_credentials(string u, string p)
Set the credentials for responding to challenges while dereferencing URLs.
Definition: Connect.cc:1193
virtual string request_protocol()
Definition: Connect.cc:418
Hold attribute data for a DAP2 dataset.
Definition: DAS.h:121
virtual void request_data_url(DataDDS &data)
Get the DAS from a server.
Definition: Connect.cc:938
A class for error processing.
Definition: Error.h:90
Holds a DAP2 DDS.
Definition: DataDDS.h:77
string get_version()
Definition: Connect.h:191
virtual void request_ddx_url(DDS &dds)
The 'url' version of request_ddx.
Definition: Connect.cc:805