BaseType.h
// -*- mode: c++; c-basic-offset:4 -*-
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
// Access Protocol.
// Copyright (c) 2002,2003 OPeNDAP, Inc.
// Author: James Gallagher <jgallagher@opendap.org>
// Dan Holloway <dan@hollywood.gso.uri.edu>
// Reza Nekovei <reza@intcomm.net>
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
// (c) COPYRIGHT URI/MIT 1994-1999
// Please read the full copyright statement in the file COPYRIGHT_URI.
//
// Authors:
// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
// dan Dan Holloway <dan@hollywood.gso.uri.edu>
// reza Reza Nekovei <reza@intcomm.net>
// Abstract base class for the variables in a dataset. This is used to store
// the type-invariant information that describes a variable as given in the
// DODS API.
//
// jhrg 9/6/94
#ifndef _basetype_h
#define _basetype_h 1
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include "AttrTable.h"
#include "InternalErr.h"
#include "dods-datatypes.h"
#include "Type.h"
#include "DapObj.h"
using namespace std;
class Crc32;
namespace libdap
{
class ConstraintEvaluator;
class DDS;
class Marshaller;
class UnMarshaller;
class Constructor;
class XMLWrter;
class DMR;
class D4Group;
class XMLWriter;
class D4StreamMarshaller;
class D4StreamUnMarshaller;
class D4Attributes;
class BaseType : public DapObj
{
private:
string d_name; // name of the instance
Type d_type; // instance's type
string d_dataset; // name of the dataset used to create this BaseType
bool d_is_read; // true if the value has been read
bool d_is_send; // Is the variable in the projection?
// d_parent points to the Constructor or Vector which holds a particular
// variable. It is null for simple variables. The Vector and Constructor
// classes must maintain this variable.
BaseType *d_parent;
// Attributes for this variable. Added 05/20/03 jhrg
AttrTable d_attr;
D4Attributes *d_attributes;
bool d_is_dap4; // True if this is a DAP4 variable, false ... DAP2
// These are non-empty only for DAP4 variables. Added 9/27/12 jhrg
protected:
// These were/are used for DAP2 CEs, but not for DAP4 ones
bool d_in_selection; // Is the variable in the selection?
bool d_is_synthesized; // true if the variable is synthesized
void m_duplicate(const BaseType &bt);
public:
typedef stack<BaseType *> btp_stack;
// These ctors assume is_dap4 is false
BaseType(const string &n, const Type &t, bool is_dap4 = false);
BaseType(const string &n, const string &d, const Type &t, bool is_dap4 = false);
BaseType(const BaseType &copy_from);
virtual ~BaseType();
virtual string toString();
virtual void transform_to_dap4(D4Group *root, Constructor *container);
virtual std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table);
virtual void dump(ostream &strm) const ;
BaseType &operator=(const BaseType &rhs);
virtual void clear_local_data() { set_read_p(false); }
virtual bool is_dap4() const { return d_is_dap4; }
virtual void set_is_dap4(const bool v) { d_is_dap4 = v;}
virtual BaseType *ptr_duplicate() = 0;
virtual string name() const;
virtual void set_name(const string &n);
virtual std::string FQN() const;
virtual Type type() const;
virtual void set_type(const Type &t);
virtual string type_name() const;
virtual string dataset() const ;
virtual int length() const { return 1; }
virtual void set_length(int) { }
virtual bool is_simple_type() const;
virtual bool is_vector_type() const;
virtual bool is_constructor_type() const;
virtual bool synthesized_p();
virtual void set_synthesized_p(bool state);
virtual int element_count(bool leaves = false);
virtual bool read_p();
virtual void set_read_p(bool state);
virtual bool send_p();
virtual void set_send_p(bool state);
virtual AttrTable &get_attr_table();
virtual void set_attr_table(const AttrTable &at);
// DAP4 attributes
virtual D4Attributes *attributes();
virtual void set_attributes(D4Attributes *);
virtual void set_attributes_nocopy(D4Attributes *);
virtual bool is_in_selection();
virtual void set_in_selection(bool state);
virtual void set_parent(BaseType *parent);
virtual BaseType *get_parent() const;
virtual void transfer_attributes(AttrTable *at);
// I put this comment here because the version in BaseType.cc does not
// include the exact_match or s variables since they are not used. Doxygen
// was gaging on the comment.
virtual BaseType *var(const string &name = "", bool exact_match = true, btp_stack *s = 0);
virtual BaseType *var(const string &name, btp_stack &s);
virtual void add_var(BaseType *bt, Part part = nil);
virtual void add_var_nocopy(BaseType *bt, Part part = nil);
virtual bool read();
virtual bool check_semantics(string &msg, bool all = false);
virtual bool ops(BaseType *b, int op);
virtual bool d4_ops(BaseType *b, int op);
virtual unsigned int width(bool constrained = false) const;
virtual void print_decl(FILE *out, string space = " ",
bool print_semi = true,
bool constraint_info = false,
bool constrained = false);
virtual void print_xml(FILE *out, string space = " ",
bool constrained = false);
virtual void print_decl(ostream &out, string space = " ",
bool print_semi = true,
bool constraint_info = false,
bool constrained = false);
virtual void print_xml(ostream &out, string space = " ",
bool constrained = false);
virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
virtual void print_dap4(XMLWriter &xml, bool constrained = false);
#if 0
virtual unsigned int width(bool constrained = false) = 0;
#endif
virtual unsigned int buf2val(void **val) = 0;
virtual unsigned int val2buf(void *val, bool reuse = false) = 0;
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds);
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true);
#if 0
virtual bool serialize_no_release(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true) {
return serialize(eval, dds, m, ce_eval);
}
#endif
virtual void compute_checksum(Crc32 &checksum) = 0;
virtual void intern_data(/*Crc32 &checksum, DMR &dmr, ConstraintEvaluator &eval*/);
virtual void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter = false);
#if 0
virtual void serialize_no_release(D4StreamMarshaller &m, DMR &dmr, bool filter = false) {
serialize(m, dmr, filter);
}
#endif
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
virtual void print_val(FILE *out, string space = "",
bool print_decl_p = true);
virtual void print_val(ostream &out, string space = "",
bool print_decl_p = true) = 0;
};
} // namespace libdap
#endif // _basetype_h
libdap::BaseType::length
virtual int length() const
How many elements are in this variable.
Definition: BaseType.h:207
libdap::UnMarshaller
abstract base class used to unmarshall/deserialize dap data objects
Definition: UnMarshaller.h:54
libdap::Part
Part
Names the parts of multi-section constructor data types.
Definition: Type.h:48
libdap::is_constructor_type
bool is_constructor_type(Type t)
Returns true if the instance is a constructor (i.e., Structure, Sequence or Grid) type variable...
Definition: util.cc:863
libdap::AttrTable
Contains the attributes for a dataset.
Definition: AttrTable.h:142
libdap::D4Attributes
Definition: D4Attributes.h:94
libdap::D4StreamUnMarshaller
Read data from the stream made by D4StreamMarshaller.
Definition: D4StreamUnMarshaller.h:65
Crc32
Definition: crc.h:76
std
STL namespace.
libdap::is_vector_type
bool is_vector_type(Type t)
Returns true if the instance is a vector (i.e., array) type variable.
Definition: util.cc:817
libdap::Type
Type
Identifies the data type.
Definition: Type.h:94
libdap
Definition: AlarmHandler.h:35
libdap::BaseType::clear_local_data
virtual void clear_local_data()
Definition: BaseType.h:179
libdap::DMR
Definition: DMR.h:55
libdap::D4StreamMarshaller
Marshaller that knows how to marshal/serialize dap data objects to a C++ iostream using DAP4&#39;s receiv...
Definition: D4StreamMarshaller.h:71
libdap::DDS
Definition: DDS.h:180
libdap::is_simple_type
bool is_simple_type(Type t)
Returns true if the instance is a numeric, string or URL type variable.
Definition: util.cc:775
libdap::BaseType::set_length
virtual void set_length(int)
Set the number of elements for this variable.
Definition: BaseType.h:214
libdap::Constructor
Definition: Constructor.h:43
libdap::ConstraintEvaluator
Evaluate a constraint expression.
Definition: ConstraintEvaluator.h:42
libdap::BaseType
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
libdap::DapObj
libdap base object for common functionality of libdap objects
Definition: DapObj.h:55
libdap::Marshaller
abstract base class used to marshal/serialize dap data objects
Definition: Marshaller.h:50
libdap::D4Group
Definition: D4Group.h:43
libdap::XMLWriter
Definition: XMLWriter.h:39
libdap::type_name
string type_name(Type t)
Definition: util.cc:760