libdap Updated for version 3.21.0
libdap4 is an implementation of OPeNDAP's DAP protocol.
DMR.h
1// -*- mode: c++; c-basic-offset:4 -*-
2
3// This file is part of libdap, A C++ implementation of the OPeNDAP Data
4// Access Protocol.
5
6// Copyright (c) 2013 OPeNDAP, Inc.
7// Author: James Gallagher <jgallagher@opendap.org>
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Lesser General Public
11// License as published by the Free Software Foundation; either
12// version 2.1 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Lesser General Public License for more details.
18//
19// You should have received a copy of the GNU Lesser General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22//
23// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
24
25#ifndef _dmr_h
26#define _dmr_h 1
27
28#include <cassert>
29
30#include <cstdint>
31#include <iostream>
32#include <string>
33#include <vector>
34
35#include "BaseType.h"
36#include "DapObj.h"
37
38namespace libdap {
39
40const string c_dap40_namespace = "http://xml.opendap.org/ns/DAP/4.0#";
41
42class D4Group;
44class XMLWriter;
45
46class DDS;
47
56class DMR : public DapObj {
57private:
58 D4BaseTypeFactory *d_factory = nullptr;
59
61 std::string d_name;
63 std::string d_filename;
64
66 int d_dap_major = 4;
68 int d_dap_minor = 0;
70 std::string d_dap_version = "4.0";
71
73 std::string d_dmr_version = "1.0";
74
76 std::string d_request_xml_base;
77
79 std::string d_namespace = c_dap40_namespace;
80
82 uint64_t d_max_response_size_kb = 0;
83
85 bool d_ce_empty = false;
86
88 D4Group *d_root = nullptr;
89
91 bool global_dio_flag = false;
92
93 friend class DMRTest;
94 friend class MockDMR;
95
96protected:
97 void m_duplicate(const DMR &dmr);
98
99public:
100 DMR() = default;
101 DMR(const DMR &dmr);
102 explicit DMR(D4BaseTypeFactory *factory, const std::string &name = "");
103
104 DMR(D4BaseTypeFactory *factory, DDS &dds);
105
106 ~DMR() override;
107
108 DMR &operator=(const DMR &rhs);
109
110 virtual void build_using_dds(DDS &dds);
111
116 bool OK() const { return (d_factory && d_root && !d_dap_version.empty()); }
117
124 std::string name() const { return d_name; }
125 void set_name(const std::string &n) { d_name = n; }
127
132 virtual D4BaseTypeFactory *factory() { return d_factory; }
133 virtual void set_factory(D4BaseTypeFactory *f) { d_factory = f; }
135
141 std::string filename() const { return d_filename; }
142 void set_filename(const std::string &fn) { d_filename = fn; }
144
145 std::string dap_version() const { return d_dap_version; }
146 void set_dap_version(const std::string &version_string);
147 int dap_major() const { return d_dap_major; }
148 int dap_minor() const { return d_dap_minor; }
149
150 std::string dmr_version() const { return d_dmr_version; }
151 void set_dmr_version(const std::string &v) { d_dmr_version = v; }
152
154 std::string request_xml_base() const { return d_request_xml_base; }
155
157 void set_request_xml_base(const std::string &xb) { d_request_xml_base = xb; }
158
160 std::string get_namespace() const { return d_namespace; }
161
163 void set_namespace(const std::string &ns) { d_namespace = ns; }
164
170 long response_limit() const { return (long)d_max_response_size_kb; }
171
177 uint64_t response_limit_kb() const { return d_max_response_size_kb; }
178
184 void set_response_limit(long size) { d_max_response_size_kb = size; }
185
191 void set_response_limit_kb(const uint64_t &size) { d_max_response_size_kb = size; }
192
194 long request_size(bool constrained);
195
201 uint64_t request_size_kb(bool constrained);
202
206 bool too_big() { return d_max_response_size_kb != 0 && request_size_kb(true) > d_max_response_size_kb; }
207
209 void set_ce_empty(bool ce_empty) { d_ce_empty = ce_empty; }
210
212 bool get_ce_empty() const { return d_ce_empty; }
213
218 D4Group *root();
219
220 virtual DDS *getDDS();
221
222 virtual bool is_dap4_projected(std::vector<string> &inventory);
223
224 void print_dap4(XMLWriter &xml, bool constrained = false);
225
226 void dump(std::ostream &strm) const override;
227
228 // The following methods are for direct IO optimization.
229 bool get_global_dio_flag() const { return global_dio_flag; }
230 void set_global_dio_flag(bool dio_flag_value = true) { global_dio_flag = dio_flag_value; }
231};
232
233} // namespace libdap
234
235#endif // _dmr_h
void dump(std::ostream &strm) const override
dumps information about this object
Definition DMR.cc:362
virtual DDS * getDDS()
Build a DDS from a DMR.
Definition DMR.cc:194
~DMR() override
Definition DMR.cc:132
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
std::string name() const
Definition DMR.h:124
void set_dap_version(const std::string &version_string)
Definition DMR.cc:239
void set_response_limit(long size)
Definition DMR.h:184
bool get_ce_empty() const
Get the flag that marks the expression constraint as empty.
Definition DMR.h:212
long response_limit() const
Get the maximum response size, in KB. Zero indicates no limit.
Definition DMR.h:170
std::string get_namespace() const
Get the namespace associated with the DMR.
Definition DMR.h:160
std::string request_xml_base() const
Get the URL that will return this DMR.
Definition DMR.h:154
void set_ce_empty(bool ce_empty)
Set the flag that marks the expression constraint as empty.
Definition DMR.h:209
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
bool too_big()
Definition DMR.h:206
virtual void build_using_dds(DDS &dds)
Definition DMR.cc:151
D4Group * root()
Definition DMR.cc:228
long request_size(bool constrained)
Get the estimated response size, in kilobytes.
Definition DMR.cc:285
uint64_t request_size_kb(bool constrained)
Compute the estimated response size, in kilobytes.
Definition DMR.cc:297
bool OK() const
Definition DMR.h:116
void set_response_limit_kb(const uint64_t &size)
Definition DMR.h:191
void set_namespace(const std::string &ns)
Set the namespace for this DMR.
Definition DMR.h:163
std::string filename() const
Definition DMR.h:141
void set_request_xml_base(const std::string &xb)
Definition DMR.h:157
virtual D4BaseTypeFactory * factory()
Definition DMR.h:132
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition DMR.cc:306
uint64_t response_limit_kb() const
Get the maximum response size, in KB. Zero indicates no limit.
Definition DMR.h:177
libdap base object for common functionality of libdap objects
Definition DapObj.h:49
top level DAP object to house generic methods
Definition AISConnect.cc:30