libdap++  Updated for version 3.11.7
BaseType.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 // Dan Holloway <dan@hollywood.gso.uri.edu>
10 // Reza Nekovei <reza@intcomm.net>
11 //
12 // This library is free software; you can redistribute it and/or
13 // modify it under the terms of the GNU Lesser General Public
14 // License as published by the Free Software Foundation; either
15 // version 2.1 of the License, or (at your option) any later version.
16 //
17 // This library is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 // Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public
23 // License along with this library; if not, write to the Free Software
24 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 //
26 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
27 
28 // (c) COPYRIGHT URI/MIT 1994-1999
29 // Please read the full copyright statement in the file COPYRIGHT_URI.
30 //
31 // Authors:
32 // jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
33 // dan Dan Holloway <dan@hollywood.gso.uri.edu>
34 // reza Reza Nekovei <reza@intcomm.net>
35 
36 // Abstract base class for the variables in a dataset. This is used to store
37 // the type-invariant information that describes a variable as given in the
38 // DODS API.
39 //
40 // jhrg 9/6/94
41 
42 #ifndef _basetype_h
43 #define _basetype_h 1
44 
45 
46 #include <vector>
47 #include <stack>
48 #include <iostream>
49 #include <string>
50 
51 #ifndef _attrtable_h
52 #include "AttrTable.h"
53 #endif
54 
55 #ifndef _internalerr_h
56 #include "InternalErr.h"
57 #endif
58 
59 #ifndef __DODS_DATATYPES_
60 #include "dods-datatypes.h"
61 #endif
62 
63 #ifndef A_DapObj_h
64 #include "DapObj.h"
65 #endif
66 
67 #ifndef XMLWRITER_H_
68 #include "XMLWriter.h"
69 #endif
70 
71 #include "Marshaller.h"
72 #include "UnMarshaller.h"
73 
74 #define FILE_METHODS 1
75 
76 using namespace std;
77 
78 namespace libdap
79 {
80 
81 class DDS;
82 class ConstraintEvaluator;
83 
102 enum Part {
103  nil, // nil is for types that don't have parts...
106 };
107 
135 enum Type {
140  dods_int32_c, // Added `dods_' to fix clash with IRIX 5.3.
150 };
151 
194 class BaseType : public DapObj
195 {
196 private:
197  string _name; // name of the instance
198  Type _type; // instance's type
199  string _dataset; // name of the dataset used to create this BaseType
200 
201  bool _read_p; // true if the value has been read
202  bool _send_p; // Is the variable in the projection?
203  bool d_in_selection; // Is the variable in the selection?
204  bool _synthesized_p; // true if the variable is synthesized
205 
206  // d_parent points to the Constructor or Vector which holds a particular
207  // variable. It is null for simple variables. The Vector and Constructor
208  // classes must maintain this variable.
209  BaseType *d_parent;
210 
211  // Attributes for this variable. Added 05/20/03 jhrg
212  AttrTable d_attr;
213 
214 protected:
215  void _duplicate(const BaseType &bt);
216 
217 public:
218  typedef stack<BaseType *> btp_stack;
219 
220  BaseType(const string &n, const Type &t);
221  BaseType(const string &n, const string &d, const Type &t);
222 
223  BaseType(const BaseType &copy_from);
224  virtual ~BaseType();
225 
226  virtual string toString();
227 
228  virtual void dump(ostream &strm) const ;
229 
230  BaseType &operator=(const BaseType &rhs);
231 
238  virtual BaseType *ptr_duplicate() = 0;
239 
240  string name() const;
241  virtual void set_name(const string &n);
242 
243  Type type() const;
244  void set_type(const Type &t);
245  string type_name() const;
246 
247  string dataset() const ;
248 
249  virtual bool is_simple_type();
250  virtual bool is_vector_type();
251  virtual bool is_constructor_type();
252 
253  virtual bool synthesized_p();
254  virtual void set_synthesized_p(bool state);
255 
256  virtual int element_count(bool leaves = false);
257 
258  virtual bool read_p();
259  virtual void set_read_p(bool state);
260 
261  virtual bool send_p();
262  virtual void set_send_p(bool state);
263 
264  virtual AttrTable &get_attr_table();
265  virtual void set_attr_table(const AttrTable &at);
266 
267  virtual bool is_in_selection();
268  virtual void set_in_selection(bool state);
269 
270  virtual void set_parent(BaseType *parent);
271  virtual BaseType *get_parent();
272 
273  virtual void transfer_attributes(AttrTable *at);
274 
275  // I put this comment here because the version in BaseType.cc does not
276  // include the exact_match or s variables since they are not used. Doxygen
277  // was gaging on the comment.
278 
309  virtual BaseType *var(const string &name = "", bool exact_match = true,
310  btp_stack *s = 0);
311  virtual BaseType *var(const string &name, btp_stack &s);
312 
313  virtual void add_var(BaseType *bt, Part part = nil);
314 
315  virtual bool read();
316 
317  virtual bool check_semantics(string &msg, bool all = false);
318 
319  virtual bool ops(BaseType *b, int op);
320 #if FILE_METHODS
321  virtual void print_decl(FILE *out, string space = " ",
322  bool print_semi = true,
323  bool constraint_info = false,
324  bool constrained = false);
325 
326  virtual void print_xml(FILE *out, string space = " ",
327  bool constrained = false);
328 #endif
329  virtual void print_decl(ostream &out, string space = " ",
330  bool print_semi = true,
331  bool constraint_info = false,
332  bool constrained = false);
333 
334  virtual void print_xml(ostream &out, string space = " ",
335  bool constrained = false);
336 
337  virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
338 
341 
353  virtual unsigned int width() = 0;
354  virtual unsigned int width(bool constrained);
355 
376  virtual unsigned int buf2val(void **val) = 0;
377 
407  virtual unsigned int val2buf(void *val, bool reuse = false) = 0;
408 
421  virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
422 
450  virtual bool serialize(ConstraintEvaluator &eval, DDS &dds,
451  Marshaller &m, bool ce_eval = true) = 0;
452 
477  virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false) = 0;
478 
479 #if FILE_METHODS
480 
495  virtual void print_val(FILE *out, string space = "",
496  bool print_decl_p = true) = 0;
497 #endif
498 
513  virtual void print_val(ostream &out, string space = "",
514  bool print_decl_p = true) = 0;
516 };
517 
518 } // namespace libdap
519 
520 #endif // _basetype_h
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
Part
Names the parts of multi-section constructor data types.
Definition: BaseType.h:102
Contains the attributes for a dataset.
Definition: AttrTable.h:150
Type
Identifies the data type.
Definition: BaseType.h:135
stack< BaseType * > btp_stack
Definition: BaseType.h:218
Evaluate a constraint expression.
The basic data type for the DODS DAP types.
Definition: BaseType.h:194
libdap base object for common functionality of libdap objects
Definition: DapObj.h:55
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:53