libdap  Updated for version 3.20.6
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 
33 class Crc32;
34 
35 namespace libdap
36 {
37 
38 class DMR;
39 class XMLWriter;
40 class D4StreamUnMarshaller;
41 
43 class Constructor: public BaseType
44 {
45 private:
46  Constructor(); // No default ctor.
47 
48 protected:
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 
60 public:
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
virtual unsigned int width(bool constrained=false) const
Definition: Constructor.cc:249
virtual string name() const
Returns the name of the class instance.
Definition: BaseType.cc:320
virtual void set_in_selection(bool state)
Set the in_selection property.
Definition: Constructor.cc:834
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
virtual std::string FQN() const
Definition: Constructor.cc:181
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())
Definition: Constructor.cc:267
Part
Names the parts of multi-section constructor data types.
Definition: Type.h:48
Contains the attributes for a dataset.
Definition: AttrTable.h:142
Read data from the stream made by D4StreamMarshaller.
Vars_riter var_rend()
Definition: Constructor.cc:379
Definition: crc.h:76
virtual void compute_checksum(Crc32 &checksum)
include the data for this variable in the checksum DAP4 includes a checksum with every data response...
Definition: Constructor.cc:550
virtual void add_var_nocopy(BaseType *bt, Part part=nil)
Definition: Constructor.cc:432
virtual void add_var(BaseType *bt, Part part=nil)
Definition: Constructor.cc:407
Type
Identifies the data type.
Definition: Type.h:94
virtual int element_count(bool leaves=false)
Count the members of constructor types.
Definition: Constructor.cc:194
top level DAP object to house generic methods
Definition: AISConnect.cc:30
A class for software fault reporting.
Definition: InternalErr.h:64
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Definition: Constructor.cc:695
virtual void transform_to_dap4(D4Group *root, Constructor *dest)
DAP2 to DAP4 transform.
Definition: Constructor.cc:141
virtual bool is_linear()
Check to see whether this variable can be printed simply.
Definition: Constructor.cc:823
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4&#39;s receiv...
Vars_riter var_rbegin()
Definition: Constructor.cc:371
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: Constructor.cc:504
virtual Type type() const
Returns the type of the class instance.
Definition: BaseType.cc:365
BaseType * get_var_index(int i)
Definition: Constructor.cc:397
virtual bool read()
simple implementation of read that iterates through vars and calls read on them
Definition: Constructor.cc:476
virtual bool check_semantics(string &msg, bool all=false)
Compare an object&#39;s current state with the semantics of its type.
Definition: Constructor.cc:792
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
Definition: Constructor.cc:540
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: Constructor.cc:650
virtual unsigned int val2buf(void *, bool)
Loads class data.
Definition: Constructor.h:115
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Constructor.cc:913
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Definition: Constructor.cc:718
Evaluate a constraint expression.
virtual unsigned int buf2val(void **)
Reads the class data.
Definition: Constructor.h:118
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:50
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.
Definition: Constructor.cc:626
Vars_iter var_begin()
Definition: Constructor.cc:356
Vars_iter var_end()
Definition: Constructor.cc:364
Vars_iter get_vars_iter(int i)
Definition: Constructor.cc:388
virtual void transfer_attributes(AttrTable *at)
Definition: Constructor.cc:844
virtual void intern_data()
Read data into this variable.
Definition: Constructor.cc:556
void print_dap4(XMLWriter &xml, bool constrained=false)
Definition: Constructor.cc:768
virtual void del_var(const string &name)
Definition: Constructor.cc:448
virtual void set_send_p(bool state)
Definition: Constructor.cc:208
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: Constructor.cc:218