libdap++  Updated for version 3.11.7
Structure.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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 //
24 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25 
26 // (c) COPYRIGHT URI/MIT 1995-1999
27 // Please read the full copyright statement in the file COPYRIGHT_URI.
28 //
29 // Authors:
30 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
31 
32 // Interface for the class Structure. A structure contains a single set of
33 // variables, all at the same lexical level. Of course, a structure may
34 // contain other structures... The variables contained in a structure are
35 // stored by instances of this class in a SLList of BaseType pointers.
36 //
37 // jhrg 9/14/94
38 
39 #ifndef _structure_h
40 #define _structure_h 1
41 
42 #ifndef __POWERPC__
43 #endif
44 
45 #include <vector>
46 
47 #ifndef _basetype_h
48 #include "BaseType.h"
49 #endif
50 
51 #ifndef _constructor_h
52 #include "Constructor.h"
53 #endif
54 
55 #ifndef _dds_h
56 #include "DDS.h"
57 #endif
58 
59 #ifndef constraint_evaluator_h
60 #include "ConstraintEvaluator.h"
61 #endif
62 
63 #define FILE_METHODS 1
64 
65 namespace libdap
66 {
67 
100 class Structure: public Constructor
101 {
102 private:
103  BaseType *m_leaf_match(const string &name, btp_stack *s = 0);
104  BaseType *m_exact_match(const string &name, btp_stack *s = 0);
105 
106 protected:
107  void _duplicate(const Structure &s);
108 
109 public:
110  Structure(const string &n);
111  Structure(const string &n, const string &d);
112 
113  Structure(const Structure &rhs);
114  virtual ~Structure();
115 
116  Structure &operator=(const Structure &rhs);
117  virtual BaseType *ptr_duplicate();
118 
119  virtual int element_count(bool leaves = false);
120  virtual bool is_linear();
121 
122  virtual void set_send_p(bool state);
123  virtual void set_read_p(bool state);
124  virtual void set_in_selection(bool state);
125  virtual void set_leaf_sequence(int level = 1);
126 
127  virtual unsigned int width();
128  virtual unsigned int width(bool constrained);
129 
130  virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
131  virtual bool serialize(ConstraintEvaluator &eval, DDS &dds,
132  Marshaller &m, bool ce_eval = true);
133  virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
134 
135  // Do not store values in memory as for C; force users to work with the
136  // C++ objects as defined by the DAP.
137 
138  virtual unsigned int val2buf(void *val, bool reuse = false);
139  virtual unsigned int buf2val(void **val);
140 
141  virtual BaseType *var(const string &name, bool exact_match = true,
142  btp_stack *s = 0);
143 
144  virtual BaseType *var(const string &n, btp_stack &s);
145 
146  virtual void add_var(BaseType *bt, Part part = nil);
147  virtual void add_var_nocopy(BaseType *bt, Part part = nil);
148 
149  virtual void del_var(const string &name);
150 
151  virtual bool read() ;
152 #if FILE_METHODS
153  virtual void print_val(FILE *out, string space = "",
154  bool print_decl_p = true);
155 #endif
156  virtual void print_val(ostream &out, string space = "",
157  bool print_decl_p = true);
158 
159  virtual bool check_semantics(string &msg, bool all = false);
160 
161  virtual void dump(ostream &strm) const ;
162 };
163 
164 } // namespace libdap
165 
166 #endif // _structure_h