libdap Updated for version 3.20.10
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
37namespace libdap
38{
39
40class D4Group;
41class D4BaseTypeFactory;
42class XMLWriter;
43
44class DDS;
45
54class DMR : public DapObj
55{
56private:
57 D4BaseTypeFactory *d_factory;
58
60 std::string d_name;
62 std::string d_filename;
63
65 int d_dap_major;
67 int d_dap_minor;
69 std::string d_dap_version;
70
72 std::string d_dmr_version;
73
75 std::string d_request_xml_base;
76
78 std::string d_namespace;
79
81 uint64_t d_max_response_size_kb;
82
84 bool d_ce_empty;
85
87 D4Group *d_root;
88
89 friend class DMRTest;
90
91protected:
92 void m_duplicate(const DMR &dmr);
93
94public:
95 DMR();
96 DMR(const DMR &dmr);
97 explicit DMR(D4BaseTypeFactory *factory, const std::string &name = "");
98
100
101 ~DMR() override;
102
103 DMR &operator=(const DMR &rhs);
104
105 virtual void build_using_dds(DDS &dds);
106
111 bool OK() const { return (d_factory && d_root && !d_dap_version.empty()); }
112
119 std::string name() const { return d_name; }
120 void set_name(const std::string &n) { d_name = n; }
122
127 virtual D4BaseTypeFactory *factory() { return d_factory; }
128 virtual void set_factory(D4BaseTypeFactory *f) { d_factory = f; }
130
136 std::string filename() const { return d_filename; }
137 void set_filename(const std::string &fn) { d_filename = fn;}
139
140 std::string dap_version() const { return d_dap_version; }
141 void set_dap_version(const std::string &version_string);
142 int dap_major() const { return d_dap_major; }
143 int dap_minor() const { return d_dap_minor; }
144
145 std::string dmr_version() const { return d_dmr_version; }
146 void set_dmr_version(const std::string &v) { d_dmr_version = v; }
147
149 std::string request_xml_base() const { return d_request_xml_base; }
150
152 void set_request_xml_base(const std::string &xb) { d_request_xml_base = xb; }
153
155 std::string get_namespace() const { return d_namespace; }
156
158 void set_namespace(const std::string &ns) { d_namespace = ns; }
159
165 long response_limit() const { return (long) d_max_response_size_kb; }
166
172 uint64_t response_limit_kb() const { return d_max_response_size_kb; }
173
179 void set_response_limit(long size) {
180 d_max_response_size_kb = size;
181 }
182
188 void set_response_limit_kb(const uint64_t &size) {
189 d_max_response_size_kb = size;
190 }
191
193 long request_size(bool constrained);
194
200 uint64_t request_size_kb(bool constrained);
201
205 bool too_big() {
206 return d_max_response_size_kb != 0 && request_size_kb(true) > d_max_response_size_kb;
207 }
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 void print_dap4(XMLWriter &xml, bool constrained = false);
224
225 void dump(std::ostream &strm) const override;
226};
227
228} // namespace libdap
229
230#endif // _dmr_h
void dump(std::ostream &strm) const override
dumps information about this object
Definition DMR.cc:439
virtual DDS * getDDS()
Build a DDS from a DMR.
Definition DMR.cc:260
~DMR() override
Definition DMR.cc:190
std::string name() const
Definition DMR.h:119
void set_dap_version(const std::string &version_string)
Definition DMR.cc:308
void set_response_limit(long size)
Definition DMR.h:179
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:165
std::string get_namespace() const
Get the namespace associated with the DMR.
Definition DMR.h:155
std::string request_xml_base() const
Get the URL that will return this DMR.
Definition DMR.h:149
void set_ce_empty(bool ce_empty)
Set the flag that marks the expression constraint as empty.
Definition DMR.h:210
bool too_big()
Definition DMR.h:205
virtual void build_using_dds(DDS &dds)
Definition DMR.cc:212
D4Group * root()
Definition DMR.cc:296
long request_size(bool constrained)
Get the estimated response size, in kilobytes.
Definition DMR.cc:355
uint64_t request_size_kb(bool constrained)
Compute the estimated response size, in kilobytes.
Definition DMR.cc:370
bool OK() const
Definition DMR.h:111
void set_response_limit_kb(const uint64_t &size)
Definition DMR.h:188
void set_namespace(const std::string &ns)
Set the namespace for this DMR.
Definition DMR.h:158
std::string filename() const
Definition DMR.h:136
void set_request_xml_base(const std::string &xb)
Definition DMR.h:152
virtual D4BaseTypeFactory * factory()
Definition DMR.h:127
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition DMR.cc:386
uint64_t response_limit_kb() const
Get the maximum response size, in KB. Zero indicates no limit.
Definition DMR.h:172
libdap base object for common functionality of libdap objects
Definition DapObj.h:51
top level DAP object to house generic methods