D4Group.h
// -*- mode: c++; c-basic-offset:4 -*-
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
#ifndef D4GROUP_H_
#define D4GROUP_H_
#include <string>
#include <cstdint>
#include "Constructor.h"
#include "D4Dimensions.h"
#include "D4EnumDefs.h"
class Crc32;
namespace libdap {
class BaseType;
class Array;
class D4Group :public Constructor {
private:
// Note that because Constructor is a BaseType, this class inherits
// both a back pointer to its parent, an AttrTable and, directly from the
// Constructor class, a vector of BaseTypes.
// This instance of D4Dimensions holds the Group's definitions; the same
// class is used by Array to hold the actual dimensions for a variable.
D4Dimensions *d_dims;
// This holds the Group's enumeration definitions; a different class is
// used for the Enumeration type
D4EnumDefs *d_enum_defs;
// This is a pointer so that the factory class(es) that return pointers
// work as expected when making Groups.
vector<D4Group*> d_groups;
BaseType *m_find_map_source_helper(const string &name);
protected:
void m_duplicate(const D4Group &g);
public:
typedef vector<D4Group*>::iterator groupsIter;
typedef vector<D4Group*>::const_iterator groupsCIter;
D4Group(const string &name);
D4Group(const string &name, const string &dataset);
D4Group(const D4Group &rhs);
virtual ~D4Group();
D4Group &operator=(const D4Group &rhs);
// This method returned a D4Group * previously. jhrg 11/17/16
BaseType *ptr_duplicate() override;
// TODO Wire up the new D4Dimensions object to have this group as its parent. jhrg 8/22/22
D4Dimensions *dims() {
// If not built yet, make one and set this as parent.
if (!d_dims) d_dims = new D4Dimensions(this);
return d_dims;
}
std::string FQN() const override;
D4Dimension *find_dim(const string &path);
Array *find_map_source(const string &path);
D4EnumDef *find_enum_def(const string &path);
D4EnumDefs *enum_defs() {
if (!d_enum_defs) {
d_enum_defs = new D4EnumDefs;
d_enum_defs->set_parent(this);
}
return d_enum_defs;
}
BaseType *find_first_var_that_uses_dimension(D4Dimension *dim);
BaseType *find_first_var_that_uses_enumeration(D4EnumDef *enum_def);
BaseType *find_var(const string &name);
const vector<D4Group*> &groups() const { return d_groups; }
groupsIter grp_begin() { return d_groups.begin(); }
groupsIter grp_end() { return d_groups.end(); }
void add_group(const D4Group *g) {
add_group_nocopy(new D4Group(*g));
}
void add_group_nocopy(D4Group *g) {
g->set_parent(this);
d_groups.push_back(g);
}
void insert_group_nocopy(D4Group *g, groupsIter i) {
g->set_parent(this);
d_groups.insert(i, g);
}
D4Group *find_child_grp(const string &grp_name);
long request_size(bool constrained);
uint64_t request_size_kb(bool constrained);
void set_send_p(bool state) override;
void set_read_p(bool state) override;
bool is_dap4_projected(std::vector<std::string> &inventory) override;
// DAP4
void intern_data() override;
void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false) override;
void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override;
void print_dap4(XMLWriter &xml, bool constrained = false) override;
void print_decl(ostream &out, string space = " ", bool print_semi = true, bool constraint_info = false,
bool constrained = false) override;
void print_decl(FILE *out, string space = " ", bool print_semi = true, bool constraint_info = false,
bool constrained = false) override;
void print_val(FILE *out, string space = "", bool print_decl_p = true) override;
void print_val(ostream &out, string space = "", bool print_decl_p = true) override;
std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table) override;
};
} /* namespace libdap */
#endif /* D4GROUP_H_ */
Crc32
Definition crc.h:79
libdap::Array
A multidimensional array of identical data types.
Definition Array.h:123
libdap::BaseType
The basic data type for the DODS DAP types.
Definition BaseType.h:120
libdap::BaseType::name
virtual string name() const
Returns the name of the class instance.
Definition BaseType.cc:317
libdap::BaseType::dataset
virtual string dataset() const
Returns the name of the dataset used to create this instance.
Definition BaseType.cc:355
libdap::Constructor
Definition Constructor.h:44
libdap::D4Dimension
Definition D4Dimensions.h:41
libdap::D4Dimensions
Definition D4Dimensions.h:101
libdap::D4EnumDef
Definition D4EnumDefs.h:42
libdap::D4EnumDefs
Definition D4EnumDefs.h:108
libdap::D4Group
Definition D4Group.h:44
libdap::D4Group::print_dap4
void print_dap4(XMLWriter &xml, bool constrained=false) override
Definition D4Group.cc:630
libdap::D4Group::find_dim
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
libdap::D4Group::print_val
void print_val(FILE *out, string space="", bool print_decl_p=true) override
Prints the value of the variable.
Definition D4Group.cc:710
libdap::D4Group::is_dap4_projected
bool is_dap4_projected(std::vector< std::string > &inventory) override
Definition D4Group.cc:898
libdap::D4Group::find_map_source
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
libdap::D4Group::find_var
BaseType * find_var(const string &name)
Definition D4Group.cc:401
libdap::D4Group::grp_begin
groupsIter grp_begin()
Get an iterator to the start of the values.
Definition D4Group.h:115
libdap::D4Group::intern_data
void intern_data() override
Read data into this variable.
Definition D4Group.cc:511
libdap::D4Group::serialize
void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter=false) override
Serialize a Group.
Definition D4Group.cc:563
libdap::D4Group::request_size_kb
uint64_t request_size_kb(bool constrained)
Get the estimated size of a response in kilobytes.
Definition D4Group.cc:467
libdap::D4Group::grp_end
groupsIter grp_end()
Get an iterator to the end of the values.
Definition D4Group.h:118
libdap::D4Group::dims
D4Dimensions * dims()
Get the dimensions defined for this Group.
Definition D4Group.h:84
libdap::D4Group::set_send_p
void set_send_p(bool state) override
Definition D4Group.cc:501
libdap::D4Group::ptr_duplicate
BaseType * ptr_duplicate() override
Definition D4Group.cc:165
libdap::D4Group::set_read_p
void set_read_p(bool state) override
Set the 'read_p' property for the Constructor and its members.
Definition D4Group.cc:491
libdap::D4Group::print_decl
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
libdap::D4Group::enum_defs
D4EnumDefs * enum_defs()
Get the enumerations defined for this Group.
Definition D4Group.h:99
libdap::D4Group::request_size
long request_size(bool constrained)
Definition D4Group.cc:448
libdap::D4Group::D4Group
D4Group(const string &name)
Definition D4Group.cc:124
libdap::D4Group::transform_to_dap2
std::vector< BaseType * > * transform_to_dap2(AttrTable *parent_attr_table) override
Transform the D4Group's variables to DAP2 variables.
Definition D4Group.cc:797
libdap::D4Group::FQN
std::string FQN() const override
Definition D4Group.cc:187
libdap::D4Group::deserialize
void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override
Definition D4Group.cc:602
libdap
top level DAP object to house generic methods
Definition AlarmHandler.h:36