Public Types | Public Member Functions | Static Public Member Functions

glv::Data Class Reference

Dynamically typed multidimensional array of primitive values. More...

#include <glv_model.h>

Inherits glv::ReferenceCounter.

List of all members.

Public Types

enum  Type {
  VOID = 0, BOOL, INT, FLOAT,
  DOUBLE, STRING
}
 

Data types.

More...

Public Member Functions

 Data ()
 This sets the data type to void and does not allocate memory.
 Data (Data &v)
 Data (const Data &v)
 Data (Data::Type type, int size1=1, int size2=1, int size3=1, int size4=1)
 Constructor that sets internal attributes without allocating memory.
template<class T >
 Data (T &value)
template<class T >
 Data (const T &value)
template<class T >
 Data (T *data, int size1, int size2=1, int size3=1, int size4=1)
bool operator== (const Data &v) const
 Returns whether elements from each array are equal.
bool operator!= (const Data &v) const
 Returns whether elements from each array are not equal.
template<class T >
const T at (int ind) const
 Get element at 1D index, performing type cast if necessary.
template<class T >
const T at (int i1, int i2) const
 Get element at 2D index, performing type cast if necessary.
template<class T >
const T at (int i1, int i2, int i3) const
 Get element at 3D index, performing type cast if necessary.
template<class T >
const T at (int i1, int i2, int i3, int i4) const
 Get element at 4D index, performing type cast if necessary.
template<class T >
const T & elem (int i) const
 Get element at 1D index using pointer casting.
bool hasData () const
 Returns whether there is valid data that can be accessed.
bool inBounds (int i1, int i2) const
 Returns whether 2D index is within bounds.
bool inBounds (int i1, int i2, int i3) const
 Returns whether 3D index is within bounds.
bool inBounds (int i1, int i2, int i3, int i4) const
 Returns whether 4D index is within bounds.
int indexFlat (int i1, int i2) const
 Convert 2D index to 1D index.
int indexFlat (int i1, int i2, int i3) const
 Convert 3D index to 1D index.
int indexFlat (int i1, int i2, int i3, int i4) const
 Convert 4D index to 1D index.
void indexDim (int &i1, int &i2, const int &i) const
 Convert 1D index to 2D index.
void indexDim (int &i1, int &i2, int &i3, const int &i) const
 Convert 1D index to 3D index.
void indexDim (int &i1, int &i2, int &i3, int &i4, const int &i) const
 Convert 1D index to 4D index.
bool isNumerical () const
 Returns whether type is numerical, i.e., int, float, or double.
int offset () const
 Get element offset into source array.
int order () const
 Get number of dimensions sized larger than 1.
Data reversed () const
 Returns reversed slice.
int size () const
 Get total number of elements.
const int * shape () const
 Get size array.
int sizeType () const
 Get size, in bytes, of element type.
Data slice (int offset=0) const
 Returns maximally sized 1D slice at given offset.
Data slice (int offset, int size) const
 Returns 1D slice with given offset, and size.
Data slice (int offset, int size, int stride) const
 Returns 1D slice with given offset, size, and stride.
int stride () const
 Get index stride.
const Typetype () const
 Get element type.
void print () const
 Print information to stdout.
Dataoperator= (const Data &v)
 Perform shallow copy from another Data.
template<class T >
Dataassign (const T &v)
 Assign value to first element.
template<class T >
Dataassign (const T &v, int i)
 Assign value to element at 1D index.
template<class T >
Dataassign (const T &v, int i1, int i2)
 Assign value to element at 2D index.
template<class T >
Dataassign (const T &v, int i1, int i2, int i3)
 Assign value to element at 3D index.
template<class T >
Dataassign (const T &v, int i1, int i2, int i3, int i4)
 Assign value to element at 4D index.
template<class T >
Dataassign (const T *src, int size, int stride=1)
 Assign elements from an external array.
Dataassign (const Data &v, int ind1=0, int ind2=0)
 Assign elements to elements from argument Data.
template<class T >
DataassignAll (const T &v)
 Assign all elements to argument.
void clone ()
 Allocate internal memory and copy over previous data.
template<class T >
T & elem (int i)
 Get mutable reference to element at 1D index using pointer casting.
template<class T >
T & elem (int i1, int i2)
 Get mutable reference to element at 2D index using pointer casting.
template<class T >
T & elem (int i1, int i2, int i3)
 Get mutable reference to element at 3D index using pointer casting.
template<class T >
T & elem (int i1, int i2, int i3, int i4)
 Get mutable reference to element at 4D index using pointer casting.
template<class T >
T * elems ()
 Returns pointer to first element.
template<class T >
const T * elems () const
 Get pointer to first element.
Dataresize (const int *sizes, int numDims)
 Resize array, allocating new memory if necessary.
Dataresize (int size1, int size2=1, int size3=1, int size4=1)
 Resize array, allocating new memory if necessary.
Dataresize (Data::Type type, const int *sizes, int numDims)
 Resize array, allocating new memory if necessary.
Dataresize (Data::Type type, int size1=1, int size2=1, int size3=1, int size4=1)
 Resize array allocating new memory, if necessary.
template<class T >
Dataset (T &v)
 Set data to reference a scalar.
template<class T >
Dataset (const T &v)
 Set new data from a scalar with specified value.
Dataset (const char *v)
 Set new data from a character string.
template<class T >
Dataset (T *data, const int *sizes, int numDims)
 Set data to reference an external multidimensional array.
template<class T >
Dataset (T *data, int size)
 Set data to reference an external 1D array.
Datashape (const int *sizes, int n)
 Set dimensions without reallocing new memory.
Datashape (int n1, int n2=1, int n3=1, int n4=1)
 Set dimensions without reallocing new memory.
Datastride (int v)
 Set index stride factor.
Datatype (Data::Type type)
 Change type of data.

Static Public Member Functions

static int maxDim ()
 Get maximum allowable dimensions.

Detailed Description

Dynamically typed multidimensional array of primitive values.

For operations between data with different types, standard type conversions will be used when possible. For binary operations between arrays, each array is treated as a one-dimensional array. If the number of elements differ, then the maximum possible number of elements are used in the comparison.


Member Enumeration Documentation

Data types.

Enumerator:
VOID 
BOOL 
INT 
FLOAT 
DOUBLE 
STRING 

Constructor & Destructor Documentation

glv::Data::Data ( Data v  ) 
Parameters:
[in] v data to reference
glv::Data::Data ( const Data v  ) 
Parameters:
[in] v data to make clone of
glv::Data::Data ( Data::Type  type,
int  size1 = 1,
int  size2 = 1,
int  size3 = 1,
int  size4 = 1 
)

Constructor that sets internal attributes without allocating memory.

Parameters:
[in] type type of data
[in] size1 size of dimension 1
[in] size2 size of dimension 2
[in] size3 size of dimension 3
[in] size4 size of dimension 4
template<class T >
glv::Data::Data ( T &  value  )  [inline, explicit]
Parameters:
[in] value external value to reference
template<class T >
glv::Data::Data ( const T &  value  )  [inline, explicit]
Parameters:
[in] value value to make clone of
template<class T >
glv::Data::Data ( T *  data,
int  size1,
int  size2 = 1,
int  size3 = 1,
int  size4 = 1 
) [inline]
Parameters:
[in] data pointer to external data to reference
[in] size1 size of dimension 1 of external data
[in] size2 size of dimension 2 of external data
[in] size3 size of dimension 3 of external data
[in] size4 size of dimension 4 of external data

Member Function Documentation

Data & glv::Data::type ( Data::Type  type  ) 

Change type of data.

New memory will be allocated if the type differs from the current type and the number of elements in the array is non-zero.


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