libdap++ Updated for version 3.8.2

Connect.h

Go to the documentation of this file.
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 
00133 class Connect
00134 {
00135 private:
00136     bool _local;  // Is this a local connection?
00137 
00138     HTTPConnect *d_http;
00139     string _URL;  // URL to remote dataset (minus CE)
00140     string _proj;  // Projection part of initial CE.
00141     string _sel;  // Selection of initial CE
00142 
00143     string d_version;           // Server implementation information
00144     string d_protocol;          // DAP protocol from the server
00145 
00146     void process_data(DataDDS &data, Response *rs);
00147     // Use when you cannot use libwww/libcurl. Reads HTTP response.
00148     void parse_mime(Response *rs);
00149 
00150 protected:
00153     Connect()
00154     { }
00155     Connect(const Connect &)
00156     { }
00157     Connect &operator=(const Connect &)
00158     {
00159         throw InternalErr(__FILE__, __LINE__, "Unimplemented assignment");
00160     }
00162 
00163 public:
00164     Connect(const string &name, string uname = "", string password = "")
00165     throw(Error, InternalErr);
00166 
00167     virtual ~Connect();
00168 
00169     bool is_local();
00170 
00171     // *** Add get_* versions of accessors. 02/27/03 jhrg
00172     virtual string URL(bool CE = true);
00173     virtual string CE();
00174 
00175     void set_credentials(string u, string p);
00176     void set_accept_deflate(bool deflate);
00177     void set_xdap_protocol(int major, int minor);
00178 
00179     void set_cache_enabled(bool enabled);
00180     bool is_cache_enabled();
00181 
00182     void set_xdap_accept(int major, int minor);
00183 
00193     string get_version()
00194     {
00195         return d_version;
00196     }
00197 
00201     string get_protocol()
00202     {
00203         return d_protocol;
00204     }
00205 
00206     virtual string request_version();
00207     virtual string request_protocol();
00208 
00209     virtual void request_das(DAS &das);
00210     virtual void request_das_url(DAS &das);
00211 
00212     virtual void request_dds(DDS &dds, string expr = "");
00213     virtual void request_dds_url(DDS &dds);
00214 
00215     virtual void request_ddx(DDS &dds, string expr = "");
00216     virtual void request_ddx_url(DDS &dds);
00217 
00218     virtual void request_data(DataDDS &data, string expr = "");
00219     virtual void request_data_url(DataDDS &data);
00220 
00221     virtual void request_data_ddx(DataDDS &data, string expr = "");
00222     virtual void request_data_ddx_url(DataDDS &data);
00223 
00224     virtual void read_data(DataDDS &data, Response *rs);
00225     virtual void read_data_no_mime(DataDDS &data, Response *rs);
00226 };
00227 
00228 } // namespace libdap
00229 
00230 #endif // _connect_h