libdap  Updated for version 3.18.2
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  virtual D4Group *ptr_duplicate();
78 
81  // If not built yet, make one and set this as parent.
82  if (!d_dims) d_dims = new D4Dimensions(this);
83  return d_dims;
84  }
85 
86  virtual std::string FQN() const;
87 
88  D4Dimension *find_dim(const string &path);
89 
90  Array *find_map_source(const string &path);
91 
92  D4EnumDef *find_enum_def(const string &path);
93 
96  if (!d_enum_defs) {
97  d_enum_defs = new D4EnumDefs;
98  d_enum_defs->set_parent(this);
99  }
100  return d_enum_defs;
101  }
102 
103  BaseType *find_first_var_that_uses_dimension(D4Dimension *dim);
104  BaseType *find_first_var_that_uses_enumeration(D4EnumDef *enum_def);
105 
106  BaseType *find_var(const string &name);
107 
109  groupsIter grp_begin() { return d_groups.begin(); }
110 
112  groupsIter grp_end() { return d_groups.end(); }
113 
114  void add_group(const D4Group *g) {
115  add_group_nocopy(new D4Group(*g));
116  }
117 
118  void add_group_nocopy(D4Group *g) {
119  g->set_parent(this);
120  d_groups.push_back(g);
121  }
122  void insert_group_nocopy(D4Group *g, groupsIter i) {
123  g->set_parent(this);
124  d_groups.insert(i, g);
125  }
126 
127  D4Group *find_child_grp(const string &grp_name);
128 
129  long request_size(bool constrained);
130 
131  virtual void set_send_p(bool state);
132  virtual void set_read_p(bool state);
133 
134  // DAP4
135  virtual void intern_data(/*Crc32 &checksum, DMR &dmr, ConstraintEvaluator &eval*/);
136  virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false);
137  virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
138 
139  void print_dap4(XMLWriter &xml, bool constrained = false);
140 };
141 
142 } /* namespace libdap */
143 #endif /* D4GROUP_H_ */
virtual string name() const
Returns the name of the class instance.
Definition: BaseType.cc:265
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:268
Read data from the stream made by D4StreamMarshaller.
D4Group(const string &name)
Definition: D4Group.cc:115
Definition: crc.h:76
virtual void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter=false)
Serialize a Group.
Definition: D4Group.cc:498
virtual void set_parent(BaseType *parent)
Definition: BaseType.cc:654
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:400
groupsIter grp_end()
Get an iterator to the end of the values.
Definition: D4Group.h:112
virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr)
Definition: D4Group.cc:537
virtual void intern_data()
Read data into this variable.
Definition: D4Group.cc:446
groupsIter grp_begin()
Get an iterator to the start of the values.
Definition: D4Group.h:109
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition: D4Group.cc:565
virtual std::string FQN() const
Definition: D4Group.cc:176
virtual D4Group * ptr_duplicate()
Definition: D4Group.cc:151
D4EnumDefs * enum_defs()
Get the enumerations defined for this Group.
Definition: D4Group.h:95
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:426
virtual void set_send_p(bool state)
Definition: D4Group.cc:436
virtual string dataset() const
Returns the name of the dataset used to create this instance.
Definition: BaseType.cc:303
BaseType * find_var(const string &name)
Definition: D4Group.cc:367
D4Dimensions * dims()
Get the dimensions defined for this Group.
Definition: D4Group.h:80