Constructor.h
// -*- mode: c++; c-basic-offset:4 -*-
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.
// Copyright (c) 2002,2003 OPeNDAP, Inc.
// Author: James Gallagher <jgallagher@opendap.org>
//
// 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 _constructor_h
#define _constructor_h 1
#include <vector>
#include "BaseType.h"
class Crc32;
namespace libdap {
class DMR;
class XMLWriter;
class D4StreamUnMarshaller;
class Constructor : public BaseType {
private:
void m_duplicate(const Constructor &s);
protected:
std::vector<BaseType *> d_vars;
BaseType *m_leaf_match(const string &name, btp_stack *s = nullptr);
BaseType *m_exact_match(const string &name, btp_stack *s = nullptr);
Constructor(const string &name, const Type &type, bool is_dap4 = false) : BaseType(name, type, is_dap4) {}
Constructor(const string &name, const string &dataset, const Type &type, bool is_dap4 = false)
: BaseType(name, dataset, type, is_dap4) {}
Constructor(const Constructor &copy_from) : BaseType(copy_from) { m_duplicate(copy_from); }
public:
typedef std::vector<BaseType *>::const_iterator Vars_citer;
typedef std::vector<BaseType *>::iterator Vars_iter;
typedef std::vector<BaseType *>::reverse_iterator Vars_riter;
Constructor() = delete; // Why? jhrg 4/25/22
~Constructor() override {
for (auto var : d_vars)
delete var;
}
Constructor &operator=(const Constructor &rhs) {
if (this == &rhs)
return *this;
BaseType::operator=(rhs);
m_duplicate(rhs);
return *this;
}
void transform_to_dap4(D4Group *root, Constructor *dest) override;
std::string FQN() const override;
int element_count(bool leaves = false) override;
void set_send_p(bool state) override;
void set_read_p(bool state) override;
unsigned int width(bool constrained = false) const override;
int64_t width_ll(bool constrained = false) const override;
BaseType *var(const string &name, bool exact_match = true, btp_stack *s = nullptr) override;
BaseType *var(const string &n, btp_stack &s) override;
Vars_iter var_begin();
Vars_iter var_end();
Vars_riter var_rbegin();
Vars_riter var_rend();
Vars_iter get_vars_iter(int i);
BaseType *get_var_index(int i);
void set_var_index(BaseType *bt, int i);
const vector<BaseType *> &variables() const { return d_vars; }
bool is_dap4_projected(std::vector<std::string> &inventory) override;
void add_var(BaseType *bt, Part part = nil) override;
void add_var_nocopy(BaseType *bt, Part part = nil) override;
virtual void del_var(const string &name);
virtual void del_var(Vars_iter i);
bool read() override;
// DAP2
void intern_data(ConstraintEvaluator &eval, DDS &dds) override;
bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true) override;
bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false) override;
// DAP4
void compute_checksum(Crc32 &checksum) override;
void intern_data() override;
void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter = false) override;
void deserialize(D4StreamUnMarshaller &um, DMR &dmr) override;
// Do not store values in memory as for C; users work with the C++ objects for this class
unsigned int val2buf(void *, bool) override {
throw InternalErr(__FILE__, __LINE__, "Never use this method; see the programmer's guide documentation.");
}
unsigned int buf2val(void **) override {
throw InternalErr(__FILE__, __LINE__, "Never use this method; see the programmer's guide documentation.");
}
virtual bool is_linear();
void set_in_selection(bool state) override;
void print_decl(ostream &out, string space = " ", bool print_semi = true, bool constraint_info = false,
bool constrained = false) override;
void print_xml(ostream &out, string space = " ", bool constrained = false) override;
void print_dap4(XMLWriter &xml, bool constrained = false) override;
void print_xml_writer(XMLWriter &xml, 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_xml(FILE *out, string space = " ", 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;
bool check_semantics(string &msg, bool all = false) override;
void transfer_attributes(AttrTable *at) override;
static AttrTable *make_dropped_vars_attr_table(vector<BaseType *> *dropped_vars);
void dump(ostream &strm) const override;
};
} // namespace libdap
#endif // _constructor_h
BaseType
Crc32
Definition crc.h:45
libdap::ConstraintEvaluator
Evaluate a constraint expression.
Definition ConstraintEvaluator.h:41
libdap::Constructor::get_vars_iter
Vars_iter get_vars_iter(int i)
Definition Constructor.cc:285
libdap::Constructor::var
BaseType * var(const string &name, bool exact_match=true, btp_stack *s=nullptr) override
btp_stack no longer needed; use back pointers (BaseType::get_parent())
Definition Constructor.cc:191
libdap::Constructor::set_var_index
void set_var_index(BaseType *bt, int i)
Set the ith element of d_vars to a variable object.
Definition Constructor.cc:301
libdap::Constructor::add_var
void add_var(BaseType *bt, Part part=nil) override
Definition Constructor.cc:322
libdap::Constructor::print_xml
void print_xml(ostream &out, string space=" ", bool constrained=false) override
Definition Constructor.cc:568
libdap::Constructor::set_read_p
void set_read_p(bool state) override
Set the 'read_p' property for the Constructor and its members.
Definition Constructor.cc:140
libdap::Constructor::is_dap4_projected
bool is_dap4_projected(std::vector< std::string > &inventory) override
Definition Constructor.cc:722
libdap::Constructor::var_end
Vars_iter var_end()
Definition Constructor.cc:273
libdap::Constructor::read
bool read() override
Read the elements of Constructor marked for transmission.
Definition Constructor.cc:386
libdap::Constructor::set_in_selection
void set_in_selection(bool state) override
Set the in_selection property.
Definition Constructor.cc:656
libdap::Constructor::var_rbegin
Vars_riter var_rbegin()
Definition Constructor.cc:276
libdap::Constructor::add_var_nocopy
void add_var_nocopy(BaseType *bt, Part part=nil) override
Definition Constructor.cc:340
libdap::Constructor::variables
const vector< BaseType * > & variables() const
Definition Constructor.h:110
libdap::Constructor::width
unsigned int width(bool constrained=false) const override
Definition Constructor.cc:156
libdap::Constructor::get_var_index
BaseType * get_var_index(int i)
Definition Constructor.cc:290
libdap::Constructor::var_begin
Vars_iter var_begin()
Definition Constructor.cc:269
libdap::Constructor::var_rend
Vars_riter var_rend()
Definition Constructor.cc:280
libdap::Constructor::is_linear
virtual bool is_linear()
Check to see whether this variable can be printed simply.
Definition Constructor.cc:649
libdap::Constructor::del_var
virtual void del_var(const string &name)
Remove an element from a Constructor.
Definition Constructor.cc:359
libdap::Constructor::dump
void dump(ostream &strm) const override
dumps information about this object
Definition Constructor.cc:741
libdap::Constructor::width_ll
int64_t width_ll(bool constrained=false) const override
Get the width of the Constructor's fields.
Definition Constructor.cc:176
libdap::D4Group
Definition D4Group.h:44
libdap::D4StreamMarshaller
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
Definition D4StreamMarshaller.h:71
libdap::D4StreamUnMarshaller
Read data from the stream made by D4StreamMarshaller.
Definition D4StreamUnMarshaller.h:65
libdap::DDS
Definition DDS.h:176
libdap::DMR
Definition DMR.h:56
libdap::InternalErr
A class for software fault reporting.
Definition InternalErr.h:61
libdap::Marshaller
abstract base class used to marshal/serialize dap data objects
Definition Marshaller.h:50
libdap::UnMarshaller
abstract base class used to unmarshall/deserialize dap data objects
Definition UnMarshaller.h:53
libdap::XMLWriter
Definition XMLWriter.h:39
libdap
top level DAP object to house generic methods
Definition AlarmHandler.h:35
libdap::Type
Type
Identifies the data type.
Definition Type.h:94
libdap::deserialize
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
Definition D4Sequence.h:206
libdap::serialize
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net, then remove them from the object.
Definition D4Sequence.h:203
libdap::intern_data
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
Definition D4Sequence.h:200
libdap::compute_checksum
virtual void compute_checksum(Crc32 &checksum)=0
include the data for this variable in the checksum DAP4 includes a checksum with every data response....
libdap::Part
Part
Names the parts of multi-section constructor data types.
Definition Type.h:48
libdap::dataset
virtual string dataset() const
Returns the name of the dataset used to create this instance.
Definition BaseType.cc:326
libdap::val2buf
virtual unsigned int val2buf(void *val, bool reuse=false)=0
Loads class data.