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 <iostream>
31#include <string>
32#include <vector>
33#include <cstdint>
34
35#include "DapObj.h"
36#include "BaseType.h"
37
38namespace libdap
39{
40
41const string c_dap40_namespace = "http://xml.opendap.org/ns/DAP/4.0#";
42
43class D4Group;
44class D4BaseTypeFactory;
45class XMLWriter;
46
47class DDS;
48
57class DMR : public DapObj
58{
59private:
60 D4BaseTypeFactory *d_factory = nullptr;
61
63 std::string d_name;
65 std::string d_filename;
66
68 int d_dap_major = 4;
70 int d_dap_minor = 0;
72 std::string d_dap_version = "4.0";
73
75 std::string d_dmr_version = "1.0";
76
78 std::string d_request_xml_base;
79
81 std::string d_namespace = c_dap40_namespace;
82
84 uint64_t d_max_response_size_kb = 0;
85
87 bool d_ce_empty = false;
88
90 D4Group *d_root = nullptr;
91
93 bool global_dio_flag = false;
94
95 friend class DMRTest;
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) {
186 d_max_response_size_kb = size;
187 }
188
194 void set_response_limit_kb(const uint64_t &size) {
195 d_max_response_size_kb = size;
196 }
197
199 long request_size(bool constrained);
200
206 uint64_t request_size_kb(bool constrained);
207
211 bool too_big() {
212 return d_max_response_size_kb != 0 && request_size_kb(true) > d_max_response_size_kb;
213 }
214
216 void set_ce_empty(bool ce_empty) { d_ce_empty = ce_empty; }
217
219 bool get_ce_empty() const { return d_ce_empty; }
220
225 D4Group *root();
226
227 virtual DDS *getDDS();
228
229 virtual bool is_dap4_projected(std::vector<string> &inventory);
230
231 void print_dap4(XMLWriter &xml, bool constrained = false);
232
233 void dump(std::ostream &strm) const override;
234
235 // The following methods are for direct IO optimization.
236 bool get_global_dio_flag() const {return global_dio_flag; }
237 void set_global_dio_flag( bool dio_flag_value = true) { global_dio_flag = dio_flag_value; }
238
239};
240
241} // namespace libdap
242
243#endif // _dmr_h
void dump(std::ostream &strm) const override
dumps information about this object
Definition DMR.cc:397
virtual DDS * getDDS()
Build a DDS from a DMR.
Definition DMR.cc:213
~DMR() override
Definition DMR.cc:141
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:61
std::string name() const
Definition DMR.h:125
void set_dap_version(const std::string &version_string)
Definition DMR.cc:261
void set_response_limit(long size)
Definition DMR.h:185
bool get_ce_empty() const
Get the flag that marks the expression constraint as empty.
Definition DMR.h:219
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 request_xml_base() const
Get the URL that will return this DMR.
Definition DMR.h:155
void set_ce_empty(bool ce_empty)
Set the flag that marks the expression constraint as empty.
Definition DMR.h:216
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:375
bool too_big()
Definition DMR.h:211
virtual void build_using_dds(DDS &dds)
Definition DMR.cc:165
D4Group * root()
Definition DMR.cc:249
long request_size(bool constrained)
Get the estimated response size, in kilobytes.
Definition DMR.cc:308
uint64_t request_size_kb(bool constrained)
Compute the estimated response size, in kilobytes.
Definition DMR.cc:323
bool OK() const
Definition DMR.h:117
void set_response_limit_kb(const uint64_t &size)
Definition DMR.h:194
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
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition DMR.cc:339
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:51
top level DAP object to house generic methods