32 #include "NCMLBaseArray.h"
33 #include "NCMLDebug.h"
55 auto_ptr< NCMLBaseArray >
56 NCMLBaseArray::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 auto_ptr< NCMLBaseArray > pNewArray = auto_ptr< NCMLBaseArray > (
dynamic_cast< NCMLBaseArray*
>(pNewBT.release()));
72 VALID_PTR(pNewArray.get());
75 pNewArray->copyDataFrom(proto);
81 NCMLBaseArray::NCMLBaseArray() :
82 Array(
"", 0), _noConstraints(0), _currentConstraints(0)
87 NCMLBaseArray::NCMLBaseArray(
const std::string& name) :
88 Array(name, 0), _noConstraints(0), _currentConstraints(0)
92 NCMLBaseArray::NCMLBaseArray(
const NCMLBaseArray& proto) :
93 Array(proto), _noConstraints(0), _currentConstraints(0)
95 copyLocalRepFrom(proto);
98 NCMLBaseArray::~NCMLBaseArray()
104 NCMLBaseArray::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);
187 void NCMLBaseArray::cacheUnconstrainedDimensions()
190 if (_noConstraints) {
195 _noConstraints =
new Shape(*
this);
207 if (!_noConstraints) {
208 cacheUnconstrainedDimensions();
215 void 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));
235 void NCMLBaseArray::destroy() throw ()
237 delete _noConstraints;
239 delete _currentConstraints;
240 _currentConstraints = 0;