libdap Updated for version 3.21.0
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4Group.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// This library is free software; you can redistribute it and/or
7// modify it under the terms of the GNU Lesser General Public
8// License as published by the Free Software Foundation; either
9// version 2.1 of the License, or (at your option) any later version.
10//
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// Lesser General Public License for more details.
15//
16// You should have received a copy of the GNU Lesser General Public
17// License along with this library; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
21
22#ifndef D4GROUP_H_
23#define D4GROUP_H_
24
25#include <string>
26#include <cstdint>
27
28#include "Constructor.h"
29#include "D4Dimensions.h"
30#include "D4EnumDefs.h"
31
32class Crc32;
33
34namespace libdap {
35
36class BaseType;
37class Array;
38
44class D4Group :public Constructor {
45private:
46 // Note that because Constructor is a BaseType, this class inherits
47 // both a back pointer to its parent, an AttrTable and, directly from the
48 // Constructor class, a vector of BaseTypes.
49
50 // This instance of D4Dimensions holds the Group's definitions; the same
51 // class is used by Array to hold the actual dimensions for a variable.
52 D4Dimensions *d_dims;
53
54 // This holds the Group's enumeration definitions; a different class is
55 // used for the Enumeration type
56 D4EnumDefs *d_enum_defs;
57
58 // This is a pointer so that the factory class(es) that return pointers
59 // work as expected when making Groups.
60 vector<D4Group*> d_groups;
61
62 BaseType *m_find_map_source_helper(const string &name);
63
64protected:
65 void m_duplicate(const D4Group &g);
66
67public:
68 typedef vector<D4Group*>::iterator groupsIter;
69 typedef vector<D4Group*>::const_iterator groupsCIter;
70
71 D4Group(const string &name);
72 D4Group(const string &name, const string &dataset);
73
74 D4Group(const D4Group &rhs);
75 virtual ~D4Group();
76
77 D4Group &operator=(const D4Group &rhs);
78
79 // This method returned a D4Group * previously. jhrg 11/17/16
80 BaseType *ptr_duplicate() override;
81
82 // TODO Wire up the new D4Dimensions object to have this group as its parent. jhrg 8/22/22
85 // If not built yet, make one and set this as parent.
86 if (!d_dims) d_dims = new D4Dimensions(this);
87 return d_dims;
88 }
89
90 std::string FQN() const override;
91
92 D4Dimension *find_dim(const string &path);
93
94 Array *find_map_source(const string &path);
95
96 D4EnumDef *find_enum_def(const string &path);
97
100 if (!d_enum_defs) {
101 d_enum_defs = new D4EnumDefs;
102 d_enum_defs->set_parent(this);
103 }
104 return d_enum_defs;
105 }
106
107 BaseType *find_first_var_that_uses_dimension(D4Dimension *dim);
108 BaseType *find_first_var_that_uses_enumeration(D4EnumDef *enum_def);
109
110 BaseType *find_var(const string &name);
111
112 const vector<D4Group*> &groups() const { return d_groups; }
113
115 groupsIter grp_begin() { return d_groups.begin(); }
116
118 groupsIter grp_end() { return d_groups.end(); }
119
120 void add_group(const D4Group *g) {
121 add_group_nocopy(new D4Group(*g));
122 }
123
124 void add_group_nocopy(D4Group *g) {
125 g->set_parent(this);
126 d_groups.push_back(g);
127 }
128 void insert_group_nocopy(D4Group *g, groupsIter i) {
129 g->set_parent(this);
130 d_groups.insert(i, g);
131 }
132
133 D4Group *find_child_grp(const string &grp_name);
134
135 long request_size(bool constrained);
136 uint64_t request_size_kb(bool constrained);
137
138 void set_send_p(bool state) override;
139 void set_read_p(bool state) override;
140
141 bool is_dap4_projected(std::vector<std::string> &inventory) override;
142
143 // DAP4
144 void intern_data() override;
145 void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false) override;
146 void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override;
147
148 void print_dap4(XMLWriter &xml, bool constrained = false) override;
149
150 void print_decl(ostream &out, string space = " ", bool print_semi = true, bool constraint_info = false,
151 bool constrained = false) override;
152 void print_decl(FILE *out, string space = " ", bool print_semi = true, bool constraint_info = false,
153 bool constrained = false) override;
154
155 void print_val(FILE *out, string space = "", bool print_decl_p = true) override;
156 void print_val(ostream &out, string space = "", bool print_decl_p = true) override;
157
158 std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table) override;
159};
160
161} /* namespace libdap */
162#endif /* D4GROUP_H_ */
Definition: crc.h:79
A multidimensional array of identical data types.
Definition: Array.h:123
The basic data type for the DODS DAP types.
Definition: BaseType.h:120
virtual string name() const
Returns the name of the class instance.
Definition: BaseType.cc:317
virtual string dataset() const
Returns the name of the dataset used to create this instance.
Definition: BaseType.cc:355
void print_dap4(XMLWriter &xml, bool constrained=false) override
Definition: D4Group.cc:630
D4Dimension * find_dim(const string &path)
Find the dimension using a path. Using the DAP4 name syntax, lookup a dimension. The dimension must b...
Definition: D4Group.cc:272
void print_val(FILE *out, string space="", bool print_decl_p=true) override
Prints the value of the variable.
Definition: D4Group.cc:710
bool is_dap4_projected(std::vector< std::string > &inventory) override
Definition: D4Group.cc:898
Array * find_map_source(const string &path)
Given a path to an Array that is also a Map, get that Array.
Definition: D4Group.cc:304
BaseType * find_var(const string &name)
Definition: D4Group.cc:401
groupsIter grp_begin()
Get an iterator to the start of the values.
Definition: D4Group.h:115
void intern_data() override
Read data into this variable.
Definition: D4Group.cc:511
void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter=false) override
Serialize a Group.
Definition: D4Group.cc:563
uint64_t request_size_kb(bool constrained)
Get the estimated size of a response in kilobytes.
Definition: D4Group.cc:467
groupsIter grp_end()
Get an iterator to the end of the values.
Definition: D4Group.h:118
D4Dimensions * dims()
Get the dimensions defined for this Group.
Definition: D4Group.h:84
void set_send_p(bool state) override
Definition: D4Group.cc:501
BaseType * ptr_duplicate() override
Definition: D4Group.cc:165
void set_read_p(bool state) override
Set the 'read_p' property for the Constructor and its members.
Definition: D4Group.cc:491
void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false) override
Print an ASCII representation of the variable structure.
Definition: D4Group.cc:682
D4EnumDefs * enum_defs()
Get the enumerations defined for this Group.
Definition: D4Group.h:99
long request_size(bool constrained)
Definition: D4Group.cc:448
D4Group(const string &name)
Definition: D4Group.cc:124
std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table) override
Transform the D4Group's variables to DAP2 variables.
Definition: D4Group.cc:797
std::string FQN() const override
Definition: D4Group.cc:187
void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override
Definition: D4Group.cc:602
top level DAP object to house generic methods
Definition: AlarmHandler.h:36