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 
00148     // Use when you cannot use libwww/libcurl. Reads HTTP response.
00149     void parse_mime(Response *rs);
00150 
00151 protected:
00154     Connect()
00155     { }
00156     Connect(const Connect &)
00157     { }
00158     Connect &operator=(const Connect &)
00159     {
00160         throw InternalErr(__FILE__, __LINE__, "Unimplemented assignment");
00161     }
00163 
00164 public:
00165     Connect(const string &name, string uname = "", string password = "")
00166     throw(Error, InternalErr);
00167 
00168     virtual ~Connect();
00169 
00170     bool is_local();
00171 
00172     // *** Add get_* versions of accessors. 02/27/03 jhrg
00173     virtual string URL(bool CE = true);
00174     virtual string CE();
00175 
00176     void set_credentials(string u, string p);
00177     void set_accept_deflate(bool deflate);
00178 
00179     void set_cache_enabled(bool enabled);
00180     bool is_cache_enabled();
00181 
00191     string get_version()
00192     {
00193         return d_version;
00194     }
00195 
00199     string get_protocol()
00200     {
00201         return d_protocol;
00202     }
00203 
00204 
00205     virtual string request_version();
00206     virtual string request_protocol();
00207 
00208     virtual void request_das(DAS &das);
00209     virtual void request_das_url(DAS &das);
00210 
00211     virtual void request_dds(DDS &dds, string expr = "");
00212     virtual void request_dds_url(DDS &dds);
00213 
00214     virtual void request_ddx(DDS &dds, string expr = "");
00215     virtual void request_ddx_url(DDS &dds);
00216 
00217     virtual void request_data(DataDDS &data, string expr = "");
00218     virtual void request_data_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

Generated on Tue Jun 10 18:00:29 2008 for libdap++ by  doxygen 1.5.4