34 #include "BaseTypeFactory.h"
46 #include "Structure.h"
58 libdap::BaseTypeFactory* MyBaseTypeFactory::_spFactory =
new BaseTypeFactory();
60 MyBaseTypeFactory::MyBaseTypeFactory()
64 MyBaseTypeFactory::~MyBaseTypeFactory()
68 auto_ptr<libdap::BaseType>
69 MyBaseTypeFactory::makeVariable(
const libdap::Type& t,
const string &name)
74 return auto_ptr<BaseType>(_spFactory->NewByte(name));
78 return auto_ptr<BaseType>(_spFactory->NewInt16(name));
82 return auto_ptr<BaseType>(_spFactory->NewUInt16(name));
86 return auto_ptr<BaseType>(_spFactory->NewInt32(name));
90 return auto_ptr<BaseType>(_spFactory->NewUInt32(name));
94 return auto_ptr<BaseType>(_spFactory->NewFloat32(name));
98 return auto_ptr<BaseType>(_spFactory->NewFloat64(name));
102 return auto_ptr<BaseType>(_spFactory->NewStr(name));
106 return auto_ptr<BaseType>(_spFactory->NewUrl(name));
111 return auto_ptr<BaseType>(_spFactory->NewArray(name));
114 case dods_structure_c:
115 return auto_ptr<BaseType>(_spFactory->NewStructure(name));
118 case dods_sequence_c:
119 return auto_ptr<BaseType>(_spFactory->NewSequence(name));
123 return auto_ptr<BaseType>(_spFactory->NewGrid(name));
127 return auto_ptr<BaseType>(0);
131 auto_ptr<libdap::BaseType>
132 MyBaseTypeFactory::makeVariable(
const string& type,
const std::string& name)
134 if (isArrayTemplate(type))
138 return auto_ptr<BaseType>(makeArrayTemplateVariable(type, name,
true).release());
142 return makeVariable(getType(type), name);
148 MyBaseTypeFactory::getType(
const string& name)
154 else if (name ==
"Int16")
158 else if (name ==
"UInt16")
160 return dods_uint16_c;
163 else if (name ==
"Int32")
168 else if (name ==
"UInt32")
170 return dods_uint32_c;
173 else if (name ==
"Float32")
175 return dods_float32_c;
178 else if (name ==
"Float64")
180 return dods_float64_c;
183 else if (name ==
"String" || name ==
"string")
188 else if (name ==
"URL")
193 else if (name ==
"Array")
198 else if (name ==
"Structure")
200 return dods_structure_c;
203 else if (name ==
"Sequence")
205 return dods_sequence_c;
208 else if (name ==
"Grid")
220 MyBaseTypeFactory::isSimpleType(
const string& name)
222 Type t = getType(name);
240 MyBaseTypeFactory::isArrayTemplate(
const string& typeName)
243 return (typeName.find(
"Array<") == 0 && (typeName.at(typeName.size()-1) ==
'>'));
246 std::auto_ptr<libdap::Array>
247 MyBaseTypeFactory::makeArrayTemplateVariable(
const string& type,
const string& name,
bool makeTemplateVar)
253 if (type ==
"Array<Byte>")
258 pNew->add_var(makeVariable(
"Byte", name).
get());
261 else if (type ==
"Array<Int16>")
266 pNew->add_var(makeVariable(
"Int16", name).
get());
269 else if (type ==
"Array<UInt16>")
274 pNew->add_var(makeVariable(
"UInt16", name).
get());
277 else if (type ==
"Array<Int32>")
282 pNew->add_var(makeVariable(
"Int32", name).
get());
285 else if (type ==
"Array<UInt32>")
290 pNew->add_var(makeVariable(
"UInt32", name).
get());
293 else if (type ==
"Array<Float32>")
298 pNew->add_var(makeVariable(
"Float32", name).
get());
301 else if (type ==
"Array<Float64>")
306 pNew->add_var(makeVariable(
"Float64", name).
get());
310 type ==
"Array<String>" ||
317 pNew->add_var(makeVariable(
"String", name).
get());
320 else if ( type ==
"Array<URL>" ||
321 type ==
"Array<Url>")
326 pNew->add_var(makeVariable(
"URL", name).
get());
339 return auto_ptr<Array>(pNew);
A parameterized subclass of libdap::Array that allows us to apply constraints on NcML-specified data ...
An abstract superclass for NCMLArray that handles the non-parameterized functionality and allows u...
static class NCMLUtil overview
#define THROW_NCML_INTERNAL_ERROR(msg)