Connect.h
// -*- mode: c++; c-basic-offset:4 -*-
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.
// Copyright (c) 2002,2003 OPeNDAP, Inc.
// Author: James Gallagher <jgallagher@opendap.org>
// Dan Holloway <dan@hollywood.gso.uri.edu>
// Reza Nekovei <reza@intcomm.net>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
// (c) COPYRIGHT URI/MIT 1994-1999,2001,2002
// Please first read the full copyright statement in the file COPYRIGHT_URI.
//
// Authors:
// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
// dan Dan Holloway <dholloway@gso.uri.edu>
// reza Reza Nekovei <rnekovei@ieee.org>
// Connect objects are used as containers for information pertaining to a
// connection that a user program makes to a dataset. The dataset may be
// either local (i.e., a file on the user's own computer) or a remote
// dataset. In the later case a DAP2 URL will be used to reference the
// dataset.
//
// Connect contains methods which can be used to read the DOS DAS and DDS
// objects from the remote dataset as well as reading reading data. The class
// understands in a rudimentary way how DAP2 constraint expressions are
// formed and how to manage the CEs generated by a API to request specific
// variables with the URL initially presented to the class when the object
// was instantiated.
//
// Connect also provides additional services such as error processing.
//
// Connect is not intended for use on the server-side.
//
// jhrg 9/29/94
#ifndef _connect_h
#define _connect_h
#include <string>
#ifndef _das_h
#include "DAS.h"
#endif
#ifndef _dds_h
#include "DDS.h"
#endif
#ifndef _error_h
#include "Error.h"
#endif
#ifndef _util_h
#include "util.h"
#endif
#ifndef _datadds_h
#include "DataDDS.h"
#endif
#ifndef _httpconnect_h
#include "HTTPConnect.h"
#endif
#ifndef response_h
#include "Response.h"
#endif
using std::string;
namespace libdap
{
class Connect
{
private:
bool _local; // Is this a local connection?
HTTPConnect *d_http;
string _URL; // URL to remote dataset (minus CE)
string _proj; // Projection part of initial CE.
string _sel; // Selection of initial CE
string d_version; // Server implementation information
string d_protocol; // DAP protocol from the server
void process_data(DataDDS &data, Response *rs);
void process_data(DDS &data, Response *rs);
// Use when you cannot use libwww/libcurl. Reads HTTP response.
void parse_mime(Response *rs);
protected:
Connect();
Connect(const Connect &);
Connect &operator=(const Connect &);
public:
Connect(const string &name, string uname = "", string password = "");
virtual ~Connect();
bool is_local();
// *** Add get_* versions of accessors. 02/27/03 jhrg
virtual string URL(bool CE = true);
virtual string CE();
void set_credentials(string u, string p);
void set_accept_deflate(bool deflate);
void set_xdap_protocol(int major, int minor);
void set_cache_enabled(bool enabled);
bool is_cache_enabled();
void set_xdap_accept(int major, int minor);
string get_version()
{
return d_version;
}
string get_protocol()
{
return d_protocol;
}
virtual string request_version();
virtual string request_protocol();
virtual void request_das(DAS &das);
virtual void request_das_url(DAS &das);
virtual void request_dds(DDS &dds, string expr = "");
virtual void request_dds_url(DDS &dds);
virtual void request_ddx(DDS &dds, string expr = "");
virtual void request_ddx_url(DDS &dds);
virtual void request_data(DataDDS &data, string expr = "");
virtual void request_data_url(DataDDS &data);
virtual void request_data_ddx(DataDDS &data, string expr = "");
virtual void request_data_ddx_url(DataDDS &data);
virtual void read_data(DataDDS &data, Response *rs);
virtual void read_data_no_mime(DataDDS &data, Response *rs);
virtual void read_data(DDS &data, Response *rs);
virtual void read_data_no_mime(DDS &data, Response *rs);
};
} // namespace libdap
#endif // _connect_h
libdap::Connect
Holds information about the link from a DAP2 client to a dataset.
Definition Connect.h:130
libdap::Connect::request_dds_url
virtual void request_dds_url(DDS &dds)
Get the DDS from a server.
Definition Connect.cc:642
libdap::Connect::CE
virtual string CE()
Get the Connect's constraint expression.
Definition Connect.cc:1146
libdap::Connect::set_accept_deflate
void set_accept_deflate(bool deflate)
Definition Connect.cc:1168
libdap::Connect::set_cache_enabled
void set_cache_enabled(bool enabled)
Definition Connect.cc:1188
libdap::Connect::get_version
string get_version()
Definition Connect.h:185
libdap::Connect::get_protocol
string get_protocol()
Definition Connect.h:193
libdap::Connect::request_ddx
virtual void request_ddx(DDS &dds, string expr="")
Get the DDX from a server.
Definition Connect.cc:705
libdap::Connect::read_data_no_mime
virtual void read_data_no_mime(DataDDS &data, Response *rs)
Read data from a file which does not have response MIME headers. This method is a companion to read_d...
Definition Connect.cc:1062
libdap::Connect::set_xdap_protocol
void set_xdap_protocol(int major, int minor)
Definition Connect.cc:1179
libdap::Connect::URL
virtual string URL(bool CE=true)
Get the object's URL.
Definition Connect.cc:1127
libdap::Connect::request_data
virtual void request_data(DataDDS &data, string expr="")
Get the DAS from a server.
Definition Connect.cc:845
libdap::Connect::request_das
virtual void request_das(DAS &das)
Get the DAS from a server.
Definition Connect.cc:430
libdap::Connect::set_credentials
void set_credentials(string u, string p)
Set the credentials for responding to challenges while dereferencing URLs.
Definition Connect.cc:1159
libdap::Connect::request_ddx_url
virtual void request_ddx_url(DDS &dds)
The 'url' version of request_ddx.
Definition Connect.cc:773
libdap::Connect::request_protocol
virtual string request_protocol()
Definition Connect.cc:398
libdap::Connect::request_dds
virtual void request_dds(DDS &dds, string expr="")
Get the DDS from a server.
Definition Connect.cc:562
libdap::Connect::request_das_url
virtual void request_das_url(DAS &das)
Get the DAS from a server.
Definition Connect.cc:496
libdap::Connect::request_version
virtual string request_version()
Definition Connect.cc:362
libdap::Connect::request_data_url
virtual void request_data_url(DataDDS &data)
Get the DAS from a server.
Definition Connect.cc:896
libdap::Connect::read_data
virtual void read_data(DataDDS &data, Response *rs)
Read data which is preceded by MIME headers. This method works for both data dds and data ddx respons...
Definition Connect.cc:989
libdap::DAS
Hold attribute data for a DAP2 dataset.
Definition DAS.h:122
libdap::DDS
Definition DDS.h:178
libdap::DataDDS
Holds a DAP2 DDS.
Definition DataDDS.h:78
libdap::HTTPConnect
Definition HTTPConnect.h:74
libdap::Response
Definition Response.h:54
libdap
top level DAP object to house generic methods
Definition AlarmHandler.h:36