libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
DMR.h
Go to the documentation of this file.
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 bool utf8_xml_encoding = false;
94 friend class DMRTest;
95 friend class MockDMR;
96
97protected:
98 void m_duplicate(const DMR &dmr);
99
100public:
101 DMR() = default;
102 DMR(const DMR &dmr);
103 explicit DMR(D4BaseTypeFactory *factory, const std::string &name = "");
104
106
107 ~DMR() override;
108
109 DMR &operator=(const DMR &rhs);
110
111 virtual void build_using_dds(DDS &dds);
112
117 bool OK() const { return (d_factory && d_root && !d_dap_version.empty()); }
118
125 std::string name() const { return d_name; }
126 void set_name(const std::string &n) { d_name = n; }
128
133 virtual D4BaseTypeFactory *factory() { return d_factory; }
134 virtual void set_factory(D4BaseTypeFactory *f) { d_factory = f; }
136
142 std::string filename() const { return d_filename; }
143 void set_filename(const std::string &fn) { d_filename = fn; }
145
146 std::string dap_version() const { return d_dap_version; }
147 void set_dap_version(const std::string &version_string);
148 int dap_major() const { return d_dap_major; }
149 int dap_minor() const { return d_dap_minor; }
150
151 std::string dmr_version() const { return d_dmr_version; }
152 void set_dmr_version(const std::string &v) { d_dmr_version = v; }
153
155 std::string request_xml_base() const { return d_request_xml_base; }
156
158 void set_request_xml_base(const std::string &xb) { d_request_xml_base = xb; }
159
161 std::string get_namespace() const { return d_namespace; }
162
164 void set_namespace(const std::string &ns) { d_namespace = ns; }
165
171 long response_limit() const { return (long)d_max_response_size_kb; }
172
178 uint64_t response_limit_kb() const { return d_max_response_size_kb; }
179
185 void set_response_limit(long size) { d_max_response_size_kb = size; }
186
192 void set_response_limit_kb(const uint64_t &size) { d_max_response_size_kb = size; }
193
195 long request_size(bool constrained);
196
202 uint64_t request_size_kb(bool constrained);
203
207 bool too_big() { return d_max_response_size_kb != 0 && request_size_kb(true) > d_max_response_size_kb; }
208
210 void set_ce_empty(bool ce_empty) { d_ce_empty = ce_empty; }
211
213 bool get_ce_empty() const { return d_ce_empty; }
214
219 D4Group *root();
220
221 virtual DDS *getDDS();
222
223 virtual bool is_dap4_projected(std::vector<string> &inventory);
224
225 void print_dap4(XMLWriter &xml, bool constrained = false);
226
227 void dump(std::ostream &strm) const override;
228
229 // The following methods are for direct IO optimization.
230 bool get_global_dio_flag() const { return global_dio_flag; }
231 void set_global_dio_flag(bool dio_flag_value = true) { global_dio_flag = dio_flag_value; }
232
233 // The following methods are for utf8_encoding.
234 bool get_utf8_xml_encoding() const { return utf8_xml_encoding; }
235 void set_utf8_xml_encoding(bool encoding_value = true) { utf8_xml_encoding = encoding_value; }
236};
237
238} // namespace libdap
239
240#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:125
bool get_utf8_xml_encoding() const
Definition DMR.h:234
DMR()=default
friend class MockDMR
Definition DMR.h:95
void set_dap_version(const std::string &version_string)
Definition DMR.cc:239
void set_response_limit(long size)
Definition DMR.h:185
virtual void set_factory(D4BaseTypeFactory *f)
Definition DMR.h:134
bool get_ce_empty() const
Get the flag that marks the expression constraint as empty.
Definition DMR.h:213
long response_limit() const
Get the maximum response size, in KB. Zero indicates no limit.
Definition DMR.h:171
std::string get_namespace() const
Get the namespace associated with the DMR.
Definition DMR.h:161
std::string dap_version() const
Definition DMR.h:146
std::string request_xml_base() const
Get the URL that will return this DMR.
Definition DMR.h:155
void set_global_dio_flag(bool dio_flag_value=true)
Definition DMR.h:231
DMR & operator=(const DMR &rhs)
Definition DMR.cc:134
void set_ce_empty(bool ce_empty)
Set the flag that marks the expression constraint as empty.
Definition DMR.h:210
friend class DMRTest
Definition DMR.h:94
bool get_global_dio_flag() const
Definition DMR.h:230
void set_name(const std::string &n)
Definition DMR.h:126
void set_utf8_xml_encoding(bool encoding_value=true)
Definition DMR.h:235
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:207
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
void set_dmr_version(const std::string &v)
Definition DMR.h:152
bool OK() const
Definition DMR.h:117
void set_response_limit_kb(const uint64_t &size)
Definition DMR.h:192
void set_filename(const std::string &fn)
Definition DMR.h:143
void set_namespace(const std::string &ns)
Set the namespace for this DMR.
Definition DMR.h:164
std::string filename() const
Definition DMR.h:142
void set_request_xml_base(const std::string &xb)
Definition DMR.h:158
virtual D4BaseTypeFactory * factory()
Definition DMR.h:133
std::string dmr_version() const
Definition DMR.h:151
int dap_major() const
Definition DMR.h:148
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition DMR.cc:306
int dap_minor() const
Definition DMR.h:149
uint64_t response_limit_kb() const
Get the maximum response size, in KB. Zero indicates no limit.
Definition DMR.h:178
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
const string c_dap40_namespace
Definition DMR.h:40