libdap Updated for version 3.20.10
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 virtual BaseType *ptr_duplicate();
81
84 // If not built yet, make one and set this as parent.
85 if (!d_dims) d_dims = new D4Dimensions(this);
86 return d_dims;
87 }
88
89 virtual std::string FQN() const;
90
91 D4Dimension *find_dim(const string &path);
92
93 Array *find_map_source(const string &path);
94
95 D4EnumDef *find_enum_def(const string &path);
96
99 if (!d_enum_defs) {
100 d_enum_defs = new D4EnumDefs;
101 d_enum_defs->set_parent(this);
102 }
103 return d_enum_defs;
104 }
105
106 BaseType *find_first_var_that_uses_dimension(D4Dimension *dim);
107 BaseType *find_first_var_that_uses_enumeration(D4EnumDef *enum_def);
108
109 BaseType *find_var(const string &name);
110
112 groupsIter grp_begin() { return d_groups.begin(); }
113
115 groupsIter grp_end() { return d_groups.end(); }
116
117 void add_group(const D4Group *g) {
118 add_group_nocopy(new D4Group(*g));
119 }
120
121 void add_group_nocopy(D4Group *g) {
122 g->set_parent(this);
123 d_groups.push_back(g);
124 }
125 void insert_group_nocopy(D4Group *g, groupsIter i) {
126 g->set_parent(this);
127 d_groups.insert(i, g);
128 }
129
130 D4Group *find_child_grp(const string &grp_name);
131
132 long request_size(bool constrained);
133 uint64_t request_size_kb(bool constrained);
134
135 virtual void set_send_p(bool state);
136 virtual void set_read_p(bool state);
137
138 // DAP4
139 virtual void intern_data(/*Crc32 &checksum, DMR &dmr, ConstraintEvaluator &eval*/);
140 virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false);
141 virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
142
143 void print_dap4(XMLWriter &xml, bool constrained = false);
144
145 virtual std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table);
146 //virtual std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table, bool is_root);
147
148};
149
150} /* namespace libdap */
151#endif /* D4GROUP_H_ */
Definition crc.h:77
A multidimensional array of identical data types.
Definition Array.h:113
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:316
virtual string dataset() const
Returns the name of the dataset used to create this instance.
Definition BaseType.cc:354
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:267
Array * find_map_source(const string &path)
Given a path to an Array that is also a Map, get that Array.
Definition D4Group.cc:299
virtual void intern_data()
Read data into this variable.
Definition D4Group.cc:491
virtual void set_read_p(bool state)
Set the 'read_p' property for the Constructor and its members.
Definition D4Group.cc:471
BaseType * find_var(const string &name)
Definition D4Group.cc:376
virtual std::string FQN() const
Definition D4Group.cc:182
groupsIter grp_begin()
Get an iterator to the start of the values.
Definition D4Group.h:112
virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr)
Definition D4Group.cc:582
virtual void set_send_p(bool state)
Definition D4Group.cc:481
uint64_t request_size_kb(bool constrained)
Get the estimated size of a response in kilobytes. This method looks at the variables in the DDS and ...
Definition D4Group.cc:446
groupsIter grp_end()
Get an iterator to the end of the values.
Definition D4Group.h:115
D4Dimensions * dims()
Get the dimensions defined for this Group.
Definition D4Group.h:83
virtual BaseType * ptr_duplicate()
Definition D4Group.cc:160
virtual std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table)
Transform the D4Group's variables to DAP2 variables.
Definition D4Group.cc:699
D4EnumDefs * enum_defs()
Get the enumerations defined for this Group.
Definition D4Group.h:98
long request_size(bool constrained)
Definition D4Group.cc:409
D4Group(const string &name)
Definition D4Group.cc:119
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition D4Group.cc:610
virtual void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter=false)
Serialize a Group.
Definition D4Group.cc:543
top level DAP object to house generic methods