29 #ifndef __NCML_MODULE__NCMLARRAY_H__
30 #define __NCML_MODULE__NCMLARRAY_H__
32 #include <dods-datatypes.h>
47 using libdap::dods_byte;
48 using libdap::dods_int16;
49 using libdap::dods_uint16;
50 using libdap::dods_int32;
51 using libdap::dods_uint32;
52 using libdap::dods_float32;
53 using libdap::dods_float64;
104 copyLocalRepFrom(proto);
125 copyLocalRepFrom(rhs);
152 set_attr_table(from.get_attr_table());
153 add_var(from.var()->ptr_duplicate());
156 Array::Dim_iter endIt = from.dim_end();
158 for (it = from.dim_begin(); it != endIt; ++it)
160 Array::dimension& dim = *it;
161 append_dim(dim.size, dim.name);
166 _allValues =
new std::vector<T>(from.length());
167 NCML_ASSERT(_allValues->size() ==
static_cast<unsigned int>(from.length()));
170 T* pFirst = &((*_allValues)[0]);
171 from.buf2val(reinterpret_cast<void**>(&pFirst));
186 #define NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER(arrayValue, sz) \
187 if (typeid(arrayValue) != typeid(T*)) \
189 THROW_NCML_INTERNAL_ERROR("NCMLArray<T>::set_value(): got wrong type of value array, doesn't match type T!"); \
191 bool ret = Vector::set_value((arrayValue), (sz)); \
192 cacheSuperclassStateIfNeeded(); \
195 #define NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER(vecValue, sz) \
196 if (typeid(vecValue) != typeid(vector<T>&)) \
198 THROW_NCML_INTERNAL_ERROR("NCMLArray<T>::setValue(): got wrong type of value vector, doesn't match type T!"); \
200 bool ret = Vector::set_value((vecValue), (sz)); \
201 cacheSuperclassStateIfNeeded(); \
229 virtual bool set_value(vector<dods_uint16> &val,
int sz)
249 virtual bool set_value(vector<dods_uint32> &val,
int sz)
259 virtual bool set_value(vector<dods_float32> &val,
int sz)
269 virtual bool set_value(vector<dods_float64> &val,
int sz)
284 #undef NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER
285 #undef NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER
301 if (get_value_capacity() == 0)
303 BESDEBUG(
"ncml",
"cacheValuesIfNeeded: the superclass Vector has no data so not copying...");
310 BESDEBUG(
"ncml",
"NCMLArray<T>:: we don't have unconstrained values cached, caching from Vector now..." << endl);
314 "NCMLArray expected superclass Vector length() to be the same as unconstrained space size, but it wasn't!");
316 _allValues =
new vector<T>(spaceSize);
320 T* pFirstElt = &((*_allValues)[0]);
322 unsigned int stored = buf2val(reinterpret_cast<void**>(&pFirstElt));
340 BESDEBUG(
"ncml",
"NCMLArray<T>::createAndSetConstrainedValueBuffer() called!" << endl);
344 const bool validateBounds =
false;
346 const bool validateBounds =
true;
354 unsigned int numVals = length();
356 values.reserve(numVals);
362 unsigned int count=0;
370 if (count != static_cast<unsigned int>(length()))
373 msg <<
"While adding points to hyperslab buffer we got differing number of points "
374 "from Shape space enumeration as expected from the constraints! "
375 "Shape::IndexIterator produced " << count <<
" points but we expected " << length();
382 msg <<
"While adding points to hyperslab buffer we got differing number of points "
383 "from Shape space enumeration as expected from the shape.getConstrainedSpaceSize()! "
390 val2buf(static_cast<void*>(&(values[0])),
true);
409 if (proto._allValues)
411 _allValues =
new vector<T>(*(proto._allValues));
416 void destroy() throw ()
418 delete _allValues; _allValues=0;
425 std::vector<T>* _allValues;
virtual Shape getSuperShape() const
Get the current dimensions of our superclass Array as a Shape object.
Shape::IndexIterator endSpaceEnumeration() const
The end of the enumeration for testing end conditions.
virtual void createAndSetConstrainedValueBuffer()
If we have constraints that are not the same as the constraints on the last read() call (or if this i...
virtual bool set_value(string *val, int sz)
A custom iterator that enumerates all the points in the space defined by a Shape in row major order...
A parameterized subclass of libdap::Array that allows us to apply constraints on NcML-specified data ...
unsigned int getUnconstrainedSpaceSize() const
Get the product of all the dimension sizes.
#define NCML_ASSERT(cond)
virtual void cacheValuesIfNeeded()
The first time we get a read(), we want to grab the current state of the superclass Array and Vector ...
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
virtual void copyDataFrom(libdap::Array &from)
Copy the rep from the given Array.
#define NCML_ASSERT_MSG(cond, msg)
virtual bool set_value(dods_uint32 *val, int sz)
virtual bool set_value(dods_float32 *val, int sz)
virtual bool set_value(vector< dods_uint32 > &val, int sz)
#define NCMLARRAY_CHECK_ARRAY_TYPE_THEN_CALL_SUPER(arrayValue, sz)
NCMLArray(const string &name)
A wrapper class for a vector of Array::dimension structs.
virtual bool set_value(dods_byte *val, int sz)
virtual bool set_value(vector< dods_int16 > &val, int sz)
NCMLBaseArray & operator=(const NCMLBaseArray &rhs)
virtual bool set_value(dods_uint16 *val, int sz)
virtual bool set_value(vector< dods_int32 > &val, int sz)
Shape::IndexIterator beginSpaceEnumeration() const
Create a forward iterator that returns IndexTuple's in a row major order (leftmost dimension slowest ...
virtual bool set_value(vector< string > &val, int sz)
virtual bool set_value(vector< dods_byte > &val, int sz)
virtual NCMLArray< T > * ptr_duplicate()
Override virtual constructor, deep clone.
#define THROW_NCML_INTERNAL_ERROR(msg)
virtual bool set_value(vector< dods_float32 > &val, int sz)
virtual bool set_value(vector< dods_float64 > &val, int sz)
virtual bool isDataCached() const
NCMLArray< T > & operator=(const NCMLArray< T > &rhs)
virtual bool set_value(dods_int32 *val, int sz)
virtual bool set_value(dods_int16 *val, int sz)
virtual ~NCMLArray()
Destroy any locally cached data.
#define NCMLARRAY_CHECK_VECTOR_TYPE_THEN_CALL_SUPER(vecValue, sz)
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
unsigned int getRowMajorIndex(const IndexTuple &indices, bool validate=true) const
Return the row major linear index into a slowest varying dimension first flattening of the given UNCO...
NCMLArray(const NCMLArray< T > &proto)
virtual bool set_value(dods_float64 *val, int sz)
unsigned int getConstrainedSpaceSize() const
Get the production of all dimension c_sizes.
virtual bool set_value(vector< dods_uint16 > &val, int sz)