libdap++  Updated for version 3.13.3
Constructor.h
Go to the documentation of this file.
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 namespace libdap
34 {
35 
37 class Constructor: public BaseType
38 {
39 private:
40  Constructor(); // No default ctor.
41 
42 protected:
43  std::vector<BaseType *> d_vars;
44 
45  void m_duplicate(const Constructor &s);
46  BaseType *m_leaf_match(const string &name, btp_stack *s = 0);
47  BaseType *m_exact_match(const string &name, btp_stack *s = 0);
48 
49  Constructor(const string &n, const Type &t, bool is_dap4 = false);
50  Constructor(const string &n, const string &d, const Type &t, bool is_dap4 = false);
51 
52  Constructor(const Constructor &copy_from);
53 
54 public:
55  typedef std::vector<BaseType *>::const_iterator Vars_citer ;
56  typedef std::vector<BaseType *>::iterator Vars_iter ;
57  typedef std::vector<BaseType *>::reverse_iterator Vars_riter ;
58 
59  virtual ~Constructor();
60 
61  Constructor &operator=(const Constructor &rhs);
62 
63  //virtual void transfer_attributes(AttrTable *at_container);
64 
65  virtual int element_count(bool leaves = false);
66 
67  virtual void set_send_p(bool state);
68  virtual void set_read_p(bool state);
69 
71  virtual unsigned int width(bool constrained = false);
72 #if 0
73  virtual unsigned int width(bool constrained);
74 #endif
75  virtual BaseType *var(const string &name, bool exact_match = true, btp_stack *s = 0);
78  virtual BaseType *var(const string &n, btp_stack &s);
79 
80  Vars_iter var_begin();
81  Vars_iter var_end();
82  Vars_riter var_rbegin();
83  Vars_riter var_rend();
84  Vars_iter get_vars_iter(int i);
85  BaseType *get_var_index(int i);
86 
87  virtual void add_var(BaseType *bt, Part part = nil);
88  virtual void add_var_nocopy(BaseType *bt, Part part = nil);
89 
90  virtual void del_var(const string &name);
91  virtual void del_var(Vars_iter i);
92 
93  virtual bool read();
94  virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
95  virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true);
96  virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
97 
98  // Do not store values in memory as for C; users work with the C++ objects
99  virtual unsigned int val2buf(void *, bool) {
100  throw InternalErr(__FILE__, __LINE__, "Never use this method; see the programmer's guide documentation.");
101  }
102  virtual unsigned int buf2val(void **) {
103  throw InternalErr(__FILE__, __LINE__, "Never use this method; see the programmer's guide documentation.");
104  }
105 
106  virtual bool is_linear();
107  virtual void set_in_selection(bool state);
108 
109  virtual void print_decl(ostream &out, string space = " ",
110  bool print_semi = true,
111  bool constraint_info = false,
112  bool constrained = false);
113 
114  virtual void print_xml(ostream &out, string space = " ",
115  bool constrained = false);
116 
117  virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
118 
119  virtual void print_decl(FILE *out, string space = " ",
120  bool print_semi = true,
121  bool constraint_info = false,
122  bool constrained = false);
123  virtual void print_xml(FILE *out, string space = " ",
124  bool constrained = false);
125 
126  virtual void print_val(FILE *out, string space = "",
127  bool print_decl_p = true);
128  virtual void print_val(ostream &out, string space = "",
129  bool print_decl_p = true);
130 
131  virtual bool check_semantics(string &msg, bool all = false);
132 
133  virtual void dump(ostream &strm) const ;
134 };
135 
136 } // namespace libdap
137 
138 #endif // _constructor_h
virtual ~Constructor()
Definition: Constructor.cc:93
virtual void set_in_selection(bool state)
Set the in_selection property.
Definition: Constructor.cc:625
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
void m_duplicate(const Constructor &s)
Definition: Constructor.cc:59
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:183
Part
Names the parts of multi-section constructor data types.
Definition: BaseType.h:95
std::vector< BaseType * >::reverse_iterator Vars_riter
Definition: Constructor.h:57
std::vector< BaseType * > d_vars
Definition: Constructor.h:43
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
Definition: Constructor.cc:402
std::vector< BaseType * >::iterator Vars_iter
Definition: Constructor.h:56
Vars_riter var_rend()
Definition: Constructor.cc:293
virtual void add_var_nocopy(BaseType *bt, Part part=nil)
Definition: Constructor.cc:346
virtual void add_var(BaseType *bt, Part part=nil)
Definition: Constructor.cc:321
Type
Identifies the data type.
Definition: BaseType.h:137
Constructor & operator=(const Constructor &rhs)
Definition: Constructor.cc:97
virtual int element_count(bool leaves=false)
Count the members of constructor types.
Definition: Constructor.cc:110
stack< BaseType * > btp_stack
Definition: BaseType.h:233
A class for software fault reporting.
Definition: InternalErr.h:64
virtual void print_xml(ostream &out, string space=" ", bool constrained=false)
Definition: Constructor.cc:536
virtual bool is_linear()
Check to see whether this variable can be printed simply.
Definition: Constructor.cc:614
Vars_riter var_rbegin()
Definition: Constructor.cc:285
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net.
Definition: Constructor.cc:416
BaseType * get_var_index(int i)
Definition: Constructor.cc:311
virtual bool read()
simple implementation of read that iterates through vars and calls read on them
Definition: Constructor.cc:389
virtual bool check_semantics(string &msg, bool all=false)
Compare an object's current state with the semantics of its type.
Definition: Constructor.cc:583
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Constructor.cc:643
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
Definition: Constructor.cc:451
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: Constructor.cc:494
virtual unsigned int val2buf(void *, bool)
Loads class data.
Definition: Constructor.h:99
string name() const
Returns the name of the class instance.
Definition: BaseType.cc:254
bool is_dap4()
Definition: BaseType.h:252
BaseType * m_leaf_match(const string &name, btp_stack *s=0)
Definition: Constructor.cc:208
std::vector< BaseType * >::const_iterator Vars_citer
Definition: Constructor.h:55
virtual void print_xml_writer(XMLWriter &xml, bool constrained=false)
Definition: Constructor.cc:559
virtual unsigned int width(bool constrained=false)
Definition: Constructor.cc:165
Evaluate a constraint expression.
virtual unsigned int buf2val(void **)
Reads the class data.
Definition: Constructor.h:102
The basic data type for the DODS DAP types.
Definition: BaseType.h:199
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:53
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:470
Vars_iter var_begin()
Definition: Constructor.cc:270
BaseType * m_exact_match(const string &name, btp_stack *s=0)
Definition: Constructor.cc:235
Vars_iter var_end()
Definition: Constructor.cc:278
Vars_iter get_vars_iter(int i)
Definition: Constructor.cc:302
virtual void del_var(const string &name)
Definition: Constructor.cc:362
virtual void set_send_p(bool state)
Definition: Constructor.cc:124
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: Constructor.cc:134