libdap  Updated for version 3.20.9
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 
37 namespace libdap
38 {
39 
40 class D4Group;
41 class D4BaseTypeFactory;
42 class XMLWriter;
43 
44 class DDS;
45 
54 class DMR : public DapObj
55 {
56 private:
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 
91 protected:
92  void m_duplicate(const DMR &dmr);
93 
94 public:
95  DMR();
96  DMR(const DMR &dmr);
97  DMR(D4BaseTypeFactory *factory, const std::string &name = "");
98 
100 
101  virtual ~DMR();
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  virtual void dump(std::ostream &strm) const ;
226 };
227 
228 } // namespace libdap
229 
230 #endif // _dmr_h
virtual DDS * getDDS()
Build a DDS from a DMR.
Definition: DMR.cc:374
std::string name() const
Definition: DMR.h:119
void set_dap_version(const std::string &version_string)
Definition: DMR.cc:422
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
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: DMR.cc:553
virtual ~DMR()
Definition: DMR.cc:203
bool too_big()
Definition: DMR.h:205
virtual D4BaseTypeFactory * factory()
Definition: DMR.h:127
virtual void build_using_dds(DDS &dds)
Definition: DMR.cc:229
D4Group * root()
Definition: DMR.cc:410
long request_size(bool constrained)
Get the estimated response size, in kilobytes.
Definition: DMR.cc:469
uint64_t request_size_kb(bool constrained)
Compute the estimated response size, in kilobytes.
Definition: DMR.cc:484
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
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition: DMR.cc:500
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
Definition: AlarmHandler.h:36