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 <stdio.h>
00060 
00061 #include <string>
00062 
00063 #ifndef _das_h
00064 #include "DAS.h"
00065 #endif
00066 
00067 #ifndef _dds_h
00068 #include "DDS.h"
00069 #endif
00070 
00071 #ifndef _error_h
00072 #include "Error.h"
00073 #endif
00074 
00075 #ifndef _util_h
00076 #include "util.h"
00077 #endif
00078 
00079 #ifndef _datadds_h
00080 #include "DataDDS.h"
00081 #endif
00082 
00083 #ifndef _httpconnect_h
00084 #include "HTTPConnect.h"
00085 #endif
00086 
00087 #ifndef response_h
00088 #include "Response.h"
00089 #endif
00090 
00091 using std::string;
00092 
00132 class Connect
00133 {
00134 private:
00135     bool _local;  // Is this a local connection?
00136 
00137     HTTPConnect *d_http;
00138     string _URL;  // URL to remote dataset (minus CE)
00139     string _proj;  // Projection part of initial CE.
00140     string _sel;  // Selection of initial CE
00141 
00142     string d_version;           // Server implementation information
00143     string d_protocol;          // DAP protocol from the server
00144 
00145     void process_data(DataDDS &data, Response *rs);
00146 
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 
00178     void set_cache_enabled(bool enabled);
00179     bool is_cache_enabled();
00180 
00190     string get_version()
00191     {
00192         return d_version;
00193     }
00194 
00198     string get_protocol()
00199     {
00200         return d_protocol;
00201     }
00202 
00203 
00204     virtual string request_version();
00205     virtual string request_protocol();
00206 
00207     virtual void request_das(DAS &das);
00208     virtual void request_das_url(DAS &das);
00209 
00210     virtual void request_dds(DDS &dds, string expr = "");
00211     virtual void request_dds_url(DDS &dds);
00212 
00213     virtual void request_ddx(DDS &dds, string expr = "");
00214     virtual void request_ddx_url(DDS &dds);
00215 
00216     virtual void request_data(DataDDS &data, string expr = "");
00217     virtual void request_data_url(DataDDS &data);
00218 
00219     virtual void read_data(DataDDS &data, Response *rs);
00220     virtual void read_data_no_mime(DataDDS &data, Response *rs);
00221 };
00222 
00223 #endif // _connect_h

Generated on Wed Jun 27 12:56:38 2007 for libdap++ by  doxygen 1.4.7