30 #ifndef __NCML_MODULE__SHAPE_H__
31 #define __NCML_MODULE__SHAPE_H__
73 :
public std::iterator < std::forward_iterator_tag, IndexTuple >
86 return (! ((*
this) == rhs));
112 void advanceCurrent();
115 void setCurrentToStart();
132 Shape(
const Array& copyDimsFrom);
144 return !(*
this == rhs);
160 static bool areDimensionsEqual(
const Array::dimension& lhs,
const Array::dimension& rhs);
165 unsigned int size = 1;
166 for (
unsigned int i=0; i<_dims.size(); ++i)
168 size *= _dims[i].size;
176 unsigned int c_size = 1;
177 for (
unsigned int i=0; i<_dims.size(); ++i)
179 c_size *= _dims[i].c_size;
200 unsigned int getRowMajorIndex(
const IndexTuple& indices,
bool validate=
true)
const;
222 void print(std::ostream& strm)
const;
225 static void printDimension(std::ostream& strm,
const Array::dimension& dim);
236 std::vector<Array::dimension> _dims;
242 inline std::ostream &
IndexIterator()
isEnd is only set by Shape for creating an end() iterator...
Shape::IndexIterator endSpaceEnumeration() const
The end of the enumeration for testing end conditions.
std::ostream & operator<<(std::ostream &strm, const ncml_module::Shape &shape)
bool validateIndices(const IndexTuple &indices) const
A custom iterator that enumerates all the points in the space defined by a Shape in row major order...
unsigned int getUnconstrainedSpaceSize() const
Get the product of all the dimension sizes.
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
std::vector< unsigned int > IndexTuple
IndexIterator & operator=(const IndexIterator &rhs)
void print(std::ostream &strm) const
Print the contents of this to the stream.
Shape & operator=(const Shape &rhs)
#define NCML_ASSERT_MSG(cond, msg)
void setToUnconstrained()
Go through and set all the values to be the unconstrained values.
A wrapper class for a vector of Array::dimension structs.
IndexIterator & operator++()
Shape()
The empty shape, with no dimensions.
bool operator!=(const Shape &rhs) const
bool isConstrained() const
Are there constraints on the dimension?
bool operator==(const IndexIterator &rhs) const
Shape::IndexIterator beginSpaceEnumeration() const
Create a forward iterator that returns IndexTuple's in a row major order (leftmost dimension slowest ...
static bool areDimensionsEqual(const Array::dimension &lhs, const Array::dimension &rhs)
Helper:
bool operator!=(const IndexIterator &rhs) const
IndexIterator operator++(int)
bool operator==(const Shape &rhs) const
Return if this contains the same shape as rhs.
std::string toString() const
Make a string that prints the contents of this.
const Shape::IndexTuple & operator*()
unsigned int getNumDimensions() const
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...
static void printDimension(std::ostream &strm, const Array::dimension &dim)
Helper to print the dimension to a stream.
unsigned int getConstrainedSpaceSize() const
Get the production of all dimension c_sizes.