|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// -*- mode: c++; c-basic-offset:4 -*-
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// This file is part of libdap, A C++ implementation of the OPeNDAP Data
|
|
Packit |
a4aae4 |
// Access Protocol.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// Copyright (c) 2002,2003 OPeNDAP, Inc.
|
|
Packit |
a4aae4 |
// Author: James Gallagher <jgallagher@opendap.org>
|
|
Packit |
a4aae4 |
// Dan Holloway <dan@hollywood.gso.uri.edu>
|
|
Packit |
a4aae4 |
// Reza Nekovei <reza@intcomm.net>
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// This library is free software; you can redistribute it and/or
|
|
Packit |
a4aae4 |
// modify it under the terms of the GNU Lesser General Public
|
|
Packit |
a4aae4 |
// License as published by the Free Software Foundation; either
|
|
Packit |
a4aae4 |
// version 2.1 of the License, or (at your option) any later version.
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// This library is distributed in the hope that it will be useful,
|
|
Packit |
a4aae4 |
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit |
a4aae4 |
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit |
a4aae4 |
// Lesser General Public License for more details.
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// You should have received a copy of the GNU Lesser General Public
|
|
Packit |
a4aae4 |
// License along with this library; if not, write to the Free Software
|
|
Packit |
a4aae4 |
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// (c) COPYRIGHT URI/MIT 1994-1999
|
|
Packit |
a4aae4 |
// Please read the full copyright statement in the file COPYRIGHT_URI.
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// Authors:
|
|
Packit |
a4aae4 |
// jhrg,jimg James Gallagher <jgallagher@gso.uri.edu>
|
|
Packit |
a4aae4 |
// dan Dan Holloway <dan@hollywood.gso.uri.edu>
|
|
Packit |
a4aae4 |
// reza Reza Nekovei <reza@intcomm.net>
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// Abstract base class for the variables in a dataset. This is used to store
|
|
Packit |
a4aae4 |
// the type-invariant information that describes a variable as given in the
|
|
Packit |
a4aae4 |
// DODS API.
|
|
Packit |
a4aae4 |
//
|
|
Packit |
a4aae4 |
// jhrg 9/6/94
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#ifndef _basetype_h
|
|
Packit |
a4aae4 |
#define _basetype_h 1
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include <vector>
|
|
Packit |
a4aae4 |
#include <stack>
|
|
Packit |
a4aae4 |
#include <iostream>
|
|
Packit |
a4aae4 |
#include <string>
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include "AttrTable.h"
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include "InternalErr.h"
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include "dods-datatypes.h"
|
|
Packit |
a4aae4 |
#include "Type.h"
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#include "DapObj.h"
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
using namespace std;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
class Crc32;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
namespace libdap
|
|
Packit |
a4aae4 |
{
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
class ConstraintEvaluator;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
class DDS;
|
|
Packit |
a4aae4 |
class Marshaller;
|
|
Packit |
a4aae4 |
class UnMarshaller;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
class Constructor;
|
|
Packit |
a4aae4 |
class XMLWrter;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
class DMR;
|
|
Packit |
a4aae4 |
class D4Group;
|
|
Packit |
a4aae4 |
class XMLWriter;
|
|
Packit |
a4aae4 |
class D4StreamMarshaller;
|
|
Packit |
a4aae4 |
class D4StreamUnMarshaller;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
class D4Attributes;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** This defines the basic data type features for the DODS data access
|
|
Packit |
a4aae4 |
protocol (DAP) data types. All the DAP type classes (Float64, Array,
|
|
Packit |
a4aae4 |
etc.) subclass it. This class is an abstract one; no variables will ever
|
|
Packit |
a4aae4 |
be stored as BaseType instances, only as instances of its child classes.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
These classes and their methods give a user the capacity to set up
|
|
Packit |
a4aae4 |
sophisticated data types. They do not provide sophisticated ways to
|
|
Packit |
a4aae4 |
access and use this data. On the server side, in many cases, the class
|
|
Packit |
a4aae4 |
instances will have no data in them at all until the
|
|
Packit |
a4aae4 |
<tt>serialize</tt> function
|
|
Packit |
a4aae4 |
is called to send data to the client. On the client side, most DAP
|
|
Packit |
a4aae4 |
application programs will unpack the data promptly into whatever local
|
|
Packit |
a4aae4 |
data structure the programmer deems the most useful.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
In order to use these classes on the server side of a DAP
|
|
Packit |
a4aae4 |
client/server connection, you must write a <tt>read</tt> method
|
|
Packit |
a4aae4 |
for each of the data types you expect to encounter in the
|
|
Packit |
a4aae4 |
application. This function, whose purpose is to read data from a
|
|
Packit |
a4aae4 |
local source into the class instance data buffer, is called in
|
|
Packit |
a4aae4 |
<tt>serialize</tt>, when the data is about to be sent to the
|
|
Packit |
a4aae4 |
client. The <tt>read</tt> function may be called earlier, in the
|
|
Packit |
a4aae4 |
case of data subset requests (constraint expressions) whose
|
|
Packit |
a4aae4 |
evaluation requires it. (For example, the constraint expression
|
|
Packit |
a4aae4 |
``<tt>a,b&b>c</tt>'' requires that <tt>c</tt> be read even though
|
|
Packit |
a4aae4 |
it will not be sent.)
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
For some data types, the <tt>read</tt> function must be aware of
|
|
Packit |
a4aae4 |
the constraints
|
|
Packit |
a4aae4 |
to be returned. These cautions are outlined where they occur.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@note This class is ued by both DAP2 and DAP4.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@brief The basic data type for the DODS DAP types. */
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
class BaseType : public DapObj
|
|
Packit |
a4aae4 |
{
|
|
Packit |
a4aae4 |
private:
|
|
Packit |
a4aae4 |
string d_name; // name of the instance
|
|
Packit |
a4aae4 |
Type d_type; // instance's type
|
|
Packit |
a4aae4 |
string d_dataset; // name of the dataset used to create this BaseType
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
bool d_is_read; // true if the value has been read
|
|
Packit |
a4aae4 |
bool d_is_send; // Is the variable in the projection?
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// d_parent points to the Constructor or Vector which holds a particular
|
|
Packit |
a4aae4 |
// variable. It is null for simple variables. The Vector and Constructor
|
|
Packit |
a4aae4 |
// classes must maintain this variable.
|
|
Packit |
a4aae4 |
BaseType *d_parent;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// Attributes for this variable. Added 05/20/03 jhrg
|
|
Packit |
a4aae4 |
AttrTable d_attr;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
D4Attributes *d_attributes;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
bool d_is_dap4; // True if this is a DAP4 variable, false ... DAP2
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// These are non-empty only for DAP4 variables. Added 9/27/12 jhrg
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
protected:
|
|
Packit |
a4aae4 |
// These were/are used for DAP2 CEs, but not for DAP4 ones
|
|
Packit |
a4aae4 |
bool d_in_selection; // Is the variable in the selection?
|
|
Packit |
a4aae4 |
bool d_is_synthesized; // true if the variable is synthesized
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
void m_duplicate(const BaseType &bt;;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
public:
|
|
Packit |
a4aae4 |
typedef stack<BaseType *> btp_stack;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// These ctors assume is_dap4 is false
|
|
Packit |
a4aae4 |
BaseType(const string &n, const Type &t, bool is_dap4 = false);
|
|
Packit |
a4aae4 |
BaseType(const string &n, const string &d, const Type &t, bool is_dap4 = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
BaseType(const BaseType ©_from);
|
|
Packit |
a4aae4 |
virtual ~BaseType();
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual string toString();
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void transform_to_dap4(D4Group *root, Constructor *container);
|
|
Packit |
a4aae4 |
virtual std::vector<BaseType *> *transform_to_dap2(AttrTable *parent_attr_table);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void dump(ostream &strm) const ;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
BaseType &operator=(const BaseType &rhs;;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* Remove any read or set data in the private data of the variable,
|
|
Packit |
a4aae4 |
* setting read_p() to false. Used to clear any dynamically allocated
|
|
Packit |
a4aae4 |
* storage that holds (potentially large) data. For the simple types,
|
|
Packit |
a4aae4 |
* this no-op version is all that's needed. Vector and some other classes
|
|
Packit |
a4aae4 |
* define a special version and have serialize() implementations that
|
|
Packit |
a4aae4 |
* call it to free data as soon as possible after sending it.
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* @note Added 7/5/15 jhrg
|
|
Packit |
a4aae4 |
* @note Any specialization of this should make sure to reset the read_p
|
|
Packit |
a4aae4 |
* property.
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
virtual void clear_local_data() { set_read_p(false); }
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual bool is_dap4() const { return d_is_dap4; }
|
|
Packit |
a4aae4 |
virtual void set_is_dap4(const bool v) { d_is_dap4 = v;}
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** Clone this instance. Allocate a new instance and copy \c *this into
|
|
Packit |
a4aae4 |
it. This method must perform a deep copy.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@note This method should \e not copy data values, but must copy all
|
|
Packit |
a4aae4 |
other fields in the object.
|
|
Packit |
a4aae4 |
@return A newly allocated copy of \c this. */
|
|
Packit |
a4aae4 |
virtual BaseType *ptr_duplicate() = 0;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual string name() const;
|
|
Packit |
a4aae4 |
virtual void set_name(const string &n);
|
|
Packit |
a4aae4 |
virtual std::string FQN() const;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual Type type() const;
|
|
Packit |
a4aae4 |
virtual void set_type(const Type &t);
|
|
Packit |
a4aae4 |
virtual string type_name() const;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual string dataset() const ;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief How many elements are in this variable.
|
|
Packit |
a4aae4 |
* @todo change the return type to int64_t
|
|
Packit |
a4aae4 |
* @return The number of elements; 1 for scalars
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
virtual int length() const { return 1; }
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief Set the number of elements for this variable
|
|
Packit |
a4aae4 |
* @todo change param type to int64_t
|
|
Packit |
a4aae4 |
* @param l The number of elements
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
virtual void set_length(int) { }
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual bool is_simple_type() const;
|
|
Packit |
a4aae4 |
virtual bool is_vector_type() const;
|
|
Packit |
a4aae4 |
virtual bool is_constructor_type() const;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual bool synthesized_p();
|
|
Packit |
a4aae4 |
virtual void set_synthesized_p(bool state);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual int element_count(bool leaves = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual bool read_p();
|
|
Packit |
a4aae4 |
virtual void set_read_p(bool state);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual bool send_p();
|
|
Packit |
a4aae4 |
virtual void set_send_p(bool state);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual AttrTable &get_attr_table();
|
|
Packit |
a4aae4 |
virtual void set_attr_table(const AttrTable &at);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// DAP4 attributes
|
|
Packit |
a4aae4 |
virtual D4Attributes *attributes();
|
|
Packit |
a4aae4 |
virtual void set_attributes(D4Attributes *);
|
|
Packit |
a4aae4 |
virtual void set_attributes_nocopy(D4Attributes *);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual bool is_in_selection();
|
|
Packit |
a4aae4 |
virtual void set_in_selection(bool state);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void set_parent(BaseType *parent);
|
|
Packit |
a4aae4 |
virtual BaseType *get_parent() const;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void transfer_attributes(AttrTable *at);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
// I put this comment here because the version in BaseType.cc does not
|
|
Packit |
a4aae4 |
// include the exact_match or s variables since they are not used. Doxygen
|
|
Packit |
a4aae4 |
// was gaging on the comment.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** Returns a pointer to the contained variable in a composite class. The
|
|
Packit |
a4aae4 |
composite classes are those made up of aggregated simple data types.
|
|
Packit |
a4aae4 |
Array, Grid, and Structure are composite types, while Int and Float are
|
|
Packit |
a4aae4 |
simple types. This function is only used by composite classes. The
|
|
Packit |
a4aae4 |
BaseType implementation always returns null.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
Several of the subclasses provide alternate access methods
|
|
Packit |
a4aae4 |
that make sense for that particular data type. For example,
|
|
Packit |
a4aae4 |
the Array class defines a <tt>*var(int i)</tt> method that
|
|
Packit |
a4aae4 |
returns the ith entry in the Array data, and the Structure
|
|
Packit |
a4aae4 |
provides a <tt>*var(Vars_iter)</tt> function using a
|
|
Packit |
a4aae4 |
pseudo-index to access the different members of the structure.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@brief Returns a pointer to a member of a constructor class.
|
|
Packit |
a4aae4 |
@param name The name of the class member. Defaults to ""
|
|
Packit |
a4aae4 |
@param exact_match True if only interested in variables whose
|
|
Packit |
a4aae4 |
full names match \e n exactly. If false, returns the first
|
|
Packit |
a4aae4 |
variable whose name matches \e name. For example, if \e name
|
|
Packit |
a4aae4 |
is \c x and \c point.x is a variable, then var("x", false)
|
|
Packit |
a4aae4 |
would return a BaseType pointer to \c point.x. If \e
|
|
Packit |
a4aae4 |
exact_match was <tt>true</tt> then \e name would need to be \c
|
|
Packit |
a4aae4 |
"point.x" for var to return that pointer. This feature
|
|
Packit |
a4aae4 |
simplifies constraint expressions for datasets which have
|
|
Packit |
a4aae4 |
complex, nested, constructor variables. Defaults to true.
|
|
Packit |
a4aae4 |
@param s Record the path to \e name. Defaults to null, in
|
|
Packit |
a4aae4 |
which case it is not used.
|
|
Packit |
a4aae4 |
@return A pointer to the member named in the \e n argument. If
|
|
Packit |
a4aae4 |
no name is given, the function returns the first (only)
|
|
Packit |
a4aae4 |
variable. For example, an Array has only one variable, while a
|
|
Packit |
a4aae4 |
Structure can have many. */
|
|
Packit |
a4aae4 |
virtual BaseType *var(const string &name = "", bool exact_match = true, btp_stack *s = 0);
|
|
Packit |
a4aae4 |
virtual BaseType *var(const string &name, btp_stack &s);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void add_var(BaseType *bt, Part part = nil);
|
|
Packit |
a4aae4 |
virtual void add_var_nocopy(BaseType *bt, Part part = nil);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual bool read();
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual bool check_semantics(string &msg, bool all = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual bool ops(BaseType *b, int op);
|
|
Packit |
a4aae4 |
virtual bool d4_ops(BaseType *b, int op);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual unsigned int width(bool constrained = false) const;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void print_decl(FILE *out, string space = " ",
|
|
Packit |
a4aae4 |
bool print_semi = true,
|
|
Packit |
a4aae4 |
bool constraint_info = false,
|
|
Packit |
a4aae4 |
bool constrained = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void print_xml(FILE *out, string space = " ",
|
|
Packit |
a4aae4 |
bool constrained = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void print_decl(ostream &out, string space = " ",
|
|
Packit |
a4aae4 |
bool print_semi = true,
|
|
Packit |
a4aae4 |
bool constraint_info = false,
|
|
Packit |
a4aae4 |
bool constrained = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void print_xml(ostream &out, string space = " ",
|
|
Packit |
a4aae4 |
bool constrained = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void print_xml_writer(XMLWriter &xml, bool constrained = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void print_dap4(XMLWriter &xml, bool constrained = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** @name Abstract Methods */
|
|
Packit |
a4aae4 |
//@{
|
|
Packit |
a4aae4 |
#if 0
|
|
Packit |
a4aae4 |
/** Return the number of bytes that are required to hold the
|
|
Packit |
a4aae4 |
instance's value. In the case of simple types such as Int32,
|
|
Packit |
a4aae4 |
this is the size of one Int32 (four bytes). For a String or
|
|
Packit |
a4aae4 |
Url type, <tt>width(bool constrained = false)</tt> returns the number of bytes needed
|
|
Packit |
a4aae4 |
for a <tt>String *</tt> variable, not the bytes needed for all
|
|
Packit |
a4aae4 |
the characters, since that value cannot be determined from
|
|
Packit |
a4aae4 |
type information alone. For Structure, and other constructor
|
|
Packit |
a4aae4 |
types size() returns the number of bytes needed to store
|
|
Packit |
a4aae4 |
pointers to the C++ objects.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@brief Returns the size of the class instance data. */
|
|
Packit |
a4aae4 |
virtual unsigned int width(bool constrained = false) = 0;
|
|
Packit |
a4aae4 |
#endif
|
|
Packit |
a4aae4 |
/** Reads the class data into the memory referenced by val.
|
|
Packit |
a4aae4 |
The caller should either allocate enough storage to val
|
|
Packit |
a4aae4 |
to hold the class data or set \c *val to null. If *val
|
|
Packit |
a4aae4 |
is NULL, memory will be allocated by this function with
|
|
Packit |
a4aae4 |
<tt>new()</tt>. If the memory is allocated this way, the
|
|
Packit |
a4aae4 |
caller is responsible for deallocating that memory. Array and
|
|
Packit |
a4aae4 |
values for simple types are stored as C would store an array.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@deprecated Use value() in the leaf classes.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@brief Reads the class data.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@param val A pointer to a pointer to the memory into which the
|
|
Packit |
a4aae4 |
class data will be copied. If the value pointed to is NULL,
|
|
Packit |
a4aae4 |
memory will be allocated to hold the data, and the pointer
|
|
Packit |
a4aae4 |
value modified accordingly. The calling program is responsible
|
|
Packit |
a4aae4 |
for deallocating the memory references by this pointer.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@return The size (in bytes) of the information copied to val.
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
virtual unsigned int buf2val(void **val) = 0;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** Store the value pointed to by val in the object's
|
|
Packit |
a4aae4 |
internal buffer. This function does not perform any checks, so
|
|
Packit |
a4aae4 |
users must be sure that the thing pointed to can actually be
|
|
Packit |
a4aae4 |
stored in the object's buffer.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
Only simple objects (Int, Float, Byte, and so on) and arrays
|
|
Packit |
a4aae4 |
of these simple objects may be stored using this function. To
|
|
Packit |
a4aae4 |
put data into more complex constructor types, use the
|
|
Packit |
a4aae4 |
functions provided by that class.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@deprecated Use set_value() in the leaf classes.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@brief Loads class data.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@param val A pointer to the data to be inserted into the class
|
|
Packit |
a4aae4 |
data buffer.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@param reuse A boolean value, indicating whether the class
|
|
Packit |
a4aae4 |
internal data storage can be reused or not. If this argument
|
|
Packit |
a4aae4 |
is TRUE, the class buffer is assumed to be large enough to
|
|
Packit |
a4aae4 |
hold the incoming data, and it is not reallocated. If
|
|
Packit |
a4aae4 |
FALSE, new storage is allocated. If the internal buffer has
|
|
Packit |
a4aae4 |
not been allocated at all, this argument has no effect. This
|
|
Packit |
a4aae4 |
is currently used only in the Vector class.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@return The size (in bytes) of the information copied from
|
|
Packit |
a4aae4 |
val.
|
|
Packit |
a4aae4 |
@see Grid
|
|
Packit |
a4aae4 |
@see Vector::val2buf */
|
|
Packit |
a4aae4 |
virtual unsigned int val2buf(void *val, bool reuse = false) = 0;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** Similar to using serialize() and deserialize() together in one object.
|
|
Packit |
a4aae4 |
Data are read as for serialize and those values are stored in the
|
|
Packit |
a4aae4 |
objects as deserialize() does but does not write and then read data
|
|
Packit |
a4aae4 |
to/from a stream.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
This method is defined by the various data type classes. It calls the
|
|
Packit |
a4aae4 |
read() abstract method. Unlike serialize(), this method does not
|
|
Packit |
a4aae4 |
clear the memory use to hold the data values, so the caller should
|
|
Packit |
a4aae4 |
make sure to delete the DDS or the variable as soon as possible.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@param eval Use this as the constraint expression evaluator.
|
|
Packit |
a4aae4 |
@param dds The Data Descriptor Structure object corresponding
|
|
Packit |
a4aae4 |
to this dataset. See The DODS User Manual for
|
|
Packit |
a4aae4 |
information about this structure. */
|
|
Packit |
a4aae4 |
virtual void intern_data(ConstraintEvaluator &eval, DDS &dds;;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** Sends the data from the indicated (local) dataset through the
|
|
Packit |
a4aae4 |
connection identified by the Marshaller parameter. If the
|
|
Packit |
a4aae4 |
data is not already incorporated into the DDS object, read the
|
|
Packit |
a4aae4 |
data from the dataset. Once the data are sent (written to the
|
|
Packit |
a4aae4 |
Marshaller), they are deleted from the object and the object
|
|
Packit |
a4aae4 |
state is reset so that they will be read again if the read()
|
|
Packit |
a4aae4 |
method is called.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
This function is only used on the server side of the
|
|
Packit |
a4aae4 |
client/server connection, and is generally only called from
|
|
Packit |
a4aae4 |
the ResponseBuilder functions. It has no BaseType
|
|
Packit |
a4aae4 |
implementation; each datatype child class supplies its own
|
|
Packit |
a4aae4 |
implementation.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@brief Move data to the net, then remove them from the object.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@param eval Use this as the constraint expression evaluator.
|
|
Packit |
a4aae4 |
@param dds The Data Descriptor Structure object corresponding
|
|
Packit |
a4aae4 |
to this dataset. See The DODS User Manual for
|
|
Packit |
a4aae4 |
information about this structure.
|
|
Packit |
a4aae4 |
@param m A marshaller used to serialize data types
|
|
Packit |
a4aae4 |
@param ce_eval A boolean value indicating whether to evaluate
|
|
Packit |
a4aae4 |
the DODS constraint expression that may accompany this
|
|
Packit |
a4aae4 |
dataset. The constraint expression is stored in the dds.
|
|
Packit |
a4aae4 |
@return This method always returns true. Older versions used
|
|
Packit |
a4aae4 |
the return value to signal success or failure.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@note We changed the default behavior of this method so that it
|
|
Packit |
a4aae4 |
calls BaseType::clear_local_data() once the values are sent. This,
|
|
Packit |
a4aae4 |
combined with the behavior that read() is called by this method
|
|
Packit |
a4aae4 |
just before data are sent, means that data for any given variable
|
|
Packit |
a4aae4 |
remain in memory for the shortest time possible. Furthermore, since
|
|
Packit |
a4aae4 |
variables are serialized one at a time, no more than one variable's
|
|
Packit |
a4aae4 |
data will be in memory at any given time when using the default
|
|
Packit |
a4aae4 |
behavior. Some code - code that uses intern_data() or server functions -
|
|
Packit |
a4aae4 |
might alter this default behavior. Only Array (i.e. Vector), Sequence,
|
|
Packit |
a4aae4 |
D4Sequence and D4Opaque types actually hold data in dynamically allocated
|
|
Packit |
a4aae4 |
memory, so sonly those types have the new/changed behavior.
|
|
Packit |
a4aae4 |
This change was made on 7/5/15.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@exception InternalErr.
|
|
Packit |
a4aae4 |
@exception Error.
|
|
Packit |
a4aae4 |
@see DDS */
|
|
Packit |
a4aae4 |
virtual bool serialize(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#if 0
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* Provide a way to get the old behavior of serialize() - calling this
|
|
Packit |
a4aae4 |
* method will serialize the BaseType object's data but _not_ delete its
|
|
Packit |
a4aae4 |
* data storage.
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* @note This method's behavior differs only for Array (i.e. Vector), Sequence,
|
|
Packit |
a4aae4 |
* D4Sequence and D4Opaque types; the other types do not use dynamic memory to
|
|
Packit |
a4aae4 |
* hold data values.
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* @param eval Use this as the constraint expression evaluator.
|
|
Packit |
a4aae4 |
* @param dds The Data Descriptor Structure object corresponding
|
|
Packit |
a4aae4 |
* to this dataset. See The DODS User Manual for
|
|
Packit |
a4aae4 |
* information about this structure.
|
|
Packit |
a4aae4 |
* @param m A marshaller used to serialize data types
|
|
Packit |
a4aae4 |
* @param ce_eval A boolean value indicating whether to evaluate
|
|
Packit |
a4aae4 |
* the DODS constraint expression that may accompany this
|
|
Packit |
a4aae4 |
* @return This method always returns true. Older versions used
|
|
Packit |
a4aae4 |
* the return value to signal success or failure.
|
|
Packit |
a4aae4 |
* @param
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
virtual bool serialize_no_release(ConstraintEvaluator &eval, DDS &dds, Marshaller &m, bool ce_eval = true) {
|
|
Packit |
a4aae4 |
return serialize(eval, dds, m, ce_eval);
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
#endif
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief include the data for this variable in the checksum
|
|
Packit |
a4aae4 |
* DAP4 includes a checksum with every data response. This method adds the
|
|
Packit |
a4aae4 |
* variable's data to that checksum.
|
|
Packit |
a4aae4 |
* @param checksum A Crc32 instance that holds the current checksum.
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
virtual void compute_checksum(Crc32 &checksum) = 0;
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void intern_data(/*Crc32 &checksum, DMR &dmr, ConstraintEvaluator &eval*/);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief The DAP4 serialization method.
|
|
Packit |
a4aae4 |
* Serialize a variable's values for DAP4. This does not write the DMR
|
|
Packit |
a4aae4 |
* persistent representation but does write that part of the binary
|
|
Packit |
a4aae4 |
* data blob that holds a variable's data. Once a variable's data are
|
|
Packit |
a4aae4 |
* serialized, that memory is reclaimed (by calling BaseType::clear_local_data())
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* @param m
|
|
Packit |
a4aae4 |
* @param dmr
|
|
Packit |
a4aae4 |
* @param eval
|
|
Packit |
a4aae4 |
* @param filter True if there is one variable that should be 'filtered'
|
|
Packit |
a4aae4 |
* @exception Error or InternalErr
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
virtual void serialize(D4StreamMarshaller &m, DMR &dmr, bool filter = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#if 0
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* @brief Variation on the DAP4 serialization method - retain data after serialization
|
|
Packit |
a4aae4 |
* Serialize a variable's values for DAP4. This does not write the DMR
|
|
Packit |
a4aae4 |
* persistent representation but does write that part of the binary
|
|
Packit |
a4aae4 |
* data blob that holds a variable's data. Once a variable's data are
|
|
Packit |
a4aae4 |
* serialized, that memory is reclaimed (by calling BaseType::clear_local_data())
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* @note This version does not delete the storage of Array, D4Sequence or
|
|
Packit |
a4aae4 |
* D4Opaque variables, as it the case with serialize(). For other types,
|
|
Packit |
a4aae4 |
* this method and serialize have the same beavior (since those types do
|
|
Packit |
a4aae4 |
* not us dynamic memory to hold data values).
|
|
Packit |
a4aae4 |
*
|
|
Packit |
a4aae4 |
* @param m
|
|
Packit |
a4aae4 |
* @param dmr
|
|
Packit |
a4aae4 |
* @param eval
|
|
Packit |
a4aae4 |
* @param filter True if there is one variable that should be 'filtered'
|
|
Packit |
a4aae4 |
* @exception Error or InternalErr
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
virtual void serialize_no_release(D4StreamMarshaller &m, DMR &dmr, bool filter = false) {
|
|
Packit |
a4aae4 |
serialize(m, dmr, filter);
|
|
Packit |
a4aae4 |
}
|
|
Packit |
a4aae4 |
#endif
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** Receives data from the network connection identified by the
|
|
Packit |
a4aae4 |
<tt>source</tt> parameter. The data is put into the class data
|
|
Packit |
a4aae4 |
buffer according to the input <tt>dds</tt>.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
This function is only used on the client side of the DODS
|
|
Packit |
a4aae4 |
client/server connection.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@brief Receive data from the net.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@param um An UnMarshaller that knows how to deserialize data types
|
|
Packit |
a4aae4 |
@param dds The Data Descriptor Structure object corresponding
|
|
Packit |
a4aae4 |
to this dataset. See The DODS User Manual for
|
|
Packit |
a4aae4 |
information about this structure. This would have been
|
|
Packit |
a4aae4 |
received from the server in an earlier transmission.
|
|
Packit |
a4aae4 |
@param reuse A boolean value, indicating whether the class
|
|
Packit |
a4aae4 |
internal data storage can be reused or not. If this argument
|
|
Packit |
a4aae4 |
is TRUE, the class buffer is assumed to be large enough to
|
|
Packit |
a4aae4 |
hold the incoming data, and it is not reallocated. If
|
|
Packit |
a4aae4 |
FALSE, new storage is allocated. If the internal buffer has
|
|
Packit |
a4aae4 |
not been allocated at all, this argument has no effect.
|
|
Packit |
a4aae4 |
@return Always returns TRUE.
|
|
Packit |
a4aae4 |
@exception Error when a problem reading from the UnMarshaller is
|
|
Packit |
a4aae4 |
found.
|
|
Packit |
a4aae4 |
@see DDS */
|
|
Packit |
a4aae4 |
virtual bool deserialize(UnMarshaller &um, DDS *dds, bool reuse = false);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/**
|
|
Packit |
a4aae4 |
* The DAP4 deserialization method.
|
|
Packit |
a4aae4 |
* @param um
|
|
Packit |
a4aae4 |
* @param dmr
|
|
Packit |
a4aae4 |
* @exception Error or InternalErr
|
|
Packit |
a4aae4 |
*/
|
|
Packit |
a4aae4 |
virtual void deserialize(D4StreamUnMarshaller &um, DMR &dmr);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** Prints the value of the variable, with its declaration. This
|
|
Packit |
a4aae4 |
function is primarily intended for debugging DODS
|
|
Packit |
a4aae4 |
applications. However, it can be overloaded and used to do
|
|
Packit |
a4aae4 |
some useful things. Take a look at the asciival and writeval
|
|
Packit |
a4aae4 |
clients, both of which overload this to output the values of
|
|
Packit |
a4aae4 |
variables in different ways.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@brief Prints the value of the variable.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@param out The output stream on which to print the value.
|
|
Packit |
a4aae4 |
@param space This value is passed to the print_decl()
|
|
Packit |
a4aae4 |
function, and controls the leading spaces of the output.
|
|
Packit |
a4aae4 |
@param print_decl_p A boolean value controlling whether the
|
|
Packit |
a4aae4 |
variable declaration is printed as well as the value. */
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
virtual void print_val(FILE *out, string space = "",
|
|
Packit |
a4aae4 |
bool print_decl_p = true);
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
/** Prints the value of the variable, with its declaration. This
|
|
Packit |
a4aae4 |
function is primarily intended for debugging DODS
|
|
Packit |
a4aae4 |
applications. However, it can be overloaded and used to do
|
|
Packit |
a4aae4 |
some useful things. Take a look at the asciival and writeval
|
|
Packit |
a4aae4 |
clients, both of which overload this to output the values of
|
|
Packit |
a4aae4 |
variables in different ways.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@brief Prints the value of the variable.
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
@param out The output ostream on which to print the value.
|
|
Packit |
a4aae4 |
@param space This value is passed to the print_decl()
|
|
Packit |
a4aae4 |
function, and controls the leading spaces of the output.
|
|
Packit |
a4aae4 |
@param print_decl_p A boolean value controlling whether the
|
|
Packit |
a4aae4 |
variable declaration is printed as well as the value. */
|
|
Packit |
a4aae4 |
virtual void print_val(ostream &out, string space = "",
|
|
Packit |
a4aae4 |
bool print_decl_p = true) = 0;
|
|
Packit |
a4aae4 |
//@}
|
|
Packit |
a4aae4 |
};
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
} // namespace libdap
|
|
Packit |
a4aae4 |
|
|
Packit |
a4aae4 |
#endif // _basetype_h
|