31#include "MyBaseTypeFactory.h"
33#include <libdap/BaseType.h>
34#include <libdap/BaseTypeFactory.h>
36#include <libdap/Array.h>
37#include <libdap/Byte.h>
38#include <libdap/Float32.h>
39#include <libdap/Float64.h>
40#include <libdap/Grid.h>
41#include <libdap/Int16.h>
42#include <libdap/Int32.h>
44#include <libdap/Sequence.h>
45#include <libdap/Str.h>
46#include <libdap/Structure.h>
47#include <libdap/UInt16.h>
48#include <libdap/UInt32.h>
49#include <libdap/Url.h>
57libdap::BaseTypeFactory* MyBaseTypeFactory::_spFactory =
new BaseTypeFactory();
59MyBaseTypeFactory::MyBaseTypeFactory()
63MyBaseTypeFactory::~MyBaseTypeFactory()
71 return auto_ptr<BaseType>(_spFactory->NewByte(name));
75 return auto_ptr<BaseType>(_spFactory->NewInt16(name));
79 return auto_ptr<BaseType>(_spFactory->NewUInt16(name));
83 return auto_ptr<BaseType>(_spFactory->NewInt32(name));
87 return auto_ptr<BaseType>(_spFactory->NewUInt32(name));
91 return auto_ptr<BaseType>(_spFactory->NewFloat32(name));
95 return auto_ptr<BaseType>(_spFactory->NewFloat64(name));
99 return auto_ptr<BaseType>(_spFactory->NewStr(name));
103 return auto_ptr<BaseType>(_spFactory->NewUrl(name));
107 THROW_NCML_INTERNAL_ERROR(
"MyBaseTypeFactory::makeVariable(): no longer can make Array, instead use Array<T> form!");
110 case dods_structure_c:
111 return auto_ptr<BaseType>(_spFactory->NewStructure(name));
114 case dods_sequence_c:
115 return auto_ptr<BaseType>(_spFactory->NewSequence(name));
119 return auto_ptr<BaseType>(_spFactory->NewGrid(name));
123 return auto_ptr<BaseType>(0);
142 if (name ==
"Byte") {
145 else if (name ==
"Int16") {
148 else if (name ==
"UInt16") {
149 return dods_uint16_c;
152 else if (name ==
"Int32") {
156 else if (name ==
"UInt32") {
157 return dods_uint32_c;
160 else if (name ==
"Float32") {
161 return dods_float32_c;
164 else if (name ==
"Float64") {
165 return dods_float64_c;
168 else if (name ==
"String" || name ==
"string") {
172 else if (name ==
"URL") {
176 else if (name ==
"Array") {
180 else if (name ==
"Structure") {
181 return dods_structure_c;
184 else if (name ==
"Sequence") {
185 return dods_sequence_c;
188 else if (name ==
"Grid") {
219 return (typeName.find(
"Array<") == 0 && (typeName.at(typeName.size() - 1) ==
'>'));
223 bool makeTemplateVar)
229 if (type ==
"Array<Byte>") {
231 if (makeTemplateVar) {
232 pNew->add_var_nocopy(
makeVariable(
"Byte", name).release());
235 else if (type ==
"Array<Int16>") {
237 if (makeTemplateVar) {
238 pNew->add_var_nocopy(
makeVariable(
"Int16", name).release());
241 else if (type ==
"Array<UInt16>") {
243 if (makeTemplateVar) {
244 pNew->add_var_nocopy(
makeVariable(
"UInt16", name).release());
247 else if (type ==
"Array<Int32>") {
249 if (makeTemplateVar) {
250 pNew->add_var_nocopy(
makeVariable(
"Int32", name).release());
253 else if (type ==
"Array<UInt32>") {
255 if (makeTemplateVar) {
256 pNew->add_var_nocopy(
makeVariable(
"UInt32", name).release());
259 else if (type ==
"Array<Float32>") {
261 if (makeTemplateVar) {
262 pNew->add_var_nocopy(
makeVariable(
"Float32", name).release());
265 else if (type ==
"Array<Float64>") {
267 if (makeTemplateVar) {
268 pNew->add_var_nocopy(
makeVariable(
"Float64", name).release());
271 else if (type ==
"Array<String>" || type ==
"Array<Str>") {
273 if (makeTemplateVar) {
274 pNew->add_var_nocopy(
makeVariable(
"String", name).release());
277 else if (type ==
"Array<URL>" || type ==
"Array<Url>") {
279 if (makeTemplateVar) {
280 pNew->add_var_nocopy(
makeVariable(
"URL", name).release());
284 THROW_NCML_INTERNAL_ERROR(
"MyBaseTypeFactory::makeArrayTemplateVariable(): can't create type=" + type);
289 THROW_NCML_INTERNAL_ERROR(
290 "MyBaseTypeFactory::makeArrayTemplateVariable(): failed to allocate memory for type=" + type);
292 return auto_ptr<Array>(pNew);
static bool isSimpleType(const string &typeName)
static libdap::Type getType(const string &name)
static bool isArrayTemplate(const string &typeName)
static std::auto_ptr< libdap::Array > makeArrayTemplateVariable(const string &type, const string &name, bool addTemplateVar)
static std::auto_ptr< libdap::BaseType > makeVariable(const libdap::Type &type, const string &name)
A parameterized subclass of libdap::Array that allows us to apply constraints on NcML-specified data ...
NcML Parser for adding/modifying/removing metadata (attributes) to existing local datasets using NcML...