35typedef vector<Array::dimension>::const_iterator DimItC;
45 Array& from =
const_cast<Array&
>(copyDimsFrom);
46 Array::Dim_iter endIt = from.dim_end();
48 for (it = from.dim_begin(); it != endIt; ++it) {
49 const Array::dimension& dim = (*it);
65Shape::operator=(
const Shape& rhs)
80 if (rhs._dims.size() != _dims.size()) {
85 for (
unsigned int i = 0; i < _dims.size(); ++i) {
99 for (
unsigned int i = 0; i < _dims.size(); ++i) {
100 const Array::dimension& dim = _dims[i];
101 ret |= (dim.c_size != dim.size);
111 for (
unsigned int i = 0; i < _dims.size(); ++i) {
112 Array::dimension& dim = _dims[i];
113 dim.c_size = dim.size;
115 dim.stop = dim.size - 1;
133 equal &= (lhs.size == rhs.size);
134 equal &= (lhs.name == rhs.name);
135 equal &= (lhs.start == rhs.start);
136 equal &= (lhs.stride == rhs.stride);
137 equal &= (lhs.c_size == rhs.c_size);
144 THROW_NCML_INTERNAL_ERROR(
145 "Shape::getRowMajorIndex got indices that were out of range for the given space dimensions!");
148 NCML_ASSERT(indices.size() >= 1);
149 unsigned int index = indices[0];
150 for (
unsigned int i = 1; i < indices.size(); ++i) {
151 index = indices[i] + (_dims[i].size * index);
168 std::stringstream sos;
175 strm <<
"Shape = { ";
176 for (
unsigned int i = 0; i < _dims.size(); ++i) {
177 const Array::dimension& dim = _dims[i];
185 strm <<
"\tDim = { \n";
186 strm <<
"\t\tname=" << dim.name <<
"\n";
187 strm <<
"\t\tsize=" << dim.size <<
"\n";
188 strm <<
"\t\tc_size=" << dim.c_size <<
"\n";
189 strm <<
"\t\tstart=" << dim.start <<
"\n";
190 strm <<
"\t\tstop=" << dim.stop <<
"\n";
191 strm <<
"\t\tstride=" << dim.stride <<
"\n";
196 if (indices.size() != _dims.size()) {
200 for (
unsigned int i = 0; i < _dims.size(); ++i) {
202 if (indices[i] >=
static_cast<unsigned int>(_dims[i].size)) {
214 _shape(0), _current(), _end(true)
219 _shape(&shape), _current(shape.getNumDimensions())
226 _shape(proto._shape), _current(proto._current), _end(proto._end)
230Shape::IndexIterator::~IndexIterator()
238Shape::IndexIterator::operator=(
const Shape::IndexIterator& rhs)
245 _current = rhs._current;
250bool Shape::IndexIterator::operator==(
const Shape::IndexIterator& rhs)
const
254 if (_shape != rhs._shape) {
259 if (_end != rhs._end) {
264 return (_current == rhs._current);
285void Shape::IndexIterator::advanceCurrent()
289 THROW_NCML_INTERNAL_ERROR(
"Shape::IndexIterator::advanceCurrent(): tried to advance beyond end()!");
293 unsigned int dimInd = _shape->getNumDimensions();
294 while (carry && dimInd-- > 0)
296 const Array::dimension& dim = _shape->_dims[dimInd];
298 unsigned int& currentDimIndex = _current[dimInd];
299 currentDimIndex += dim.stride;
302 if (currentDimIndex >
static_cast<unsigned int>(dim.stop)) {
303 currentDimIndex = dim.start;
315void Shape::IndexIterator::setCurrentToStart()
318 for (
unsigned int i = 0; i < _shape->getNumDimensions(); ++i) {
319 _current[i] = _shape->_dims[i].start;
A wrapper class for a vector of Array::dimension structs.
Shape::IndexIterator endSpaceEnumeration() const
void setToUnconstrained()
std::string toString() const
static bool areDimensionsEqual(const Array::dimension &lhs, const Array::dimension &rhs)
bool validateIndices(const IndexTuple &indices) const
bool isConstrained() const
unsigned int getRowMajorIndex(const IndexTuple &indices, bool validate=true) const
Shape::IndexIterator beginSpaceEnumeration() const
bool operator==(const Shape &rhs) const
static void printDimension(std::ostream &strm, const Array::dimension &dim)
void print(std::ostream &strm) const
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...