libdap Updated for version 3.20.8
libdap4 is an implementation of OPeNDAP's DAP protocol.
Constructor.h
1
2// -*- mode: c++; c-basic-offset:4 -*-
3
4// This file is part of libdap, A C++ implementation of the OPeNDAP Data
5// Access Protocol.
6
7// Copyright (c) 2002,2003 OPeNDAP, Inc.
8// Author: James Gallagher <jgallagher@opendap.org>
9//
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Lesser General Public
12// License as published by the Free Software Foundation; either
13// version 2.1 of the License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23//
24// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25
26#ifndef _constructor_h
27#define _constructor_h 1
28
29#include <vector>
30
31#include "BaseType.h"
32
33class Crc32;
34
35namespace libdap
36{
37
38class DMR;
39class XMLWriter;
40class D4StreamUnMarshaller;
41
43class Constructor: public BaseType
44{
45private:
46 Constructor(); // No default ctor.
47
48protected:
49 std::vector<BaseType *> d_vars;
50
51 void m_duplicate(const Constructor &s);
52 BaseType *m_leaf_match(const string &name, btp_stack *s = 0);
53 BaseType *m_exact_match(const string &name, btp_stack *s = 0);
54
55 Constructor(const string &name, const Type &type, bool is_dap4 = false);
56 Constructor(const string &name, const string &d, const Type &type, bool is_dap4 = false);
57
58 Constructor(const Constructor &copy_from);
59
60public:
61 typedef std::vector<BaseType *>::const_iterator Vars_citer ;
62 typedef std::vector<BaseType *>::iterator Vars_iter ;
63 typedef std::vector<BaseType *>::reverse_iterator Vars_riter ;
64
65 virtual ~Constructor();
66
67 Constructor &operator=(const Constructor &rhs);
68 virtual void transform_to_dap4(D4Group *root, Constructor *dest);
69
70 virtual std::string FQN() const;
71
72 virtual int element_count(bool leaves = false);
73
74 virtual void set_send_p(bool state);
75 virtual void set_read_p(bool state);
76
77 virtual unsigned int width(bool constrained = false) const;
78#if 0
79 virtual unsigned int width(bool constrained);
80#endif
81 // TODO Rewrite these methods to use the back pointers and keep this
82 // for older code.
84 virtual BaseType *var(const string &name, bool exact_match = true, btp_stack *s = 0);
86 virtual BaseType *var(const string &n, btp_stack &s);
87
88 Vars_iter var_begin();
89 Vars_iter var_end();
90 Vars_riter var_rbegin();
91 Vars_riter var_rend();
92 Vars_iter get_vars_iter(int i);
93 BaseType *get_var_index(int i);
94
95 virtual void add_var(BaseType *bt, Part part = nil);
96 virtual void add_var_nocopy(BaseType *bt, Part part = nil);
97
98 virtual void del_var(const string &name);
99 virtual void del_var(Vars_iter i);
100
101 virtual bool read();
102
103 // DAP2
104 virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
105 virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true);
106 virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
107
108 // DAP4
109 virtual void compute_checksum(Crc32 &checksum);
110 virtual void intern_data(/*Crc32 &checksum, DMR &dmr, ConstraintEvaluator &eval*/);
111 virtual void serialize(D4StreamMarshaller &m, DMR &dmr, /*ConstraintEvaluator &eval,*/ bool filter = false);
112 virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
113
114 // Do not store values in memory as for C; users work with the C++ objects
115 virtual unsigned int val2buf(void *, bool) {
116 throw InternalErr(__FILE__, __LINE__, "Never use this method; see the programmer's guide documentation.");
117 }
118 virtual unsigned int buf2val(void **) {
119 throw InternalErr(__FILE__, __LINE__, "Never use this method; see the programmer's guide documentation.");
120 }
121
122 virtual bool is_linear();
123 virtual void set_in_selection(bool state);
124
125 virtual void print_decl(ostream &out, string space = " ",
126 bool print_semi = true,
127 bool constraint_info = false,
128 bool constrained = false);
129
130 virtual void print_xml(ostream &out, string space = " ",
131 bool constrained = false);
132
133 void print_dap4(XMLWriter &xml, bool constrained = false);
134
135 virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
136
137 virtual void print_decl(FILE *out, string space = " ",
138 bool print_semi = true,
139 bool constraint_info = false,
140 bool constrained = false);
141 virtual void print_xml(FILE *out, string space = " ",
142 bool constrained = false);
143
144 virtual void print_val(FILE *out, string space = "",
145 bool print_decl_p = true);
146 virtual void print_val(ostream &out, string space = "",
147 bool print_decl_p = true);
148
149 virtual bool check_semantics(string &msg, bool all = false);
150
151 virtual void transfer_attributes(AttrTable *at);
152 static AttrTable *make_dropped_vars_attr_table(vector<BaseType *> *dropped_vars);
153
154 virtual void dump(ostream &strm) const ;
155};
156
157} // namespace libdap
158
159#endif // _constructor_h
Definition crc.h:77
Contains the attributes for a dataset.
Definition AttrTable.h:143
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:320
virtual Type type() const
Returns the type of the class instance.
Definition BaseType.cc:365
Evaluate a constraint expression.
virtual unsigned int width(bool constrained=false) const
void print_dap4(XMLWriter &xml, bool constrained=false)
virtual int element_count(bool leaves=false)
Count the members of constructor types.
Vars_iter get_vars_iter(int i)
virtual void add_var(BaseType *bt, Part part=nil)
virtual void compute_checksum(Crc32 &checksum)
include the data for this variable in the checksum DAP4 includes a checksum with every data response....
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
virtual BaseType * var(const string &name, bool exact_match=true, btp_stack *s=0)
btp_stack no longer needed; use back pointers (BaseType::get_parent())
virtual void transform_to_dap4(D4Group *root, Constructor *dest)
DAP2 to DAP4 transform.
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net, then remove them from the object.
virtual void transfer_attributes(AttrTable *at)
virtual void intern_data()
Read data into this variable.
virtual void dump(ostream &strm) const
dumps information about this object
Vars_riter var_rbegin()
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
virtual void set_send_p(bool state)
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
virtual void print_decl(ostream &out, string space=" ", bool print_semi=true, bool constraint_info=false, bool constrained=false)
Print an ASCII representation of the variable structure.
virtual void add_var_nocopy(BaseType *bt, Part part=nil)
BaseType * get_var_index(int i)
virtual void set_in_selection(bool state)
Set the in_selection property.
virtual unsigned int buf2val(void **)
Reads the class data.
virtual unsigned int val2buf(void *, bool)
Loads class data.
virtual bool read()
simple implementation of read that iterates through vars and calls read on them
Vars_iter var_begin()
Vars_riter var_rend()
virtual bool is_linear()
Check to see whether this variable can be printed simply.
virtual void del_var(const string &name)
virtual void set_read_p(bool state)
Sets the value of the read_p property.
virtual std::string FQN() const
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4's receiv...
Read data from the stream made by D4StreamMarshaller.
A class for software fault reporting.
Definition InternalErr.h:65
abstract base class used to marshal/serialize dap data objects
Definition Marshaller.h:50
abstract base class used to unmarshall/deserialize dap data objects
top level DAP object to house generic methods
Type
Identifies the data type.
Definition Type.h:94
Part
Names the parts of multi-section constructor data types.
Definition Type.h:48