libdap Updated for version 3.20.10
libdap4 is an implementation of OPeNDAP's DAP protocol.
BaseTypeFactory.cc
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 "Byte.h"
31#include "Int16.h"
32#include "UInt16.h"
33#include "Int32.h"
34#include "UInt32.h"
35#include "Float32.h"
36#include "Float64.h"
37#include "Str.h"
38#include "Url.h"
39#include "Array.h"
40#include "Structure.h"
41#include "Sequence.h"
42#include "Grid.h"
43
44#include "BaseTypeFactory.h"
45#include "debug.h"
46
47namespace libdap {
48
49BaseType *
50BaseTypeFactory::NewVariable(Type type, const string &name) const
51{
52 switch (type) {
53 case dods_byte_c:
54 return NewByte(name);
55 case dods_int16_c:
56 return NewInt16(name);
57 case dods_uint16_c:
58 return NewUInt16(name);
59 case dods_int32_c:
60 return NewInt32(name);
61 case dods_uint32_c:
62 return NewUInt32(name);
63 case dods_float32_c:
64 return NewFloat32(name);
65 case dods_float64_c:
66 return NewFloat64(name);
67
68 case dods_str_c:
69 return NewStr(name);
70 case dods_url_c:
71 return NewUrl(name);
72
73 case dods_array_c:
74 return NewArray(name);
75 case dods_structure_c:
76 return NewStructure(name);
77 case dods_sequence_c:
78 return NewSequence(name);
79 case dods_grid_c:
80 return NewGrid(name);
81 default:
82 throw InternalErr(__FILE__, __LINE__, "Unknown type");
83 }
84}
85
86Byte *
87BaseTypeFactory::NewByte(const string &n) const
88{
89 return new Byte(n);
90}
91
92Int16 *
93BaseTypeFactory::NewInt16(const string &n) const
94{
95 return new Int16(n);
96}
97
98UInt16 *
99BaseTypeFactory::NewUInt16(const string &n) const
100{
101 return new UInt16(n);
102}
103
104Int32 *
105BaseTypeFactory::NewInt32(const string &n) const
106{
107 DBG(cerr << "Inside BaseTypeFactory::NewInt32" << endl);
108 return new Int32(n);
109}
110
111UInt32 *
112BaseTypeFactory::NewUInt32(const string &n) const
113{
114 return new UInt32(n);
115}
116
117Float32 *
118BaseTypeFactory::NewFloat32(const string &n) const
119{
120 return new Float32(n);
121}
122
123Float64 *
124BaseTypeFactory::NewFloat64(const string &n) const
125{
126 return new Float64(n);
127}
128
129Str *
130BaseTypeFactory::NewStr(const string &n) const
131{
132 return new Str(n);
133}
134
135Url *
136BaseTypeFactory::NewUrl(const string &n) const
137{
138 return new Url(n);
139}
140
141Array *
142BaseTypeFactory::NewArray(const string &n , BaseType *v) const
143{
144 return new Array(n, v);
145}
146
147Structure *
148BaseTypeFactory::NewStructure(const string &n) const
149{
150 return new Structure(n);
151}
152
153Sequence *
154BaseTypeFactory::NewSequence(const string &n) const
155{
156 DBG(cerr << "Inside BaseTypeFactory::NewSequence" << endl);
157 return new Sequence(n);
158}
159
160Grid *
161BaseTypeFactory::NewGrid(const string &n) const
162{
163 return new Grid(n);
164}
165
166} // namespace libdap
virtual BaseType * NewVariable(Type t, const string &name="") const
Holds a single byte.
Definition Byte.h:61
A class for software fault reporting.
Definition InternalErr.h:65
top level DAP object to house generic methods
Type
Identifies the data type.
Definition Type.h:94