DMR.h
// -*- mode: c++; c-basic-offset:4 -*-
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.
// Copyright (c) 2013 OPeNDAP, Inc.
// Author: James Gallagher <jgallagher@opendap.org>
//
// 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
#ifndef _dmr_h
#define _dmr_h 1
#include <cassert>
#include <cstdint>
#include <iostream>
#include <string>
#include <vector>
#include "BaseType.h"
#include "DapObj.h"
namespace libdap {
const string c_dap40_namespace = "http://xml.opendap.org/ns/DAP/4.0#";
class D4Group;
class D4BaseTypeFactory;
class XMLWriter;
class DDS;
class DMR : public DapObj {
private:
D4BaseTypeFactory *d_factory = nullptr;
std::string d_name;
std::string d_filename;
int d_dap_major = 4;
int d_dap_minor = 0;
std::string d_dap_version = "4.0";
std::string d_dmr_version = "1.0";
std::string d_request_xml_base;
std::string d_namespace = c_dap40_namespace;
uint64_t d_max_response_size_kb = 0;
bool d_ce_empty = false;
D4Group *d_root = nullptr;
bool global_dio_flag = false;
bool utf8_xml_encoding = false;
friend class DMRTest;
friend class MockDMR;
protected:
void m_duplicate(const DMR &dmr);
public:
DMR() = default;
DMR(const DMR &dmr);
explicit DMR(D4BaseTypeFactory *factory, const std::string &name = "");
DMR(D4BaseTypeFactory *factory, DDS &dds);
~DMR() override;
DMR &operator=(const DMR &rhs);
virtual void build_using_dds(DDS &dds);
bool OK() const { return (d_factory && d_root && !d_dap_version.empty()); }
std::string name() const { return d_name; }
void set_name(const std::string &n) { d_name = n; }
virtual D4BaseTypeFactory *factory() { return d_factory; }
virtual void set_factory(D4BaseTypeFactory *f) { d_factory = f; }
std::string filename() const { return d_filename; }
void set_filename(const std::string &fn) { d_filename = fn; }
std::string dap_version() const { return d_dap_version; }
void set_dap_version(const std::string &version_string);
int dap_major() const { return d_dap_major; }
int dap_minor() const { return d_dap_minor; }
std::string dmr_version() const { return d_dmr_version; }
void set_dmr_version(const std::string &v) { d_dmr_version = v; }
std::string request_xml_base() const { return d_request_xml_base; }
void set_request_xml_base(const std::string &xb) { d_request_xml_base = xb; }
std::string get_namespace() const { return d_namespace; }
void set_namespace(const std::string &ns) { d_namespace = ns; }
long response_limit() const { return (long)d_max_response_size_kb; }
uint64_t response_limit_kb() const { return d_max_response_size_kb; }
void set_response_limit(long size) { d_max_response_size_kb = size; }
void set_response_limit_kb(const uint64_t &size) { d_max_response_size_kb = size; }
long request_size(bool constrained);
uint64_t request_size_kb(bool constrained);
bool too_big() { return d_max_response_size_kb != 0 && request_size_kb(true) > d_max_response_size_kb; }
void set_ce_empty(bool ce_empty) { d_ce_empty = ce_empty; }
bool get_ce_empty() const { return d_ce_empty; }
D4Group *root();
virtual DDS *getDDS();
virtual bool is_dap4_projected(std::vector<string> &inventory);
void print_dap4(XMLWriter &xml, bool constrained = false);
void dump(std::ostream &strm) const override;
// The following methods are for direct IO optimization.
bool get_global_dio_flag() const { return global_dio_flag; }
void set_global_dio_flag(bool dio_flag_value = true) { global_dio_flag = dio_flag_value; }
// The following methods are for utf8_encoding.
bool get_utf8_xml_encoding() const { return utf8_xml_encoding; }
void set_utf8_xml_encoding(bool encoding_value = true) { utf8_xml_encoding = encoding_value; }
};
} // namespace libdap
#endif // _dmr_h
libdap::D4BaseTypeFactory
Definition D4BaseTypeFactory.h:71
libdap::D4Group
Definition D4Group.h:44
libdap::DDS
Definition DDS.h:176
libdap::DMR::dump
void dump(std::ostream &strm) const override
dumps information about this object
Definition DMR.cc:362
libdap::DMR::getDDS
virtual DDS * getDDS()
Build a DDS from a DMR.
Definition DMR.cc:194
libdap::DMR::~DMR
~DMR() override
Definition DMR.cc:132
libdap::DMR::m_duplicate
void m_duplicate(const DMR &dmr)
Copy the contents of the given DMR into this one. This is defined because the we perform a deep copy ...
Definition DMR.cc:60
libdap::DMR::name
std::string name() const
Definition DMR.h:125
libdap::DMR::set_dap_version
void set_dap_version(const std::string &version_string)
Definition DMR.cc:239
libdap::DMR::set_response_limit
void set_response_limit(long size)
Definition DMR.h:185
libdap::DMR::get_ce_empty
bool get_ce_empty() const
Get the flag that marks the expression constraint as empty.
Definition DMR.h:213
libdap::DMR::response_limit
long response_limit() const
Get the maximum response size, in KB. Zero indicates no limit.
Definition DMR.h:171
libdap::DMR::get_namespace
std::string get_namespace() const
Get the namespace associated with the DMR.
Definition DMR.h:161
libdap::DMR::request_xml_base
std::string request_xml_base() const
Get the URL that will return this DMR.
Definition DMR.h:155
libdap::DMR::set_ce_empty
void set_ce_empty(bool ce_empty)
Set the flag that marks the expression constraint as empty.
Definition DMR.h:210
libdap::DMR::is_dap4_projected
virtual bool is_dap4_projected(std::vector< string > &inventory)
Scans the inventory of projected variables and their attributes for projected DAP4 types....
Definition DMR.cc:343
libdap::DMR::too_big
bool too_big()
Definition DMR.h:207
libdap::DMR::build_using_dds
virtual void build_using_dds(DDS &dds)
Definition DMR.cc:151
libdap::DMR::root
D4Group * root()
Definition DMR.cc:228
libdap::DMR::request_size
long request_size(bool constrained)
Get the estimated response size, in kilobytes.
Definition DMR.cc:285
libdap::DMR::request_size_kb
uint64_t request_size_kb(bool constrained)
Compute the estimated response size, in kilobytes.
Definition DMR.cc:297
libdap::DMR::OK
bool OK() const
Definition DMR.h:117
libdap::DMR::set_response_limit_kb
void set_response_limit_kb(const uint64_t &size)
Definition DMR.h:192
libdap::DMR::set_namespace
void set_namespace(const std::string &ns)
Set the namespace for this DMR.
Definition DMR.h:164
libdap::DMR::filename
std::string filename() const
Definition DMR.h:142
libdap::DMR::set_request_xml_base
void set_request_xml_base(const std::string &xb)
Definition DMR.h:158
libdap::DMR::factory
virtual D4BaseTypeFactory * factory()
Definition DMR.h:133
libdap::DMR::print_dap4
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition DMR.cc:306
libdap::DMR::response_limit_kb
uint64_t response_limit_kb() const
Get the maximum response size, in KB. Zero indicates no limit.
Definition DMR.h:178
libdap::DapObj
libdap base object for common functionality of libdap objects
Definition DapObj.h:49
libdap::XMLWriter
Definition XMLWriter.h:39
libdap
top level DAP object to house generic methods
Definition AlarmHandler.h:35
libdap::dap_version
string dap_version()
Definition util.cc:1198