OPeNDAP Hyrax Back End Server (BES)  Updated for version 3.8.3
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. 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 ()
 Store the current super Array shape as the current constraints so we remember. More...
 
virtual void cacheSuperclassStateIfNeeded ()
 Required by subclasses to copy the original data values locally. More...
 
virtual void cacheUnconstrainedDimensions ()
 
virtual void copyDataFrom (libdap::Array &from)
 Copy the rep from the given Array. More...
 
virtual Shape getSuperShape () const
 Get the current dimensions of our superclass Array as a Shape object. More...
 
virtual bool haveConstraintsChangedSinceLastRead () const
 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. More...
 
virtual bool isConstrained () const
 Return whether the superclass Array has been constrained along any dimensions. More...
 
virtual bool isDataCached () const
 
 NCMLArray ()
 
 NCMLArray (const string &name)
 
 NCMLArray (const NCMLArray< T > &proto)
 
NCMLArray< T > & operator= (const NCMLArray< T > &rhs)
 
virtual NCMLArray< T > * ptr_duplicate ()
 Override virtual constructor, deep clone. More...
 
virtual bool read ()
 If there are no constraints and this is the first call to read(), we will do nothing, assuming the sueprclasses have everything under control. More...
 
virtual bool read_p ()
 Override to return false if we have uncomputed constraints and only true if the current constraints match the Vector value buffer. More...
 
virtual void set_read_p (bool state)
 Override to disable setting of this flag. More...
 
virtual bool set_value (dods_byte *val, int sz)
 
virtual bool set_value (vector< dods_byte > &val, int sz)
 
virtual bool set_value (dods_int16 *val, int sz)
 
virtual bool set_value (vector< dods_int16 > &val, int sz)
 
virtual bool set_value (dods_uint16 *val, int sz)
 
virtual bool set_value (vector< dods_uint16 > &val, int sz)
 
virtual bool set_value (dods_int32 *val, int sz)
 
virtual bool set_value (vector< dods_int32 > &val, int sz)
 
virtual bool set_value (dods_uint32 *val, int sz)
 
virtual bool set_value (vector< dods_uint32 > &val, int sz)
 
virtual bool set_value (dods_float32 *val, int sz)
 
virtual bool set_value (vector< dods_float32 > &val, int sz)
 
virtual bool set_value (dods_float64 *val, int sz)
 
virtual bool set_value (vector< dods_float64 > &val, int sz)
 
virtual bool set_value (string *val, int sz)
 
virtual bool set_value (vector< string > &val, int sz)
 
virtual ~NCMLArray ()
 Destroy any locally cached data. More...
 

Static Public Member Functions

static auto_ptr< NCMLBaseArraycreateFromArray (const libdap::Array &proto)
 Make a new NCMLArray<T> from the given proto, using the Array interface. More...
 

Protected Member Functions

virtual void cacheValuesIfNeeded ()
 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. More...
 
virtual void createAndSetConstrainedValueBuffer ()
 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. More...
 

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.

Definition at line 83 of file NCMLArray.h.

Constructor & Destructor Documentation

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

Definition at line 88 of file NCMLArray.h.

Referenced by ncml_module::NCMLArray< T >::ptr_duplicate().

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

Definition at line 94 of file NCMLArray.h.

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

Definition at line 100 of file NCMLArray.h.

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

Destroy any locally cached data.

Definition at line 108 of file NCMLArray.h.

Member Function Documentation

void ncml_module::NCMLBaseArray::cacheCurrentConstraints ( )
virtualinherited

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

Definition at line 188 of file NCMLBaseArray.cc.

References ncml_module::NCMLBaseArray::_currentConstraints.

Referenced by ncml_module::NCMLBaseArray::read().

void ncml_module::NCMLBaseArray::cacheSuperclassStateIfNeeded ( )
virtualinherited

Required by subclasses to copy the original data values locally.

Definition at line 217 of file NCMLBaseArray.cc.

References ncml_module::NCMLBaseArray::_noConstraints, ncml_module::NCMLBaseArray::cacheUnconstrainedDimensions(), ncml_module::NCMLBaseArray::cacheValuesIfNeeded(), and NCML_ASSERT.

Referenced by ncml_module::NCMLBaseArray::read().

Here is the call graph for this function:

void ncml_module::NCMLBaseArray::cacheUnconstrainedDimensions ( )
virtualinherited

Definition at line 201 of file NCMLBaseArray.cc.

References ncml_module::NCMLBaseArray::_noConstraints, and ncml_module::Shape::setToUnconstrained().

Referenced by ncml_module::NCMLBaseArray::cacheSuperclassStateIfNeeded().

Here is the call graph for this function:

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.

References ncml_module::NCMLBaseArray::_noConstraints, BESDEBUG, ncml_module::Shape::getUnconstrainedSpaceSize(), NCML_ASSERT, and NCML_ASSERT_MSG.

Here is the call graph for this function:

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.

References NCML_ASSERT, and VALID_PTR.

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 338 of file NCMLArray.h.

References ncml_module::NCMLBaseArray::_noConstraints, ncml_module::Shape::beginSpaceEnumeration(), BESDEBUG, ncml_module::Shape::endSpaceEnumeration(), ncml_module::Shape::getConstrainedSpaceSize(), ncml_module::Shape::getRowMajorIndex(), ncml_module::NCMLBaseArray::getSuperShape(), THROW_NCML_INTERNAL_ERROR, and VALID_PTR.

Here is the call graph for this function:

auto_ptr< NCMLBaseArray > ncml_module::NCMLBaseArray::createFromArray ( const libdap::Array &  protoC)
staticinherited

Make a new NCMLArray<T> from the given proto, using the Array interface.

It uses the underlying proto.var() BaseType to figure out the type parameter T for the returned class, hence the return of the generic superclass pointer.

All the data values in the proto value buffer are copied into the returned copy. This ASSUMES that the data currently in proto's Vector _buf is valid for the UNCONSTRAINED data case.

It also copies the template arg, attribute table, and shape of the proto.

Note
This is used for handling problems with renaming an NCArray prior to read() loading the data, forcing us to call read() on a rename, thus breaking constraints. To handle this error, we copy the data into our NCMLArray<T> in order to handle the constraints ourselves.

It uses the underlying proto.var() BaseType to figure out the type parameter T for the returned class, hence the return of the generic superclass pointer.

All the data values in the proto value buffer are copied into the returned copy. This ASSUMES that the data currently in proto's Vector _buf is valid for the UNCONSTRAINED data case.

Note
This is used for handling problems with renaming an NCArray prior to read() loading the data, forcing us to call read() on a rename, thus breaking constraints. To handle this error, we copy the data into our NCMLArray<T> in order to handle the constraints ourselves.

Definition at line 53 of file NCMLBaseArray.cc.

References BESDEBUG, ncml_module::MyBaseTypeFactory::makeVariable(), NCML_ASSERT_MSG, and VALID_PTR.

Here is the call graph for this function:

Shape ncml_module::NCMLBaseArray::getSuperShape ( ) const
virtualinherited
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 174 of file NCMLBaseArray.cc.

References ncml_module::NCMLBaseArray::_currentConstraints, and ncml_module::NCMLBaseArray::getSuperShape().

Referenced by ncml_module::NCMLBaseArray::read(), and ncml_module::NCMLBaseArray::read_p().

Here is the call graph for this function:

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

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

Definition at line 167 of file NCMLBaseArray.cc.

References ncml_module::NCMLBaseArray::getSuperShape(), and ncml_module::Shape::isConstrained().

Here is the call graph for this function:

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.

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

Definition at line 114 of file NCMLArray.h.

References ncml_module::NCMLBaseArray::operator=().

Here is the call graph for this function:

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.

References ncml_module::NCMLArray< T >::NCMLArray().

Here is the call graph for this function:

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 138 of file NCMLBaseArray.cc.

References BESDEBUG, ncml_module::NCMLBaseArray::cacheCurrentConstraints(), ncml_module::NCMLBaseArray::cacheSuperclassStateIfNeeded(), ncml_module::NCMLBaseArray::createAndSetConstrainedValueBuffer(), and ncml_module::NCMLBaseArray::haveConstraintsChangedSinceLastRead().

Here is the call graph for this function:

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 123 of file NCMLBaseArray.cc.

References ncml_module::NCMLBaseArray::haveConstraintsChangedSinceLastRead().

Here is the call graph for this function:

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 131 of file NCMLBaseArray.cc.

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.

References NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER.

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

Definition at line 274 of file NCMLArray.h.

References NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER.

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.

References NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER.

Member Data Documentation

Shape* ncml_module::NCMLBaseArray::_currentConstraints
protectedinherited

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