libdap++  Updated for version 3.12.0
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 
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