libdap  Updated for version 3.17.0
D4Connect.h
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) 2013 OPeNDAP, Inc.
00008 // Author: James Gallagher <jgallagher@opendap.org>
00009 //
00010 // This library is free software; you can redistribute it and/or
00011 // modify it under the terms of the GNU Lesser General Public
00012 // License as published by the Free Software Foundation; either
00013 // version 2.1 of the License, or (at your option) any later version.
00014 //
00015 // This library is distributed in the hope that it will be useful,
00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00023 //
00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
00025 
00026 #ifndef _d4connect_h
00027 #define _d4connect_h
00028 
00029 #include <string>
00030 
00031 namespace libdap
00032 {
00033 
00034 class HTTPConnect;
00035 class DMR;
00036 class Response;
00037 
00038 class D4Connect
00039 {
00040 private:
00041     HTTPConnect *d_http;
00042 
00043     bool d_local;  // Is this a local connection?
00044     std::string d_URL;  // URL to remote dataset (minus CE)
00045     std::string d_dap4ce;       // CE
00046 
00047     std::string d_server; // Server implementation information (the XDAP-Server header)
00048     std::string d_protocol; // DAP protocol from the server (XDAP)
00049 
00050     void process_data(DMR &data, Response &rs);
00051     void process_dmr(DMR &data, Response &rs);
00052 
00053     // Use when you cannot use but have a complete response with MIME headers
00054     void parse_mime(Response &rs);
00055 
00056 protected:
00058     D4Connect();
00059     D4Connect(const D4Connect &);
00060     D4Connect &operator=(const D4Connect &);
00061 
00062 public:
00063     D4Connect(const std::string &url, std::string uname = "", std::string password = "");
00064 
00065     virtual ~D4Connect();
00066 
00067     bool is_local() const { return d_local; }
00068 
00069     virtual std::string URL() const { return d_URL; }
00070     virtual std::string CE() const { return d_dap4ce; }
00071 
00072     void set_credentials(std::string u, std::string p);
00073     void set_accept_deflate(bool deflate);
00074     void set_xdap_protocol(int major, int minor);
00075 
00076     void set_cache_enabled(bool enabled);
00077     bool is_cache_enabled();
00078 
00079     void set_xdap_accept(int major, int minor);
00080 
00090     std::string get_version() { return d_server; }
00091 
00095     std::string get_protocol() { return d_protocol; }
00096 
00097     virtual void request_dmr(DMR &dmr, const std::string expr = "");
00098     virtual void request_dap4_data(DMR &dmr, const std::string expr = "");
00099 #if 0
00100     virtual void request_version();
00101 #endif
00102 
00103     virtual void read_dmr(DMR &dmr, Response &rs);
00104     virtual void read_dmr_no_mime(DMR &dmr, Response &rs);
00105 
00106     virtual void read_data(DMR &data, Response &rs);
00107     virtual void read_data_no_mime(DMR &data, Response &rs);
00108 };
00109 
00110 } // namespace libdap
00111 
00112 #endif // _d4connect_h