libdap++  Updated for version 3.8.2
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 
129  virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
130  virtual bool serialize(ConstraintEvaluator &eval, DDS &dds,
131  Marshaller &m, bool ce_eval = true);
132  virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
133 
134  // Do not store values in memory as for C; force users to work with the
135  // C++ objects as defined by the DAP.
136 
137  virtual unsigned int val2buf(void *val, bool reuse = false);
138  virtual unsigned int buf2val(void **val);
139 
140  virtual BaseType *var(const string &name, bool exact_match = true,
141  btp_stack *s = 0);
142 
143  virtual BaseType *var(const string &n, btp_stack &s);
144 
145  virtual void add_var(BaseType *bt, Part part = nil);
146  virtual void del_var(const string &name);
147 
148  virtual bool read() ;
149 #if FILE_METHODS
150  virtual void print_val(FILE *out, string space = "",
151  bool print_decl_p = true);
152 #endif
153  virtual void print_val(ostream &out, string space = "",
154  bool print_decl_p = true);
155 
156  virtual bool check_semantics(string &msg, bool all = false);
157 
158  virtual void dump(ostream &strm) const ;
159 };
160 
161 } // namespace libdap
162 
163 #endif // _structure_h
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval=true)
Move data to the net.
Definition: Structure.cc:300
string name() const
Returns the name of the class instance.
Definition: BaseType.cc:210
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds)
Definition: Structure.cc:286
Structure & operator=(const Structure &rhs)
Definition: Structure.cc:128
virtual BaseType * ptr_duplicate()
Definition: Structure.cc:122
Part
Names the parts of multi-section constructor data types.
Definition: BaseType.h:98
virtual BaseType * var(const string &name, bool exact_match=true, btp_stack *s=0)
Returns a pointer to a member of a constructor class.
Definition: Structure.cc:359
virtual bool check_semantics(string &msg, bool all=false)
Compare an object&#39;s current state with the semantics of its type.
Definition: Structure.cc:492
Structure(const string &n)
Definition: Structure.cc:91
void _duplicate(const Structure &s)
Definition: Structure.cc:65
virtual void add_var(BaseType *bt, Part part=nil)
Definition: Structure.cc:220
Holds a structure (aggregate) type.
Definition: Structure.h:100
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse=false)
Receive data from the net.
Definition: Structure.cc:325
stack< BaseType * > btp_stack
Definition: BaseType.h:214
virtual void set_leaf_sequence(int level=1)
Traverse Structure, set Sequence leaf nodes.
Definition: Structure.cc:205
virtual void set_in_selection(bool state)
Set the in_selection property.
Definition: Structure.cc:194
virtual unsigned int width()
Returns the size of the class instance data.
Definition: Structure.cc:274
virtual int element_count(bool leaves=false)
Count the members of constructor types.
Definition: Structure.cc:141
virtual unsigned int val2buf(void *val, bool reuse=false)
Never call this.
Definition: Structure.cc:344
virtual unsigned int buf2val(void **val)
Never call this.
Definition: Structure.cc:353
virtual void del_var(const string &name)
Definition: Structure.cc:242
Evaluate a constraint expression.
The basic data type for the DODS DAP types.
Definition: BaseType.h:190
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:53
virtual bool is_linear()
Check to see whether this variable can be printed simply.
Definition: Structure.cc:155
virtual void dump(ostream &strm) const
dumps information about this object
Definition: Structure.cc:525
virtual void print_val(FILE *out, string space="", bool print_decl_p=true)
Prints the value of the variable.
Definition: Structure.cc:451
virtual void set_send_p(bool state)
Definition: Structure.cc:169
virtual void set_read_p(bool state)
Sets the value of the read_p property.
Definition: Structure.cc:179
virtual bool read()
simple implementation of reat that iterates through vars and calls read on them
Definition: Structure.cc:260
virtual ~Structure()
Definition: Structure.cc:113