bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
ncml_module::NCMLArray< T > Class Template Reference

A parameterized subclass of libdap::Array that allows us to apply constraints on NcML-specified data prior to serialization. All the code is in the .h, so no .cc is defined. More...

#include <NCMLArray.h>

Inheritance diagram for ncml_module::NCMLArray< T >:
Inheritance graph
Collaboration diagram for ncml_module::NCMLArray< T >:
Collaboration graph

Public Member Functions

virtual void cacheCurrentConstraints ()
 
virtual void cacheSuperclassStateIfNeeded ()
 
virtual void cacheUnconstrainedDimensions ()
 
virtual void copyDataFrom (libdap::Array &from)
 
virtual Shape getSuperShape () const
 
virtual bool haveConstraintsChangedSinceLastRead () const
 
virtual bool isConstrained () const
 
virtual bool isDataCached () const
 
 NCMLArray (const NCMLArray< T > &proto)
 
 NCMLArray (const string &name)
 
NCMLArray< T > & operator= (const NCMLArray< T > &rhs)
 
virtual NCMLArray< T > * ptr_duplicate ()
 
virtual bool read ()
 
virtual bool read_p ()
 
virtual void set_read_p (bool state)
 
virtual bool set_value (dods_byte *val, int sz)
 
virtual bool set_value (dods_float32 *val, int sz)
 
virtual bool set_value (dods_float64 *val, int sz)
 
virtual bool set_value (dods_int16 *val, int sz)
 
virtual bool set_value (dods_int32 *val, int sz)
 
virtual bool set_value (dods_uint16 *val, int sz)
 
virtual bool set_value (dods_uint32 *val, int sz)
 
virtual bool set_value (string *val, int sz)
 
virtual bool set_value (vector< dods_byte > &val, int sz)
 
virtual bool set_value (vector< dods_float32 > &val, int sz)
 
virtual bool set_value (vector< dods_float64 > &val, int sz)
 
virtual bool set_value (vector< dods_int16 > &val, int sz)
 
virtual bool set_value (vector< dods_int32 > &val, int sz)
 
virtual bool set_value (vector< dods_uint16 > &val, int sz)
 
virtual bool set_value (vector< dods_uint32 > &val, int sz)
 
virtual bool set_value (vector< string > &val, int sz)
 
virtual ~NCMLArray ()
 

Protected Member Functions

virtual void cacheValuesIfNeeded ()
 
virtual void createAndSetConstrainedValueBuffer ()
 

Protected Attributes

Shape_currentConstraints
 
Shape_noConstraints
 

Detailed Description

template<typename T>
class ncml_module::NCMLArray< T >

A parameterized subclass of libdap::Array that allows us to apply constraints on NcML-specified data prior to serialization. All the code is in the .h, so no .cc is defined.

This class caches the full set of data values of basic type T for the unconstrained super Array shape. It forces read_p() to ALWAYS be false to force a call of this->read() prior to any serialization of super Vector's data buffer.

In a read() call, if constraints have been applied to the Array superclass, this class will effect the Vector superclass data buffer (Vector._buf) in order to calculate and store the constrained data into Vector._buf so serialize() passes the constrained data properly. It maintains a copy of the full set of data, however, in case constraints are later removed or changed. It maintains a copy of the constrained shape used to generate the current Vector._buf so that on subsequent read() calls it can check to see if the constraints have changed and if so recompute Vector._buf.

We use a template on the underlying data type stored, such as dods_byte, dods_int32, etc. Note that this can ALSO be std::string, in which case Vector does special processing. We need to be aware of this in processing data.

NOTE: I examined the way this class is used and I think that, in fact, it is only currently used for new variable arrays (in which the data is provided in the source ncml file) and NEVER for existing arrays (which would mean massive copying of data). Now I may well be wrong about this assessment, but at the moment that what it looks like to me. ndp - 8/7/15

Definition at line 86 of file NCMLArray.h.

Constructor & Destructor Documentation

◆ NCMLArray() [1/3]

template<typename T>
ncml_module::NCMLArray< T >::NCMLArray ( )
inline

Definition at line 92 of file NCMLArray.h.

◆ NCMLArray() [2/3]

template<typename T>
ncml_module::NCMLArray< T >::NCMLArray ( const string & name)
inlineexplicit

Definition at line 97 of file NCMLArray.h.

◆ NCMLArray() [3/3]

template<typename T>
ncml_module::NCMLArray< T >::NCMLArray ( const NCMLArray< T > & proto)
inlineexplicit

Definition at line 102 of file NCMLArray.h.

◆ ~NCMLArray()

template<typename T>
virtual ncml_module::NCMLArray< T >::~NCMLArray ( )
inlinevirtual

Destroy any locally cached data

Definition at line 109 of file NCMLArray.h.

Member Function Documentation

◆ cacheCurrentConstraints()

void ncml_module::NCMLBaseArray::cacheCurrentConstraints ( )
virtualinherited

Store the current super Array shape as the current constraints so we remember

Definition at line 176 of file NCMLBaseArray.cc.

◆ cacheSuperclassStateIfNeeded()

void ncml_module::NCMLBaseArray::cacheSuperclassStateIfNeeded ( )
virtualinherited

Required by subclasses to copy the original data values locally

Definition at line 201 of file NCMLBaseArray.cc.

◆ cacheUnconstrainedDimensions()

void ncml_module::NCMLBaseArray::cacheUnconstrainedDimensions ( )
virtualinherited

Definition at line 187 of file NCMLBaseArray.cc.

◆ cacheValuesIfNeeded()

template<typename T>
virtual void ncml_module::NCMLArray< T >::cacheValuesIfNeeded ( )
inlineprotectedvirtual

The first time we get a read(), we want to grab the current state of the superclass Array and Vector and cache them locally before we apply any needed constraints. ASSUME: that the current value of the _buf in Vector super is the FULL set of values for the UNCONSTRAINED Array. We also grab the dimensions from the super Array, but realize that these may be already constrained. For this reason, we cache the UNCONSTRAINED shape (i.e. the d.size() for all dimensions) as well as the full set of current dimensions, constrained or not. The latter tells of if constraints have been applied and if we need to compute a new _buf in read().

Implements ncml_module::NCMLBaseArray.

Definition at line 298 of file NCMLArray.h.

◆ copyDataFrom()

template<typename T>
virtual void ncml_module::NCMLArray< T >::copyDataFrom ( libdap::Array & from)
inlinevirtual

Copy the rep from the given Array. This includes:

  • Shape
  • Attribute table
  • Template BaseType var
  • Data values

Implements ncml_module::NCMLBaseArray.

Definition at line 143 of file NCMLArray.h.

◆ createAndSetConstrainedValueBuffer()

template<typename T>
virtual void ncml_module::NCMLArray< T >::createAndSetConstrainedValueBuffer ( )
inlineprotectedvirtual

If we have constraints that are not the same as the constraints on the last read() call (or if this is first read() call), use the super Array's current constrained dimension values to set Vector->val2buf() with the proper constrained data. ASSUMES: cacheSuperclassStateIfNeeded() has already been called once so that this instance's state contains all the unconstrained data values and shape.

Implements ncml_module::NCMLBaseArray.

Definition at line 345 of file NCMLArray.h.

◆ getSuperShape()

Shape ncml_module::NCMLBaseArray::getSuperShape ( ) const
virtualinherited

Get the current dimensions of our superclass Array as a Shape object.

Definition at line 152 of file NCMLBaseArray.cc.

◆ haveConstraintsChangedSinceLastRead()

bool ncml_module::NCMLBaseArray::haveConstraintsChangedSinceLastRead ( ) const
virtualinherited

Return whether the constraints used to create Vector._buf for the last read() have changed, meaning we need to recompute Vector._buf using the new values.

Definition at line 164 of file NCMLBaseArray.cc.

◆ isConstrained()

bool ncml_module::NCMLBaseArray::isConstrained ( ) const
virtualinherited

Return whether the superclass Array has been constrained along any dimensions.

Definition at line 158 of file NCMLBaseArray.cc.

◆ isDataCached()

template<typename T>
virtual bool ncml_module::NCMLArray< T >::isDataCached ( ) const
inlinevirtual
Returns
whether we have the unconstrained data cached yet.

Implements ncml_module::NCMLBaseArray.

Definition at line 174 of file NCMLArray.h.

◆ operator=()

template<typename T>
NCMLArray< T > & ncml_module::NCMLArray< T >::operator= ( const NCMLArray< T > & rhs)
inline

Definition at line 115 of file NCMLArray.h.

◆ ptr_duplicate()

template<typename T>
virtual NCMLArray< T > * ncml_module::NCMLArray< T >::ptr_duplicate ( )
inlinevirtual

Override virtual constructor, deep clone

Definition at line 131 of file NCMLArray.h.

◆ read()

bool ncml_module::NCMLBaseArray::read ( )
virtualinherited

If there are no constraints and this is the first call to read(), we will do nothing, assuming the sueprclasses have everything under control.

If there are constraints, this function will create the correct buffer in Vector with the constrained data, generated from cached local values gathered to be from the unconstrained state.

The first call to read() will assume the CURRENT Vector buffer has ALL values (unconstrained) and store a local copy before generating a Vector buffer for the current constraints.

After this call, the caller can be assured that the Vector's data buffer has properly constrained data matching the current super Array's constraints. Subsequent calls to read() will see if the constraints used to create the Vector data buffer have changed and if so recompute a new Vector buffer from the locally cached values.

Definition at line 132 of file NCMLBaseArray.cc.

◆ read_p()

bool ncml_module::NCMLBaseArray::read_p ( )
virtualinherited

Override to return false if we have uncomputed constraints and only true if the current constraints match the Vector value buffer.

Definition at line 119 of file NCMLBaseArray.cc.

◆ set_read_p()

void ncml_module::NCMLBaseArray::set_read_p ( bool state)
virtualinherited

Override to disable setting of this flag. We will leave it false unless the constraints match the Vector value buffer.

Definition at line 126 of file NCMLBaseArray.cc.

◆ set_value() [1/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( dods_byte * val,
int sz )
inlinevirtual

Definition at line 204 of file NCMLArray.h.

◆ set_value() [2/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( dods_float32 * val,
int sz )
inlinevirtual

Definition at line 254 of file NCMLArray.h.

◆ set_value() [3/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( dods_float64 * val,
int sz )
inlinevirtual

Definition at line 264 of file NCMLArray.h.

◆ set_value() [4/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( dods_int16 * val,
int sz )
inlinevirtual

Definition at line 214 of file NCMLArray.h.

◆ set_value() [5/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( dods_int32 * val,
int sz )
inlinevirtual

Definition at line 234 of file NCMLArray.h.

◆ set_value() [6/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( dods_uint16 * val,
int sz )
inlinevirtual

Definition at line 224 of file NCMLArray.h.

◆ set_value() [7/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( dods_uint32 * val,
int sz )
inlinevirtual

Definition at line 244 of file NCMLArray.h.

◆ set_value() [8/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( string * val,
int sz )
inlinevirtual

Definition at line 274 of file NCMLArray.h.

◆ set_value() [9/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( vector< dods_byte > & val,
int sz )
inlinevirtual

Definition at line 209 of file NCMLArray.h.

◆ set_value() [10/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( vector< dods_float32 > & val,
int sz )
inlinevirtual

Definition at line 259 of file NCMLArray.h.

◆ set_value() [11/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( vector< dods_float64 > & val,
int sz )
inlinevirtual

Definition at line 269 of file NCMLArray.h.

◆ set_value() [12/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( vector< dods_int16 > & val,
int sz )
inlinevirtual

Definition at line 219 of file NCMLArray.h.

◆ set_value() [13/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( vector< dods_int32 > & val,
int sz )
inlinevirtual

Definition at line 239 of file NCMLArray.h.

◆ set_value() [14/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( vector< dods_uint16 > & val,
int sz )
inlinevirtual

Definition at line 229 of file NCMLArray.h.

◆ set_value() [15/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( vector< dods_uint32 > & val,
int sz )
inlinevirtual

Definition at line 249 of file NCMLArray.h.

◆ set_value() [16/16]

template<typename T>
virtual bool ncml_module::NCMLArray< T >::set_value ( vector< string > & val,
int sz )
inlinevirtual

Definition at line 279 of file NCMLArray.h.

Member Data Documentation

◆ _currentConstraints

Shape* ncml_module::NCMLBaseArray::_currentConstraints
protectedinherited

Definition at line 162 of file NCMLBaseArray.h.

◆ _noConstraints

Shape* ncml_module::NCMLBaseArray::_noConstraints
protectedinherited

Definition at line 158 of file NCMLBaseArray.h.


The documentation for this class was generated from the following file: