libdap  Updated for version 3.20.6
libdap4 is an implementation of OPeNDAP's DAP protocol.
Connect.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) 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();
152  Connect(const Connect &);
153  Connect &operator=(const Connect &);
155 
156 public:
157  Connect(const string &name, string uname = "", string password = "");
158 
159  virtual ~Connect();
160 
161  bool is_local();
162 
163  // *** Add get_* versions of accessors. 02/27/03 jhrg
164  virtual string URL(bool CE = true);
165  virtual string CE();
166 
167  void set_credentials(string u, string p);
168  void set_accept_deflate(bool deflate);
169  void set_xdap_protocol(int major, int minor);
170 
171  void set_cache_enabled(bool enabled);
172  bool is_cache_enabled();
173 
174  void set_xdap_accept(int major, int minor);
175 
185  string get_version()
186  {
187  return d_version;
188  }
189 
193  string get_protocol()
194  {
195  return d_protocol;
196  }
197 
198  virtual string request_version();
199  virtual string request_protocol();
200 
201  virtual void request_das(DAS &das);
202  virtual void request_das_url(DAS &das);
203 
204  virtual void request_dds(DDS &dds, string expr = "");
205  virtual void request_dds_url(DDS &dds);
206 
207  virtual void request_ddx(DDS &dds, string expr = "");
208  virtual void request_ddx_url(DDS &dds);
209 
210  virtual void request_data(DataDDS &data, string expr = "");
211  virtual void request_data_url(DataDDS &data);
212 
213  virtual void request_data_ddx(DataDDS &data, string expr = "");
214  virtual void request_data_ddx_url(DataDDS &data);
215 
216  virtual void read_data(DataDDS &data, Response *rs);
217  virtual void read_data_no_mime(DataDDS &data, Response *rs);
218  virtual void read_data(DDS &data, Response *rs);
219  virtual void read_data_no_mime(DDS &data, Response *rs);
220 };
221 
222 } // namespace libdap
223 
224 #endif // _connect_h
virtual string CE()
Get the Connect&#39;s constraint expression.
Definition: Connect.cc:1146
virtual void request_das_url(DAS &das)
Get the DAS from a server.
Definition: Connect.cc:496
virtual void request_ddx(DDS &dds, string expr="")
Get the DDX from a server.
Definition: Connect.cc:705
virtual string URL(bool CE=true)
Get the object&#39;s URL.
Definition: Connect.cc:1127
void set_xdap_protocol(int major, int minor)
Definition: Connect.cc:1179
virtual void request_dds_url(DDS &dds)
Get the DDS from a server.
Definition: Connect.cc:642
Holds information about the link from a DAP2 client to a dataset.
Definition: Connect.h:129
top level DAP object to house generic methods
Definition: AISConnect.cc:30
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:989
void set_cache_enabled(bool enabled)
Definition: Connect.cc:1188
virtual void request_dds(DDS &dds, string expr="")
Get the DDS from a server.
Definition: Connect.cc:562
void set_accept_deflate(bool deflate)
Definition: Connect.cc:1168
virtual void request_data(DataDDS &data, string expr="")
Get the DAS from a server.
Definition: Connect.cc:845
string get_protocol()
Definition: Connect.h:193
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:1062
virtual void request_das(DAS &das)
Get the DAS from a server.
Definition: Connect.cc:430
virtual string request_version()
Definition: Connect.cc:362
void set_credentials(string u, string p)
Set the credentials for responding to challenges while dereferencing URLs.
Definition: Connect.cc:1159
virtual string request_protocol()
Definition: Connect.cc:398
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:896
Holds a DAP2 DDS.
Definition: DataDDS.h:77
string get_version()
Definition: Connect.h:185
virtual void request_ddx_url(DDS &dds)
The &#39;url&#39; version of request_ddx.
Definition: Connect.cc:773