bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
ncml_module::Shape Class Reference

A wrapper class for a vector of Array::dimension structs. More...

#include <Shape.h>

Collaboration diagram for ncml_module::Shape:
Collaboration graph

Classes

class  IndexIterator
 

Public Types

typedef std::vector< unsigned intIndexTuple
 

Public Member Functions

Shape::IndexIterator beginSpaceEnumeration () const
 
Shape::IndexIterator endSpaceEnumeration () const
 
unsigned int getConstrainedSpaceSize () const
 
unsigned int getNumDimensions () const
 
unsigned int getRowMajorIndex (const IndexTuple &indices, bool validate=true) const
 
unsigned int getUnconstrainedSpaceSize () const
 
bool isConstrained () const
 
bool operator!= (const Shape &rhs) const
 
Shapeoperator= (const Shape &rhs)
 
bool operator== (const Shape &rhs) const
 
void print (std::ostream &strm) const
 
void setToUnconstrained ()
 
 Shape ()
 
 Shape (const Array &copyDimsFrom)
 
 Shape (const Shape &proto)
 
std::string toString () const
 
bool validateIndices (const IndexTuple &indices) const
 

Static Public Member Functions

static bool areDimensionsEqual (const Array::dimension &lhs, const Array::dimension &rhs)
 
static void printDimension (std::ostream &strm, const Array::dimension &dim)
 

Friends

class IndexIterator
 

Detailed Description

A wrapper class for a vector of Array::dimension structs.

We add functionality for equality, getting space sizes for constrained and unconstrained cases, and a way to get row major absolute indices into a linear array rep of a multi-dimensional array (as C stores them).

Shape::IndexIterator: We also add an iterator for generating the full set of index tuples for all the points in a given Shape (constrained or not) using a row major order memory traversal (i.e. for the case of no constraints, we should advance linearly one element at a time through the memory when looking up an index tuple). Leftmost component of the tuple varies fastest. Again, these iterator work if there is a constraint on the dataset as well, generating one index tuple for each entry in the defined hyperslab, also in row major order so that the constrained elements can be shoved into a Vector _buf for shipping off the hyperslab.

Definition at line 58 of file Shape.h.

Member Typedef Documentation

◆ IndexTuple

typedef std::vector<unsigned int> ncml_module::Shape::IndexTuple

Definition at line 61 of file Shape.h.

Constructor & Destructor Documentation

◆ Shape() [1/3]

ncml_module::Shape::Shape ( )

The empty shape, with no dimensions. Not valid for anything useful except IndexIterator

Empty shape

Definition at line 38 of file Shape.cc.

◆ Shape() [2/3]

ncml_module::Shape::Shape ( const Shape & proto)

Definition at line 54 of file Shape.cc.

◆ Shape() [3/3]

ncml_module::Shape::Shape ( const Array & copyDimsFrom)

Create this Shape from the shape of the given Array.

Definition at line 43 of file Shape.cc.

◆ ~Shape()

ncml_module::Shape::~Shape ( )

Definition at line 59 of file Shape.cc.

Member Function Documentation

◆ areDimensionsEqual()

bool ncml_module::Shape::areDimensionsEqual ( const Array::dimension & lhs,
const Array::dimension & rhs )
static

Helper:

Returns
whether all the fields of the two args are equal

Definition at line 120 of file Shape.cc.

◆ beginSpaceEnumeration()

Shape::IndexIterator ncml_module::Shape::beginSpaceEnumeration ( ) const

Create a forward iterator that returns IndexTuple's in a row major order (leftmost dimension slowest varying) enumeration of all the points in this Shape. This uses constraints, so should return getConstrainedSpaceSize() values. If constraints are not set, the getConstrainedSpaceSize() == getUnconstrainedSpaceSize().

ASSUMES: this Shape CANNOT be mutated during the life of the return value!! Only const functions should be used for the life of the returned iterator.

Definition at line 156 of file Shape.cc.

◆ endSpaceEnumeration()

Shape::IndexIterator ncml_module::Shape::endSpaceEnumeration ( ) const

The end of the enumeration for testing end conditions.

See also
beginSpaceEnumeration()

Definition at line 161 of file Shape.cc.

◆ getConstrainedSpaceSize()

unsigned int ncml_module::Shape::getConstrainedSpaceSize ( ) const
inline

Get the production of all dimension c_sizes.

Definition at line 169 of file Shape.h.

◆ getNumDimensions()

unsigned int ncml_module::Shape::getNumDimensions ( ) const
inline

Definition at line 149 of file Shape.h.

◆ getRowMajorIndex()

unsigned int ncml_module::Shape::getRowMajorIndex ( const IndexTuple & indices,
bool validate = true ) const

Return the row major linear index into a slowest varying dimension first flattening of the given UNCONSTRAINED space (ie use dim.size for each dimension's size)

Parameters
indicesan array with an index into each dimension of the space.
validatewhether to do bounds checks or not. true means slightly slower, but safer. exceptions are only thrown if validate, unless a memory fault occurs from bad indices.

ASSUME: indices.size() is the dimensionality of the space, which MUST match _dims.size() or we throw.

Given there are d dimensions of size n_i for i in {0, d-1} and indices is the d-tuple (i_0, i_1, ..., 1_{d-1}) where each i_j is in [0, n_j - 1] the index is: i_{d-1} + n_{d-1} * (i_{d-2} + n_{d-2} * ( ... + n_1 * i_0) )

Exceptions
Ifthe dimensionality of indices does not match the dimensionality of _dims.
Ifany index in indices is out of bounds for the matching dimension in _dims.

Definition at line 141 of file Shape.cc.

◆ getUnconstrainedSpaceSize()

unsigned int ncml_module::Shape::getUnconstrainedSpaceSize ( ) const
inline

Get the product of all the dimension sizes

Definition at line 159 of file Shape.h.

◆ isConstrained()

bool ncml_module::Shape::isConstrained ( ) const

Are there constraints on the dimension?

Definition at line 96 of file Shape.cc.

◆ operator!=()

bool ncml_module::Shape::operator!= ( const Shape & rhs) const
inline
Returns
!(*this == rhs)

Definition at line 138 of file Shape.h.

◆ operator=()

Shape & ncml_module::Shape::operator= ( const Shape & rhs)

Definition at line 65 of file Shape.cc.

◆ operator==()

bool ncml_module::Shape::operator== ( const Shape & rhs) const

Return if this contains the same shape as rhs. They must match ALL fields of ALL dimensions to be equal!!

Definition at line 75 of file Shape.cc.

◆ print()

void ncml_module::Shape::print ( std::ostream & strm) const

Print the contents of this to the stream

Definition at line 173 of file Shape.cc.

◆ printDimension()

void ncml_module::Shape::printDimension ( std::ostream & strm,
const Array::dimension & dim )
static

Helper to print the dimension to a stream.

Definition at line 183 of file Shape.cc.

◆ setToUnconstrained()

void ncml_module::Shape::setToUnconstrained ( )

Go through and set all the values to be the unconstrained values

Definition at line 109 of file Shape.cc.

◆ toString()

std::string ncml_module::Shape::toString ( ) const

Make a string that prints the contents of this

Definition at line 166 of file Shape.cc.

◆ validateIndices()

bool ncml_module::Shape::validateIndices ( const IndexTuple & indices) const
Returns
whether all the indices are in the correct ranges for current dims and that the indices.size() matches the _dims.size().

Definition at line 194 of file Shape.cc.

Friends And Related Symbol Documentation

◆ IndexIterator

friend class IndexIterator
friend

Definition at line 121 of file Shape.h.


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