forked from OPENDAP/libdap4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
D4Group.h
161 lines (119 loc) · 5.32 KB
/
D4Group.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
// -*- mode: c++; c-basic-offset:4 -*-
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
#ifndef D4GROUP_H_
#define D4GROUP_H_
#include <cstdint>
#include <string>
#include "Constructor.h"
#include "D4Dimensions.h"
#include "D4EnumDefs.h"
class Crc32;
namespace libdap {
class BaseType;
class Array;
/** A DAP4 Group object. A Group is-a Constructor, so it inherits a set of
* BaseType objects and an attribute table, along with methods to search for
* variables by name where dots (.) in a fully qualified name serve as
* separators.
*/
class D4Group : public Constructor {
private:
// Note that because Constructor is a BaseType, this class inherits
// both a back pointer to its parent, an AttrTable and, directly from the
// Constructor class, a vector of BaseTypes.
// This instance of D4Dimensions holds the Group's definitions; the same
// class is used by Array to hold the actual dimensions for a variable.
D4Dimensions *d_dims;
// This holds the Group's enumeration definitions; a different class is
// used for the Enumeration type
D4EnumDefs *d_enum_defs;
// This is a pointer so that the factory class(es) that return pointers
// work as expected when making Groups.
vector<D4Group *> d_groups;
BaseType *m_find_map_source_helper(const string &name);
protected:
void m_duplicate(const D4Group &g);
public:
typedef vector<D4Group *>::iterator groupsIter;
typedef vector<D4Group *>::const_iterator groupsCIter;
D4Group(const string &name);
D4Group(const string &name, const string &dataset);
D4Group(const D4Group &rhs);
virtual ~D4Group();
D4Group &operator=(const D4Group &rhs);
// This method returned a D4Group * previously. jhrg 11/17/16
BaseType *ptr_duplicate() override;
// TODO Wire up the new D4Dimensions object to have this group as its parent. jhrg 8/22/22
/// Get the dimensions defined for this Group
D4Dimensions *dims() {
// If not built yet, make one and set this as parent.
if (!d_dims)
d_dims = new D4Dimensions(this);
return d_dims;
}
std::string FQN() const override;
D4Dimension *find_dim(const string &path);
Array *find_map_source(const string &path);
D4EnumDef *find_enum_def(const string &path);
/// Get the enumerations defined for this Group
D4EnumDefs *enum_defs() {
if (!d_enum_defs) {
d_enum_defs = new D4EnumDefs;
d_enum_defs->set_parent(this);
}
return d_enum_defs;
}
BaseType *find_first_var_that_uses_dimension(D4Dimension *dim);
BaseType *find_first_var_that_uses_enumeration(D4EnumDef *enum_def);
BaseType *find_var(const string &name);
const vector<D4Group *> &groups() const { return d_groups; }
/// Get an iterator to the start of the values
groupsIter grp_begin() { return d_groups.begin(); }
/// Get an iterator to the end of the values
groupsIter grp_end() { return d_groups.end(); }
void add_group(const D4Group *g) { add_group_nocopy(new D4Group(*g)); }
void add_group_nocopy(D4Group *g) {
g->set_parent(this);
d_groups.push_back(g);
}
void insert_group_nocopy(D4Group *g, groupsIter i) {
g->set_parent(this);
d_groups.insert(i, g);
}
D4Group *find_child_grp(const string &grp_name);
long request_size(bool constrained);
uint64_t request_size_kb(bool constrained);
void set_send_p(bool state) override;
void set_read_p(bool state) override;
bool is_dap4_projected(std::vector<std::string> &inventory) override;
// DAP4
void intern_data() override;
void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false) override;
void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override;
void print_dap4(XMLWriter &xml, bool constrained = false) override;
void print_decl(ostream &out, string space = " ", bool print_semi = true, bool constraint_info = false,
bool constrained = false) override;
void print_decl(FILE *out, string space = " ", bool print_semi = true, bool constraint_info = false,
bool constrained = false) override;
void print_val(FILE *out, string space = "", bool print_decl_p = true) override;
void print_val(ostream &out, string space = "", bool print_decl_p = true) override;
std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table) override;
};
} /* namespace libdap */
#endif /* D4GROUP_H_ */