libdap  Updated for version 3.20.6
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 
34 #include "DapObj.h"
35 
36 namespace libdap
37 {
38 
39 class D4Group;
40 class D4BaseTypeFactory;
41 class XMLWriter;
42 
43 class DDS;
44 
53 class DMR : public DapObj
54 {
55 private:
56  D4BaseTypeFactory *d_factory;
57 
59  std::string d_name;
61  std::string d_filename;
62 
64  int d_dap_major;
66  int d_dap_minor;
68  std::string d_dap_version;
69 
71  std::string d_dmr_version;
72 
74  std::string d_request_xml_base;
75 
77  std::string d_namespace;
78 
80  long d_max_response_size;
81 
83  D4Group *d_root;
84 
85  friend class DMRTest;
86 
87 protected:
88  void m_duplicate(const DMR &dmr);
89 
90 public:
91  DMR();
92  DMR(const DMR &dmr);
93  DMR(D4BaseTypeFactory *factory, const std::string &name = "");
94 
95  DMR(D4BaseTypeFactory *factory, DDS &dds);
96 
97  virtual ~DMR();
98 
99  DMR &operator=(const DMR &rhs);
100 
101  virtual void build_using_dds(DDS &dds);
102 
107  bool OK() const { return (d_factory && d_root && !d_dap_version.empty()); }
108 
115  std::string name() const { return d_name; }
116  void set_name(const std::string &n) { d_name = n; }
118 
123  virtual D4BaseTypeFactory *factory() { return d_factory; }
124  virtual void set_factory(D4BaseTypeFactory *f) { d_factory = f; }
126 
132  std::string filename() const { return d_filename; }
133  void set_filename(const std::string &fn) { d_filename = fn;}
135 
136  std::string dap_version() const { return d_dap_version; }
137  void set_dap_version(const std::string &version_string);
138  int dap_major() const { return d_dap_major; }
139  int dap_minor() const { return d_dap_minor; }
140 
141  std::string dmr_version() const { return d_dmr_version; }
142  void set_dmr_version(const std::string &v) { d_dmr_version = v; }
143 
145  std::string request_xml_base() const { return d_request_xml_base; }
146 
148  void set_request_xml_base(const std::string &xb) { d_request_xml_base = xb; }
149 
151  std::string get_namespace() const { return d_namespace; }
152 
154  void set_namespace(const std::string &ns) { d_namespace = ns; }
155 
156  // TODO Move the response_limit methods to D4ResponseBuilder? jhrg 5/1/13
158  long response_limit() { return d_max_response_size; }
159 
163  void set_response_limit(long size) { d_max_response_size = size; }
164 
166  long request_size(bool constrained);
167 
172  D4Group *root();
173 
174  // TODO Remove this static method? If we have a DMR, why not use the
175  // getDDS() method below? jhrg 2.28.18
176  //static DDS *getDDS(DMR &dmr);
177  virtual DDS *getDDS();
178 
179  void print_dap4(XMLWriter &xml, bool constrained = false);
180 
181  virtual void dump(std::ostream &strm) const ;
182 };
183 
184 } // namespace libdap
185 
186 #endif // _dmr_h
std::string name() const
Definition: DMR.h:115
void set_response_limit(long size)
Definition: DMR.h:163
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition: DMR.cc:478
void set_namespace(const std::string &ns)
Set the namespace for this DMR.
Definition: DMR.h:154
D4Group * root()
Definition: DMR.cc:407
long response_limit()
Get the maximum response size, in KB. Zero indicates no limit.
Definition: DMR.h:158
virtual ~DMR()
Definition: DMR.cc:200
void set_request_xml_base(const std::string &xb)
Definition: DMR.h:148
top level DAP object to house generic methods
Definition: AISConnect.cc:30
std::string filename() const
Definition: DMR.h:132
bool OK() const
Definition: DMR.h:107
virtual D4BaseTypeFactory * factory()
Definition: DMR.h:123
std::string request_xml_base() const
Get the URL that will return this DMR.
Definition: DMR.h:145
long request_size(bool constrained)
Get the estimated response size, in kilo bytes.
Definition: DMR.cc:465
void set_dap_version(const std::string &version_string)
Definition: DMR.cc:419
virtual void build_using_dds(DDS &dds)
Definition: DMR.cc:226
libdap base object for common functionality of libdap objects
Definition: DapObj.h:50
virtual DDS * getDDS()
Build a DDS from a DMR.
Definition: DMR.cc:371
std::string get_namespace() const
Get the namespace associated with the DMR.
Definition: DMR.h:151
virtual void dump(std::ostream &strm) const
dumps information about this object
Definition: DMR.cc:531