libdap  Updated for version 3.20.6
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 
27 #include "Constructor.h"
28 #include "D4Dimensions.h"
29 #include "D4EnumDefs.h"
30 
31 class Crc32;
32 
33 namespace libdap {
34 
35 class BaseType;
36 class Array;
37 
43 class D4Group :public Constructor {
44 private:
45  // Note that because Constructor is a BaseType, this class inherits
46  // both a back pointer to its parent, an AttrTable and, directly from the
47  // Constructor class, a vector of BaseTypes.
48 
49  // This instance of D4Dimensions holds the Group's definitions; the same
50  // class is used by Array to hold the actual dimensions for a variable.
51  D4Dimensions *d_dims;
52 
53  // This holds the Group's enumeration definitions; a different class is
54  // used for the Enumeration type
55  D4EnumDefs *d_enum_defs;
56 
57  // This is a pointer so that the factory class(es) that return pointers
58  // work as expected when making Groups.
59  vector<D4Group*> d_groups;
60 
61  BaseType *m_find_map_source_helper(const string &name);
62 
63 protected:
64  void m_duplicate(const D4Group &g);
65 
66 public:
67  typedef vector<D4Group*>::iterator groupsIter;
68  typedef vector<D4Group*>::const_iterator groupsCIter;
69 
70  D4Group(const string &name);
71  D4Group(const string &name, const string &dataset);
72 
73  D4Group(const D4Group &rhs);
74  virtual ~D4Group();
75 
76  D4Group &operator=(const D4Group &rhs);
77 
78  // This method returned a D4Group * previously. jhrg 11/17/16
79  virtual BaseType *ptr_duplicate();
80 
83  // If not built yet, make one and set this as parent.
84  if (!d_dims) d_dims = new D4Dimensions(this);
85  return d_dims;
86  }
87 
88  virtual std::string FQN() const;
89 
90  D4Dimension *find_dim(const string &path);
91 
92  Array *find_map_source(const string &path);
93 
94  D4EnumDef *find_enum_def(const string &path);
95 
98  if (!d_enum_defs) {
99  d_enum_defs = new D4EnumDefs;
100  d_enum_defs->set_parent(this);
101  }
102  return d_enum_defs;
103  }
104 
105  BaseType *find_first_var_that_uses_dimension(D4Dimension *dim);
106  BaseType *find_first_var_that_uses_enumeration(D4EnumDef *enum_def);
107 
108  BaseType *find_var(const string &name);
109 
111  groupsIter grp_begin() { return d_groups.begin(); }
112 
114  groupsIter grp_end() { return d_groups.end(); }
115 
116  void add_group(const D4Group *g) {
117  add_group_nocopy(new D4Group(*g));
118  }
119 
120  void add_group_nocopy(D4Group *g) {
121  g->set_parent(this);
122  d_groups.push_back(g);
123  }
124  void insert_group_nocopy(D4Group *g, groupsIter i) {
125  g->set_parent(this);
126  d_groups.insert(i, g);
127  }
128 
129  D4Group *find_child_grp(const string &grp_name);
130 
131  long request_size(bool constrained);
132 
133  virtual void set_send_p(bool state);
134  virtual void set_read_p(bool state);
135 
136  // DAP4
137  virtual void intern_data(/*Crc32 &checksum, DMR &dmr, ConstraintEvaluator &eval*/);
138  virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false);
139  virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
140 
141  void print_dap4(XMLWriter &xml, bool constrained = false);
142 
143  virtual std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table);
144  //virtual std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table, bool is_root);
145 
146 };
147 
148 } /* namespace libdap */
149 #endif /* D4GROUP_H_ */
virtual string name() const
Returns the name of the class instance.
Definition: BaseType.cc:320
Contains the attributes for a dataset.
Definition: AttrTable.h:142
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:277
Read data from the stream made by D4StreamMarshaller.
D4Group(const string &name)
Definition: D4Group.cc:119
Definition: crc.h:76
virtual void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter=false)
Serialize a Group.
Definition: D4Group.cc:507
virtual void set_parent(BaseType *parent)
Definition: BaseType.cc:733
top level DAP object to house generic methods
Definition: AISConnect.cc:30
virtual BaseType * ptr_duplicate()
Definition: D4Group.cc:160
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4&#39;s receiv...
long request_size(bool constrained)
Definition: D4Group.cc:409
groupsIter grp_end()
Get an iterator to the end of the values.
Definition: D4Group.h:114
virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr)
Definition: D4Group.cc:546
virtual void intern_data()
Read data into this variable.
Definition: D4Group.cc:455
groupsIter grp_begin()
Get an iterator to the start of the values.
Definition: D4Group.h:111
virtual std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table)
Transform the D4Group&#39;s variables to DAP2 variables.
Definition: D4Group.cc:663
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition: D4Group.cc:574
virtual std::string FQN() const
Definition: D4Group.cc:185
D4EnumDefs * enum_defs()
Get the enumerations defined for this Group.
Definition: D4Group.h:97
A multidimensional array of identical data types.
Definition: Array.h:112
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: D4Group.cc:435
virtual void set_send_p(bool state)
Definition: D4Group.cc:445
virtual string dataset() const
Returns the name of the dataset used to create this instance.
Definition: BaseType.cc:358
BaseType * find_var(const string &name)
Definition: D4Group.cc:376
D4Dimensions * dims()
Get the dimensions defined for this Group.
Definition: D4Group.h:82