<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"> <title>libdap++: Connect.h Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"> <link href="doxygen.css" rel="stylesheet" type="text/css"> </head><body> <!-- Generated by Doxygen 1.5.9 --> <div class="navigation" id="top"> <div class="tabs"> <ul> <li><a href="main.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div class="tabs"> <ul> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <h1>Connect.h</h1><a href="Connect_8h.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <a name="l00002"></a>00002 <span class="comment">// -*- mode: c++; c-basic-offset:4 -*-</span> <a name="l00003"></a>00003 <a name="l00004"></a>00004 <span class="comment">// This file is part of libdap, A C++ implementation of the OPeNDAP Data</span> <a name="l00005"></a>00005 <span class="comment">// Access Protocol.</span> <a name="l00006"></a>00006 <a name="l00007"></a>00007 <span class="comment">// Copyright (c) 2002,2003 OPeNDAP, Inc.</span> <a name="l00008"></a>00008 <span class="comment">// Author: James Gallagher <jgallagher@opendap.org></span> <a name="l00009"></a>00009 <span class="comment">// Dan Holloway <dan@hollywood.gso.uri.edu></span> <a name="l00010"></a>00010 <span class="comment">// Reza Nekovei <reza@intcomm.net></span> <a name="l00011"></a>00011 <span class="comment">//</span> <a name="l00012"></a>00012 <span class="comment">// This library is free software; you can redistribute it and/or</span> <a name="l00013"></a>00013 <span class="comment">// modify it under the terms of the GNU Lesser General Public</span> <a name="l00014"></a>00014 <span class="comment">// License as published by the Free Software Foundation; either</span> <a name="l00015"></a>00015 <span class="comment">// version 2.1 of the License, or (at your option) any later version.</span> <a name="l00016"></a>00016 <span class="comment">//</span> <a name="l00017"></a>00017 <span class="comment">// This library is distributed in the hope that it will be useful,</span> <a name="l00018"></a>00018 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span> <a name="l00019"></a>00019 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span> <a name="l00020"></a>00020 <span class="comment">// Lesser General Public License for more details.</span> <a name="l00021"></a>00021 <span class="comment">//</span> <a name="l00022"></a>00022 <span class="comment">// You should have received a copy of the GNU Lesser General Public</span> <a name="l00023"></a>00023 <span class="comment">// License along with this library; if not, write to the Free Software</span> <a name="l00024"></a>00024 <span class="comment">// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span> <a name="l00025"></a>00025 <span class="comment">//</span> <a name="l00026"></a>00026 <span class="comment">// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.</span> <a name="l00027"></a>00027 <a name="l00028"></a>00028 <span class="comment">// (c) COPYRIGHT URI/MIT 1994-1999,2001,2002</span> <a name="l00029"></a>00029 <span class="comment">// Please first read the full copyright statement in the file COPYRIGHT_URI.</span> <a name="l00030"></a>00030 <span class="comment">//</span> <a name="l00031"></a>00031 <span class="comment">// Authors:</span> <a name="l00032"></a>00032 <span class="comment">// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu></span> <a name="l00033"></a>00033 <span class="comment">// dan Dan Holloway <dholloway@gso.uri.edu></span> <a name="l00034"></a>00034 <span class="comment">// reza Reza Nekovei <rnekovei@ieee.org></span> <a name="l00035"></a>00035 <a name="l00036"></a>00036 <span class="comment">// Connect objects are used as containers for information pertaining to a</span> <a name="l00037"></a>00037 <span class="comment">// connection that a user program makes to a dataset. The dataset may be</span> <a name="l00038"></a>00038 <span class="comment">// either local (i.e., a file on the user's own computer) or a remote</span> <a name="l00039"></a>00039 <span class="comment">// dataset. In the later case a DAP2 URL will be used to reference the</span> <a name="l00040"></a>00040 <span class="comment">// dataset.</span> <a name="l00041"></a>00041 <span class="comment">//</span> <a name="l00042"></a>00042 <span class="comment">// Connect contains methods which can be used to read the DOS DAS and DDS</span> <a name="l00043"></a>00043 <span class="comment">// objects from the remote dataset as well as reading reading data. The class</span> <a name="l00044"></a>00044 <span class="comment">// understands in a rudimentary way how DAP2 constraint expressions are</span> <a name="l00045"></a>00045 <span class="comment">// formed and how to manage the CEs generated by a API to request specific</span> <a name="l00046"></a>00046 <span class="comment">// variables with the URL initially presented to the class when the object</span> <a name="l00047"></a>00047 <span class="comment">// was instantiated.</span> <a name="l00048"></a>00048 <span class="comment">//</span> <a name="l00049"></a>00049 <span class="comment">// Connect also provides additional services such as error processing.</span> <a name="l00050"></a>00050 <span class="comment">//</span> <a name="l00051"></a>00051 <span class="comment">// Connect is not intended for use on the server-side.</span> <a name="l00052"></a>00052 <span class="comment">//</span> <a name="l00053"></a>00053 <span class="comment">// jhrg 9/29/94</span> <a name="l00054"></a>00054 <a name="l00055"></a>00055 <span class="preprocessor">#ifndef _connect_h</span> <a name="l00056"></a>00056 <span class="preprocessor"></span><span class="preprocessor">#define _connect_h</span> <a name="l00057"></a>00057 <span class="preprocessor"></span> <a name="l00058"></a>00058 <a name="l00059"></a>00059 <span class="preprocessor">#include <string></span> <a name="l00060"></a>00060 <a name="l00061"></a>00061 <span class="preprocessor">#ifndef _das_h</span> <a name="l00062"></a>00062 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="DAS_8h.html">DAS.h</a>"</span> <a name="l00063"></a>00063 <span class="preprocessor">#endif</span> <a name="l00064"></a>00064 <span class="preprocessor"></span> <a name="l00065"></a>00065 <span class="preprocessor">#ifndef _dds_h</span> <a name="l00066"></a>00066 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="DDS_8h.html">DDS.h</a>"</span> <a name="l00067"></a>00067 <span class="preprocessor">#endif</span> <a name="l00068"></a>00068 <span class="preprocessor"></span> <a name="l00069"></a>00069 <span class="preprocessor">#ifndef _error_h</span> <a name="l00070"></a>00070 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="Error_8h.html">Error.h</a>"</span> <a name="l00071"></a>00071 <span class="preprocessor">#endif</span> <a name="l00072"></a>00072 <span class="preprocessor"></span> <a name="l00073"></a>00073 <span class="preprocessor">#ifndef _util_h</span> <a name="l00074"></a>00074 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="util_8h.html">util.h</a>"</span> <a name="l00075"></a>00075 <span class="preprocessor">#endif</span> <a name="l00076"></a>00076 <span class="preprocessor"></span> <a name="l00077"></a>00077 <span class="preprocessor">#ifndef _datadds_h</span> <a name="l00078"></a>00078 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="DataDDS_8h.html">DataDDS.h</a>"</span> <a name="l00079"></a>00079 <span class="preprocessor">#endif</span> <a name="l00080"></a>00080 <span class="preprocessor"></span> <a name="l00081"></a>00081 <span class="preprocessor">#ifndef _httpconnect_h</span> <a name="l00082"></a>00082 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="HTTPConnect_8h.html">HTTPConnect.h</a>"</span> <a name="l00083"></a>00083 <span class="preprocessor">#endif</span> <a name="l00084"></a>00084 <span class="preprocessor"></span> <a name="l00085"></a>00085 <span class="preprocessor">#ifndef response_h</span> <a name="l00086"></a>00086 <span class="preprocessor"></span><span class="preprocessor">#include "<a class="code" href="Response_8h.html">Response.h</a>"</span> <a name="l00087"></a>00087 <span class="preprocessor">#endif</span> <a name="l00088"></a>00088 <span class="preprocessor"></span> <a name="l00089"></a>00089 <span class="keyword">using</span> std::string; <a name="l00090"></a>00090 <a name="l00091"></a>00091 <span class="keyword">namespace </span>libdap <a name="l00092"></a>00092 { <a name="l00093"></a>00093 <a name="l00133"></a><a class="code" href="classlibdap_1_1Connect.html">00133</a> <span class="keyword">class </span><a class="code" href="classlibdap_1_1Connect.html" title="Holds information about the link from a DAP2 client to a dataset.">Connect</a> <a name="l00134"></a>00134 { <a name="l00135"></a>00135 <span class="keyword">private</span>: <a name="l00136"></a>00136 <span class="keywordtype">bool</span> _local; <span class="comment">// Is this a local connection?</span> <a name="l00137"></a>00137 <a name="l00138"></a>00138 <a class="code" href="classlibdap_1_1HTTPConnect.html">HTTPConnect</a> *d_http; <a name="l00139"></a>00139 <span class="keywordtype">string</span> _URL; <span class="comment">// URL to remote dataset (minus CE)</span> <a name="l00140"></a>00140 <span class="keywordtype">string</span> _proj; <span class="comment">// Projection part of initial CE.</span> <a name="l00141"></a>00141 <span class="keywordtype">string</span> _sel; <span class="comment">// Selection of initial CE</span> <a name="l00142"></a>00142 <a name="l00143"></a>00143 <span class="keywordtype">string</span> d_version; <span class="comment">// Server implementation information</span> <a name="l00144"></a>00144 <span class="keywordtype">string</span> d_protocol; <span class="comment">// DAP protocol from the server</span> <a name="l00145"></a>00145 <a name="l00146"></a>00146 <span class="keywordtype">void</span> process_data(<a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> &data, <a class="code" href="classlibdap_1_1Response.html">Response</a> *rs); <a name="l00147"></a>00147 <a name="l00148"></a>00148 <span class="comment">// Use when you cannot use libwww/libcurl. Reads HTTP response.</span> <a name="l00149"></a>00149 <span class="keywordtype">void</span> parse_mime(<a class="code" href="classlibdap_1_1Response.html">Response</a> *rs); <a name="l00150"></a>00150 <a name="l00151"></a>00151 <span class="keyword">protected</span>: <a name="l00154"></a><a class="code" href="classlibdap_1_1Connect.html#519d36213fc5f0fefc0c11a6b131beb8">00154</a> <a class="code" href="classlibdap_1_1Connect.html#519d36213fc5f0fefc0c11a6b131beb8">Connect</a>() <a name="l00155"></a>00155 { } <a name="l00156"></a><a class="code" href="classlibdap_1_1Connect.html#5d78784ceacab07c922c2999c335807a">00156</a> <a class="code" href="classlibdap_1_1Connect.html#519d36213fc5f0fefc0c11a6b131beb8">Connect</a>(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1Connect.html" title="Holds information about the link from a DAP2 client to a dataset.">Connect</a> &) <a name="l00157"></a>00157 { } <a name="l00158"></a><a class="code" href="classlibdap_1_1Connect.html#2b8e5380df6d65484a329fa5332ab324">00158</a> <a class="code" href="classlibdap_1_1Connect.html" title="Holds information about the link from a DAP2 client to a dataset.">Connect</a> &<a class="code" href="classlibdap_1_1Connect.html#2b8e5380df6d65484a329fa5332ab324">operator=</a>(<span class="keyword">const</span> <a class="code" href="classlibdap_1_1Connect.html" title="Holds information about the link from a DAP2 client to a dataset.">Connect</a> &) <a name="l00159"></a>00159 { <a name="l00160"></a>00160 <span class="keywordflow">throw</span> <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>(__FILE__, __LINE__, <span class="stringliteral">"Unimplemented assignment"</span>); <a name="l00161"></a>00161 } <a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="keyword">public</span>: <a name="l00165"></a>00165 <a class="code" href="classlibdap_1_1Connect.html#519d36213fc5f0fefc0c11a6b131beb8">Connect</a>(<span class="keyword">const</span> <span class="keywordtype">string</span> &name, <span class="keywordtype">string</span> uname = <span class="stringliteral">""</span>, <span class="keywordtype">string</span> password = <span class="stringliteral">""</span>) <a name="l00166"></a>00166 throw(<a class="code" href="classlibdap_1_1Error.html" title="A class for error processing.">Error</a>, <a class="code" href="classlibdap_1_1InternalErr.html" title="A class for software fault reporting.">InternalErr</a>); <a name="l00167"></a>00167 <a name="l00168"></a>00168 virtual ~<a class="code" href="classlibdap_1_1Connect.html" title="Holds information about the link from a DAP2 client to a dataset.">Connect</a>(); <a name="l00169"></a>00169 <a name="l00170"></a>00170 <span class="keywordtype">bool</span> <a class="code" href="classlibdap_1_1Connect.html#3901ce9383c3df11d1a1c28d4a09bb54">is_local</a>(); <a name="l00171"></a>00171 <a name="l00172"></a>00172 <span class="comment">// *** Add get_* versions of accessors. 02/27/03 jhrg</span> <a name="l00173"></a>00173 virtual <span class="keywordtype">string</span> <a class="code" href="classlibdap_1_1Connect.html#523bf24520185e3d71f36ac0203b98e6" title="Get the object&#39;s URL.">URL</a>(<span class="keywordtype">bool</span> <a class="code" href="classlibdap_1_1Connect.html#0e55cc99530cab779ae83984c2a22f51" title="Get the Connect&#39;s constraint expression.">CE</a> = true); <a name="l00174"></a>00174 virtual <span class="keywordtype">string</span> <a class="code" href="classlibdap_1_1Connect.html#0e55cc99530cab779ae83984c2a22f51" title="Get the Connect&#39;s constraint expression.">CE</a>(); <a name="l00175"></a>00175 <a name="l00176"></a>00176 <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#847af75e149f123a51a560119dfc06aa" title="Set the credentials for responding to challenges while dereferencing URLs.">set_credentials</a>(<span class="keywordtype">string</span> u, <span class="keywordtype">string</span> p); <a name="l00177"></a>00177 <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#186f76bfea3b61dc3587bcff5760ed8b">set_accept_deflate</a>(<span class="keywordtype">bool</span> <a class="code" href="namespacelibdap.html#ada86e90b40fc8068dbfe9be79f09e553b0e7efd18178acc018030f0e69565a5">deflate</a>); <a name="l00178"></a>00178 <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#4af759a2313d9ecbc1db1c811f549379">set_xdap_protocol</a>(<span class="keywordtype">int</span> major, <span class="keywordtype">int</span> minor); <a name="l00179"></a>00179 <a name="l00180"></a>00180 <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#25c97c4ad0239a9dd10812c880c40efe">set_cache_enabled</a>(<span class="keywordtype">bool</span> enabled); <a name="l00181"></a>00181 <span class="keywordtype">bool</span> <a class="code" href="classlibdap_1_1Connect.html#00fa7d5e2e658e8c882e07f48562ea62">is_cache_enabled</a>(); <a name="l00182"></a>00182 <a name="l00183"></a>00183 <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#b9c4a1243218c98d46fbaace37a821fc">set_xdap_accept</a>(<span class="keywordtype">int</span> major, <span class="keywordtype">int</span> minor); <a name="l00184"></a>00184 <a name="l00194"></a><a class="code" href="classlibdap_1_1Connect.html#30fe6746add5a210d59b5dc9d678355f">00194</a> <span class="keywordtype">string</span> <a class="code" href="classlibdap_1_1Connect.html#30fe6746add5a210d59b5dc9d678355f">get_version</a>() <a name="l00195"></a>00195 { <a name="l00196"></a>00196 <span class="keywordflow">return</span> d_version; <a name="l00197"></a>00197 } <a name="l00198"></a>00198 <a name="l00202"></a><a class="code" href="classlibdap_1_1Connect.html#4223a898b3da719509d173dd990c45f1">00202</a> <span class="keywordtype">string</span> <a class="code" href="classlibdap_1_1Connect.html#4223a898b3da719509d173dd990c45f1">get_protocol</a>() <a name="l00203"></a>00203 { <a name="l00204"></a>00204 <span class="keywordflow">return</span> d_protocol; <a name="l00205"></a>00205 } <a name="l00206"></a>00206 <a name="l00207"></a>00207 <a name="l00208"></a>00208 <span class="keyword">virtual</span> <span class="keywordtype">string</span> <a class="code" href="classlibdap_1_1Connect.html#c7a5896a09882004b75e581999940526">request_version</a>(); <a name="l00209"></a>00209 <span class="keyword">virtual</span> <span class="keywordtype">string</span> <a class="code" href="classlibdap_1_1Connect.html#aa1ab562899da9a4630de01f943d1aa9">request_protocol</a>(); <a name="l00210"></a>00210 <a name="l00211"></a>00211 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#816ef3bb8e729712ffeb6523f2cc4f0e" title="Get the DAS from a server.">request_das</a>(<a class="code" href="classlibdap_1_1DAS.html" title="Hold attribute data for a DAP2 dataset.">DAS</a> &das); <a name="l00212"></a>00212 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#bcf814710de1e252e74a4e1b72d3c6b3" title="Get the DAS from a server.">request_das_url</a>(<a class="code" href="classlibdap_1_1DAS.html" title="Hold attribute data for a DAP2 dataset.">DAS</a> &das); <a name="l00213"></a>00213 <a name="l00214"></a>00214 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#ad5ef370110577e9ca2a0161928f9efa" title="Get the DDS from a server.">request_dds</a>(<a class="code" href="classlibdap_1_1DDS.html">DDS</a> &dds, <span class="keywordtype">string</span> expr = <span class="stringliteral">""</span>); <a name="l00215"></a>00215 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#08795a9e160db409423fcd9058ba975d" title="Get the DDS from a server.">request_dds_url</a>(<a class="code" href="classlibdap_1_1DDS.html">DDS</a> &dds); <a name="l00216"></a>00216 <a name="l00217"></a>00217 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#4395cc18cf5ec1a5167795a5a5491958" title="Get the DDX from a server.">request_ddx</a>(<a class="code" href="classlibdap_1_1DDS.html">DDS</a> &dds, <span class="keywordtype">string</span> expr = <span class="stringliteral">""</span>); <a name="l00218"></a>00218 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#9a3e1fe01455b60a90a1974a7e871bb4" title="The &#39;url&#39; version of request_ddx.">request_ddx_url</a>(<a class="code" href="classlibdap_1_1DDS.html">DDS</a> &dds); <a name="l00219"></a>00219 <a name="l00220"></a>00220 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#814e98ac5e99927ccc79bb0feb32d241" title="Get the DAS from a server.">request_data</a>(<a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> &data, <span class="keywordtype">string</span> expr = <span class="stringliteral">""</span>); <a name="l00221"></a>00221 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#c8582099411b8d74b03e761129df5b5c" title="Get the DAS from a server.">request_data_url</a>(<a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> &data); <a name="l00222"></a>00222 <a name="l00223"></a>00223 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#e50d98d353023b9786c9bd5b0833a7de" title="Read data which is preceded by MIME headers.">read_data</a>(<a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> &data, <a class="code" href="classlibdap_1_1Response.html">Response</a> *rs); <a name="l00224"></a>00224 <span class="keyword">virtual</span> <span class="keywordtype">void</span> <a class="code" href="classlibdap_1_1Connect.html#486b095a58614dfc2be0321035784306" title="Read data from a file which does not have response MIME headers. This method is a...">read_data_no_mime</a>(<a class="code" href="classlibdap_1_1DataDDS.html" title="Holds a DAP2 DDS.">DataDDS</a> &data, <a class="code" href="classlibdap_1_1Response.html">Response</a> *rs); <a name="l00225"></a>00225 }; <a name="l00226"></a>00226 <a name="l00227"></a>00227 } <span class="comment">// namespace libdap</span> <a name="l00228"></a>00228 <a name="l00229"></a>00229 <span class="preprocessor">#endif // _connect_h</span> </pre></div></div> <hr size="1"><address style="text-align: right;"><small>Generated on Wed Oct 7 19:57:07 2009 for libdap++ by <a href="http://www.doxygen.org/index.html"> <img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.9 </small></address> </body> </html>