30#include <libdap/BaseType.h>
32#include "NCMLBaseArray.h"
55unique_ptr< NCMLBaseArray >
56NCMLBaseArray::createFromArray(
const libdap::Array& protoC)
60 libdap::Array& proto =
const_cast<libdap::Array&
>(protoC);
62 BESDEBUG(
"ncml",
"NCMLBaseArray::createFromArray(): Converting prototype Array name=" + proto.name() +
" into an NCMLArray..." << endl);
64 BaseType* pTemplate = proto.var();
65 NCML_ASSERT_MSG(pTemplate,
"NCMLArray::createFromArray(): got NULL template BaseType var() for proto name=" + proto.name());
68 string ncmlArrayType =
"Array<" + pTemplate->type_name() +
">";
70 VALID_PTR(pNewBT.get());
71 unique_ptr< NCMLBaseArray > pNewArray = unique_ptr< NCMLBaseArray > (
dynamic_cast< NCMLBaseArray*
>(pNewBT.release()));
72 VALID_PTR(pNewArray.get());
75 pNewArray->copyDataFrom(proto);
81NCMLBaseArray::NCMLBaseArray() :
82 Array(
"", 0), _noConstraints(0), _currentConstraints(0)
87NCMLBaseArray::NCMLBaseArray(
const std::string& name) :
88 Array(name, 0), _noConstraints(0), _currentConstraints(0)
92NCMLBaseArray::NCMLBaseArray(
const NCMLBaseArray& proto) :
93 Array(proto), _noConstraints(0), _currentConstraints(0)
95 copyLocalRepFrom(proto);
98NCMLBaseArray::~NCMLBaseArray()
104NCMLBaseArray::operator=(
const NCMLBaseArray& rhs)
111 Array::operator=(rhs);
114 copyLocalRepFrom(rhs);
134 BESDEBUG(
"ncml",
"NCMLArray::read() called!" << endl);
167 if (!_currentConstraints) {
179 if (_currentConstraints) {
180 delete _currentConstraints;
181 _currentConstraints = 0;
183 _currentConstraints =
new Shape(*
this);
187void NCMLBaseArray::cacheUnconstrainedDimensions()
190 if (_noConstraints) {
195 _noConstraints =
new Shape(*
this);
196 _noConstraints->setToUnconstrained();
207 if (!_noConstraints) {
208 cacheUnconstrainedDimensions();
215void NCMLBaseArray::copyLocalRepFrom(
const NCMLBaseArray& proto)
218 if (&proto ==
this) {
225 if (proto._noConstraints) {
226 _noConstraints =
new Shape(*(proto._noConstraints));
229 if (proto._currentConstraints) {
230 _currentConstraints =
new Shape(*(proto._currentConstraints));
235void NCMLBaseArray::destroy() noexcept
237 delete _noConstraints;
239 delete _currentConstraints;
240 _currentConstraints = 0;
static std::unique_ptr< libdap::BaseType > makeVariable(const libdap::Type &type, const std::string &name)
virtual Shape getSuperShape() const
virtual bool isConstrained() const
virtual void cacheSuperclassStateIfNeeded()
virtual void cacheCurrentConstraints()
virtual void createAndSetConstrainedValueBuffer()=0
virtual void set_read_p(bool state)
virtual bool haveConstraintsChangedSinceLastRead() const
virtual void cacheValuesIfNeeded()=0
A wrapper class for a vector of Array::dimension structs.
bool isConstrained() const
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...