libdap Updated for version 3.21.1
libdap4 is an implementation of OPeNDAP's DAP protocol.
BaseTypeFactory.cc
Go to the documentation of this file.
1
2// -*- mode: c++; c-basic-offset:4 -*-
3
4// This file is part of libdap, A C++ implementation of the OPeNDAP Data
5// Access Protocol.
6
7// Copyright (c) 2005 OPeNDAP, Inc.
8// Author: James Gallagher <jgallagher@opendap.org>
9//
10// This library is free software; you can redistribute it and/or
11// modify it under the terms of the GNU Lesser General Public
12// License as published by the Free Software Foundation; either
13// version 2.1 of the License, or (at your option) any later version.
14//
15// This library is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18// Lesser General Public License for more details.
19//
20// You should have received a copy of the GNU Lesser General Public
21// License along with this library; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23//
24// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
25
26#include "config.h"
27
28#include <string>
29
30#include "Array.h"
31#include "Byte.h"
32#include "Float32.h"
33#include "Float64.h"
34#include "Grid.h"
35#include "Int16.h"
36#include "Int32.h"
37#include "Sequence.h"
38#include "Str.h"
39#include "Structure.h"
40#include "UInt16.h"
41#include "UInt32.h"
42#include "Url.h"
43
44#include "BaseTypeFactory.h"
45#include "debug.h"
46
47namespace libdap {
48
49BaseType *BaseTypeFactory::NewVariable(Type type, const string &name) const {
50 switch (type) {
51 case dods_byte_c:
52 return NewByte(name);
53 case dods_int16_c:
54 return NewInt16(name);
55 case dods_uint16_c:
56 return NewUInt16(name);
57 case dods_int32_c:
58 return NewInt32(name);
59 case dods_uint32_c:
60 return NewUInt32(name);
61 case dods_float32_c:
62 return NewFloat32(name);
63 case dods_float64_c:
64 return NewFloat64(name);
65
66 case dods_str_c:
67 return NewStr(name);
68 case dods_url_c:
69 return NewUrl(name);
70
71 case dods_array_c:
72 return NewArray(name);
74 return NewStructure(name);
75 case dods_sequence_c:
76 return NewSequence(name);
77 case dods_grid_c:
78 return NewGrid(name);
79 default:
80 throw InternalErr(__FILE__, __LINE__, "Unknown type");
81 }
82}
83
84Byte *BaseTypeFactory::NewByte(const string &n) const { return new Byte(n); }
85
86Int16 *BaseTypeFactory::NewInt16(const string &n) const { return new Int16(n); }
87
88UInt16 *BaseTypeFactory::NewUInt16(const string &n) const { return new UInt16(n); }
89
90Int32 *BaseTypeFactory::NewInt32(const string &n) const {
91 DBG(cerr << "Inside BaseTypeFactory::NewInt32" << endl);
92 return new Int32(n);
93}
94
95UInt32 *BaseTypeFactory::NewUInt32(const string &n) const { return new UInt32(n); }
96
97Float32 *BaseTypeFactory::NewFloat32(const string &n) const { return new Float32(n); }
98
99Float64 *BaseTypeFactory::NewFloat64(const string &n) const { return new Float64(n); }
100
101Str *BaseTypeFactory::NewStr(const string &n) const { return new Str(n); }
102
103Url *BaseTypeFactory::NewUrl(const string &n) const { return new Url(n); }
104
105Array *BaseTypeFactory::NewArray(const string &n, BaseType *v) const { return new Array(n, v); }
106
107Structure *BaseTypeFactory::NewStructure(const string &n) const { return new Structure(n); }
108
109Sequence *BaseTypeFactory::NewSequence(const string &n) const {
110 DBG(cerr << "Inside BaseTypeFactory::NewSequence" << endl);
111 return new Sequence(n);
112}
113
114Grid *BaseTypeFactory::NewGrid(const string &n) const { return new Grid(n); }
115
116} // namespace libdap
A multidimensional array of identical data types.
Definition Array.h:121
virtual BaseType * NewVariable(Type t, const string &name="") const
virtual Float32 * NewFloat32(const string &n="") const
virtual Int16 * NewInt16(const string &n="") const
virtual Str * NewStr(const string &n="") const
virtual UInt32 * NewUInt32(const string &n="") const
virtual Grid * NewGrid(const string &n="") const
virtual Int32 * NewInt32(const string &n="") const
virtual Float64 * NewFloat64(const string &n="") const
virtual Url * NewUrl(const string &n="") const
virtual Sequence * NewSequence(const string &n="") const
virtual Array * NewArray(const string &n="", BaseType *v=0) const
virtual Byte * NewByte(const string &n="") const
virtual Structure * NewStructure(const string &n="") const
virtual UInt16 * NewUInt16(const string &n="") const
The basic data type for the DODS DAP types.
Definition BaseType.h:118
Holds a single byte.
Definition Byte.h:59
Holds a 32-bit floating point value.
Definition Float32.h:59
Holds a 64-bit (double precision) floating point value.
Definition Float64.h:58
Holds the Grid data type.
Definition Grid.h:121
Holds a 16-bit signed integer value.
Definition Int16.h:57
Holds a 32-bit signed integer.
Definition Int32.h:63
A class for software fault reporting.
Definition InternalErr.h:61
Holds a sequence.
Definition Sequence.h:162
Holds character string data.
Definition Str.h:61
Holds a structure (aggregate) type.
Definition Structure.h:82
Holds an unsigned 16-bit integer.
Definition UInt16.h:55
Holds a 32-bit unsigned integer.
Definition UInt32.h:57
Holds an Internet address (URL).
Definition Url.h:55
#define DBG(x)
Definition debug.h:58
top level DAP object to house generic methods
Definition AISConnect.cc:30
Type
Identifies the data type.
Definition Type.h:94
@ dods_sequence_c
Definition Type.h:108
@ dods_uint32_c
Definition Type.h:100
@ dods_int16_c
Definition Type.h:97
@ dods_byte_c
Definition Type.h:96
@ dods_int32_c
Definition Type.h:99
@ dods_url_c
Definition Type.h:104
@ dods_float32_c
Definition Type.h:101
@ dods_uint16_c
Definition Type.h:98
@ dods_float64_c
Definition Type.h:102
@ dods_grid_c
Definition Type.h:111
@ dods_str_c
Definition Type.h:103
@ dods_structure_c
Definition Type.h:106
@ dods_array_c
Definition Type.h:107