libdap++
Updated for version 3.8.2
|
00001 00002 // -*- mode: c++; c-basic-offset:4 -*- 00003 00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data 00005 // Access Protocol. 00006 00007 // Copyright (c) 2002,2003 OPeNDAP, Inc. 00008 // Author: James Gallagher <jgallagher@opendap.org> 00009 // Dan Holloway <dan@hollywood.gso.uri.edu> 00010 // Reza Nekovei <reza@intcomm.net> 00011 // 00012 // This library is free software; you can redistribute it and/or 00013 // modify it under the terms of the GNU Lesser General Public 00014 // License as published by the Free Software Foundation; either 00015 // version 2.1 of the License, or (at your option) any later version. 00016 // 00017 // This library is distributed in the hope that it will be useful, 00018 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00020 // Lesser General Public License for more details. 00021 // 00022 // You should have received a copy of the GNU Lesser General Public 00023 // License along with this library; if not, write to the Free Software 00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00025 // 00026 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. 00027 00028 // (c) COPYRIGHT URI/MIT 1994-1999,2001,2002 00029 // Please first read the full copyright statement in the file COPYRIGHT_URI. 00030 // 00031 // Authors: 00032 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu> 00033 // dan Dan Holloway <dholloway@gso.uri.edu> 00034 // reza Reza Nekovei <rnekovei@ieee.org> 00035 00036 // Connect objects are used as containers for information pertaining to a 00037 // connection that a user program makes to a dataset. The dataset may be 00038 // either local (i.e., a file on the user's own computer) or a remote 00039 // dataset. In the later case a DAP2 URL will be used to reference the 00040 // dataset. 00041 // 00042 // Connect contains methods which can be used to read the DOS DAS and DDS 00043 // objects from the remote dataset as well as reading reading data. The class 00044 // understands in a rudimentary way how DAP2 constraint expressions are 00045 // formed and how to manage the CEs generated by a API to request specific 00046 // variables with the URL initially presented to the class when the object 00047 // was instantiated. 00048 // 00049 // Connect also provides additional services such as error processing. 00050 // 00051 // Connect is not intended for use on the server-side. 00052 // 00053 // jhrg 9/29/94 00054 00055 #ifndef _connect_h 00056 #define _connect_h 00057 00058 00059 #include <string> 00060 00061 #ifndef _das_h 00062 #include "DAS.h" 00063 #endif 00064 00065 #ifndef _dds_h 00066 #include "DDS.h" 00067 #endif 00068 00069 #ifndef _error_h 00070 #include "Error.h" 00071 #endif 00072 00073 #ifndef _util_h 00074 #include "util.h" 00075 #endif 00076 00077 #ifndef _datadds_h 00078 #include "DataDDS.h" 00079 #endif 00080 00081 #ifndef _httpconnect_h 00082 #include "HTTPConnect.h" 00083 #endif 00084 00085 #ifndef response_h 00086 #include "Response.h" 00087 #endif 00088 00089 using std::string; 00090 00091 namespace libdap 00092 { 00093 00129 class Connect 00130 { 00131 private: 00132 bool _local; // Is this a local connection? 00133 00134 HTTPConnect *d_http; 00135 string _URL; // URL to remote dataset (minus CE) 00136 string _proj; // Projection part of initial CE. 00137 string _sel; // Selection of initial CE 00138 00139 string d_version; // Server implementation information 00140 string d_protocol; // DAP protocol from the server 00141 00142 void process_data(DataDDS &data, Response *rs); 00143 // Use when you cannot use libwww/libcurl. Reads HTTP response. 00144 void parse_mime(Response *rs); 00145 00146 protected: 00149 Connect() : d_http(0) 00150 { } 00151 Connect(const Connect &) : d_http(0) 00152 { } 00153 Connect &operator=(const Connect &) 00154 { 00155 throw InternalErr(__FILE__, __LINE__, "Unimplemented assignment"); 00156 } 00158 00159 public: 00160 Connect(const string &name, string uname = "", string password = "") 00161 throw(Error, InternalErr); 00162 00163 virtual ~Connect(); 00164 00165 bool is_local(); 00166 00167 // *** Add get_* versions of accessors. 02/27/03 jhrg 00168 virtual string URL(bool CE = true); 00169 virtual string CE(); 00170 00171 void set_credentials(string u, string p); 00172 void set_accept_deflate(bool deflate); 00173 void set_xdap_protocol(int major, int minor); 00174 00175 void set_cache_enabled(bool enabled); 00176 bool is_cache_enabled(); 00177 00178 void set_xdap_accept(int major, int minor); 00179 00189 string get_version() 00190 { 00191 return d_version; 00192 } 00193 00197 string get_protocol() 00198 { 00199 return d_protocol; 00200 } 00201 00202 virtual string request_version(); 00203 virtual string request_protocol(); 00204 00205 virtual void request_das(DAS &das); 00206 virtual void request_das_url(DAS &das); 00207 00208 virtual void request_dds(DDS &dds, string expr = ""); 00209 virtual void request_dds_url(DDS &dds); 00210 00211 virtual void request_ddx(DDS &dds, string expr = ""); 00212 virtual void request_ddx_url(DDS &dds); 00213 00214 virtual void request_data(DataDDS &data, string expr = ""); 00215 virtual void request_data_url(DataDDS &data); 00216 00217 virtual void request_data_ddx(DataDDS &data, string expr = ""); 00218 virtual void request_data_ddx_url(DataDDS &data); 00219 00220 virtual void read_data(DataDDS &data, Response *rs); 00221 virtual void read_data_no_mime(DataDDS &data, Response *rs); 00222 }; 00223 00224 } // namespace libdap 00225 00226 #endif // _connect_h