libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
D4Group.h
Go to the documentation of this file.
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 <cstdint>
26#include <string>
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:
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)
87 d_dims = new D4Dimensions(this);
88 return d_dims;
89 }
90
91 std::string FQN() const override;
92
93 D4Dimension *find_dim(const string &path);
94
95 Array *find_map_source(const string &path);
96
97 D4EnumDef *find_enum_def(const string &path);
98
101 if (!d_enum_defs) {
102 d_enum_defs = new D4EnumDefs;
103 d_enum_defs->set_parent(this);
104 }
105 return d_enum_defs;
106 }
107
110
111 BaseType *find_var(const string &name);
112
113 const vector<D4Group *> &groups() const { return d_groups; }
114
116 groupsIter grp_begin() { return d_groups.begin(); }
117
119 groupsIter grp_end() { return d_groups.end(); }
120
121 void add_group(const D4Group *g) { add_group_nocopy(new D4Group(*g)); }
122
124 g->set_parent(this);
125 d_groups.push_back(g);
126 }
128 g->set_parent(this);
129 d_groups.insert(i, g);
130 }
131
132 D4Group *find_child_grp(const string &grp_name);
133
134 long request_size(bool constrained);
135 uint64_t request_size_kb(bool constrained);
136
137 void set_send_p(bool state) override;
138 void set_read_p(bool state) override;
139
140 bool is_dap4_projected(std::vector<std::string> &inventory) override;
141
142 // DAP4
143 void intern_data() override;
144 void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false) override;
145 void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override;
146
147 void print_dap4(XMLWriter &xml, bool constrained = false) override;
148
149 void print_decl(ostream &out, string space = " ", bool print_semi = true, bool constraint_info = false,
150 bool constrained = false) override;
151 void print_decl(FILE *out, string space = " ", bool print_semi = true, bool constraint_info = false,
152 bool constrained = false) override;
153
154 void print_val(FILE *out, string space = "", bool print_decl_p = true) override;
155 void print_val(ostream &out, string space = "", bool print_decl_p = true) override;
156
157 std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table) override;
158};
159
160} /* namespace libdap */
161#endif /* D4GROUP_H_ */
Definition crc.h:43
A multidimensional array of identical data types.
Definition Array.h:121
Contains the attributes for a dataset.
Definition AttrTable.h:150
The basic data type for the DODS DAP types.
Definition BaseType.h:118
virtual string name() const
Returns the name of the class instance.
Definition BaseType.cc:296
virtual string dataset() const
Returns the name of the dataset used to create this instance.
Definition BaseType.cc:326
virtual void set_parent(BaseType *parent)
Definition BaseType.cc:622
Constructor(const string &name, const Type &type, bool is_dap4=false)
Definition Constructor.h:52
void set_parent(D4Group *p)
Definition D4EnumDefs.h:144
void print_dap4(XMLWriter &xml, bool constrained=false) override
Definition D4Group.cc:566
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:233
void print_val(FILE *out, string space="", bool print_decl_p=true) override
Prints the value of the variable.
Definition D4Group.cc:640
bool is_dap4_projected(std::vector< std::string > &inventory) override
Definition D4Group.cc:822
D4EnumDef * find_enum_def(const string &path)
Definition D4Group.cc:322
Array * find_map_source(const string &path)
Given a path to an Array that is also a Map, get that Array.
Definition D4Group.cc:263
void add_group_nocopy(D4Group *g)
Definition D4Group.h:123
BaseType * find_var(const string &name)
Definition D4Group.cc:354
void insert_group_nocopy(D4Group *g, groupsIter i)
Definition D4Group.h:127
groupsIter grp_begin()
Get an iterator to the start of the values.
Definition D4Group.h:116
void intern_data() override
Read data into this variable.
Definition D4Group.cc:452
D4Group * find_child_grp(const string &grp_name)
Definition D4Group.cc:160
void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter=false) override
Serialize a Group.
Definition D4Group.cc:502
BaseType * find_first_var_that_uses_enumeration(D4EnumDef *enum_def)
Definition D4Group.cc:196
uint64_t request_size_kb(bool constrained)
Get the estimated size of a response in kilobytes.
Definition D4Group.cc:415
groupsIter grp_end()
Get an iterator to the end of the values.
Definition D4Group.h:119
D4Dimensions * dims()
Get the dimensions defined for this Group.
Definition D4Group.h:84
void set_send_p(bool state) override
Definition D4Group.cc:444
virtual ~D4Group()
Definition D4Group.cc:125
BaseType * ptr_duplicate() override
Definition D4Group.cc:139
void m_duplicate(const D4Group &g)
Definition D4Group.cc:57
vector< D4Group * >::const_iterator groupsCIter
Definition D4Group.h:69
void set_read_p(bool state) override
Set the 'read_p' property for the Constructor and its members.
Definition D4Group.cc:436
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:614
D4Group & operator=(const D4Group &rhs)
Definition D4Group.cc:141
const vector< D4Group * > & groups() const
Definition D4Group.h:113
D4EnumDefs * enum_defs()
Get the enumerations defined for this Group.
Definition D4Group.h:100
long request_size(bool constrained)
Definition D4Group.cc:399
D4Group(const string &name)
Definition D4Group.cc:104
std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table) override
Transform the D4Group's variables to DAP2 variables.
Definition D4Group.cc:723
std::string FQN() const override
Definition D4Group.cc:155
void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override
Definition D4Group.cc:540
BaseType * find_first_var_that_uses_dimension(D4Dimension *dim)
Definition D4Group.cc:166
void add_group(const D4Group *g)
Definition D4Group.h:121
vector< D4Group * >::iterator groupsIter
Definition D4Group.h:68
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
Read data from the stream made by D4StreamMarshaller.
STL iterator class.
STL iterator class.
top level DAP object to house generic methods
Definition AISConnect.cc:30