1#ifndef wmsimplearrays_h
2#define wmsimplearrays_h
21template<
int MAJOR_ORDER_TYPE>
52 _numBytesPerElement(that._numBytesPerElement)
72 _numBytesPerElement = that._numBytesPerElement;
105 char* byte_loc =
static_cast<char*
>(_data) + element_offset * _numBytesPerElement;
106 return static_cast<void*
>(byte_loc);
115 const void*
data(
const int* indices)
const
118 const char* byte_loc =
119 static_cast<const char*
>(_data) + element_offset * _numBytesPerElement;
120 return static_cast<const void*
>(byte_loc);
130 void*
dataSlab(
const int* indices,
int indicesRank)
133 for (
int i = 0; i < indicesRank; ++i)
134 slabStartIndices[i] = indices[i];
135 for (
int i = indicesRank; i <
rank(); ++i)
139 char* byte_loc =
static_cast<char*
>(_data) + element_offset * _numBytesPerElement;
140 return static_cast<void*
>(byte_loc);
150 const void*
dataSlab(
const int* indices,
int indicesRank)
const
153 for (
int i = 0; i < indicesRank; ++i)
154 slabStartIndices[i] = indices[i];
155 for (
int i = indicesRank; i <
rank(); ++i)
159 const char* byte_loc =
160 static_cast<const char*
>(_data) + element_offset * _numBytesPerElement;
161 return static_cast<const void*
>(byte_loc);
166 return _numBytesPerElement;
262 :
WmArrayBase<MAJOR_ORDER_TYPE>(), _data(NULL), _numBytesPerElement(0)
288 void checkContained(
const WxRange& selection)
const;
290 static void copyToRange(
int currentDim,
295 const char* sourceBuffer,
296 char* destinationPointer,
298 static void copyFromRange(
int currentDim,
303 const char* sourcePointer,
308 int _numBytesPerElement;
317template<
int MAJOR_ORDER_TYPE,
typename T>
331 _responsibleForFreeingElements(false)
345 _responsibleForFreeingElements(true)
358 :
WmTypeOpaqueArray<MAJOR_ORDER_TYPE>(that), _responsibleForFreeingElements(false)
371 :
WmTypeOpaqueArray<MAJOR_ORDER_TYPE>(that), _responsibleForFreeingElements(false)
390 _responsibleForFreeingElements =
false;
401 if (_responsibleForFreeingElements)
474 return static_cast<T*
>(
485 const T*
dataSlab(
const int* indices,
int indicesRank)
const
487 return static_cast<const T*
>(
524 if (_responsibleForFreeingElements)
527 _responsibleForFreeingElements =
false;
530 range, newdata,
sizeof(T));
545 bool _responsibleForFreeingElements;
Defines common interface for variables that are arrays.
Definition: wmarraybase.h:24
WmArrayBase< MAJOR_ORDER_TYPE > & operator=(const WmArrayBase< MAJOR_ORDER_TYPE > &that)
Assignment operator duplicates the array geometry properties of right hand side one.
Definition: wmarraybase.h:66
unsigned rank() const
Rank of array.
Definition: wmarraybase.h:114
void setRange(const WxRange &range)
Array spanning given range object.
Definition: wmarraybase.h:104
const WxRange & range() const
Definition: wmarraybase.h:26
static const int max_dims
Definition: wmarraybase.h:120
Defines common interface for arrays of elements.
Definition: wmsimplearrays.h:23
WmTypeOpaqueArray(const WmTypeOpaqueArray< MAJOR_ORDER_TYPE > &that)
Copy constructor does not allocate new memory.
Definition: wmsimplearrays.h:49
void * dataSlab(const int *indices, int indicesRank)
Access higher dimension slab of raw array element.
Definition: wmsimplearrays.h:130
const void * data() const
Access start of raw array data.
Definition: wmsimplearrays.h:91
void get(const WxRange &selection, const WxRange &outputShape, void *bufout) const
Copy data elements from the region described range selection to the bufout provided.
WmTypeOpaqueArray< MAJOR_ORDER_TYPE > & operator=(const WmTypeOpaqueArray< MAJOR_ORDER_TYPE > &that)
Definition: wmsimplearrays.h:66
int numBytesPerElement() const
Definition: wmsimplearrays.h:164
const void * dataSlab(const int *indices, int indicesRank) const
Access higher dimension slab of raw array element.
Definition: wmsimplearrays.h:150
void * data()
Access start of raw array data.
Definition: wmsimplearrays.h:81
void * data(const int *indices)
Access raw array element.
Definition: wmsimplearrays.h:102
void put(const WxRange &selection, const WxRange &inputShape, const void *bufin)
Copy data elements from bufin to the region described by the range selection.
WmTypeOpaqueArray(const WxRange &range, void *data, int numBytesPerElement)
Array spanning given range object.
Definition: wmsimplearrays.h:34
WmTypeOpaqueArray()
Default ctor does not set up array geometry initially, this must be done later, so it is only exposed...
Definition: wmsimplearrays.h:261
const void * data(const int *indices) const
Access raw array element.
Definition: wmsimplearrays.h:115
virtual ~WmTypeOpaqueArray()
Delete object which only describes the array geometry, no array allocation is deleted.
Definition: wmsimplearrays.h:250
void resetArrayProperties(const WxRange &range, void *data, int numBytesPerElement)
Reset the properties of this array.
Definition: wmsimplearrays.h:271
Defines common interface for arrays of type T elements.
Definition: wmsimplearrays.h:319
WmTypedArray< MAJOR_ORDER_TYPE, T > & operator=(const WmTypedArray< MAJOR_ORDER_TYPE, T > &that)
Definition: wmsimplearrays.h:385
void resetArrayProperties(const WxRange &range, T *newdata)
Copy data elements from bufin to the region described by the range selection.
Definition: wmsimplearrays.h:522
T & operator()(int k0, int k1, int k2)
T & operator()(int k0, int k1, int k2, int k3)
const T * data() const
Access raw array data.
Definition: wmsimplearrays.h:460
WmTypedArray(const WmTypedArray< MAJOR_ORDER_TYPE, T > &that)
Copy constructor does not allocate new memory.
Definition: wmsimplearrays.h:357
T operator()(int k0) const
Rank-1 indexer.
WmTypedArray()
Default ctor does not set up array geometry initially, this must be done later, so it is only exposed...
Definition: wmsimplearrays.h:539
const T * dataSlab(const int *indices, int indicesRank) const
Access higher dimension slab of raw array element.
Definition: wmsimplearrays.h:485
T operator()(int k0, int k1, int k2) const
Rank-3 indexer.
T operator()(int k0, int k1) const
Rank-2 indexer.
T operator()(int k0, int k1, int k2, int k3) const
Rank-4 indexer.
WmTypedArray(const WxRange &range, T *data)
Array spanning given range object.
Definition: wmsimplearrays.h:329
T * dataSlab(const int *indices, int indicesRank)
Access higher dimension slab of raw array element.
Definition: wmsimplearrays.h:472
WmTypedArray(const WmTypeOpaqueArray< MAJOR_ORDER_TYPE > &that)
Special copy constructor does not allocate new memory.
Definition: wmsimplearrays.h:370
T & operator()(int k0, int k1)
WmTypedArray(const WxRange &range)
Array spanning given range object.
Definition: wmsimplearrays.h:343
T * data()
Access raw array data.
Definition: wmsimplearrays.h:450
~WmTypedArray()
Delete instance which may or may not involve freeing array element allocation.
Definition: wmsimplearrays.h:399
TYPE lower(unsigned dim) const
Lower bound along dimension 'dim'.
Definition: wxbox.h:124
WxRange represents a hyper-rectangular domain of an n-dimensional space of integers.
Definition: wxrange.h:23