bes  Updated for version 3.20.6
DmrppTypeFactory.cc
1 // -*- mode: c++; c-basic-offset:4 -*-
2 
3 // This file is part of the BES
4 
5 // Copyright (c) 2016 OPeNDAP, Inc.
6 // Author: James Gallagher <jgallagher@opendap.org>
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
17 //
18 // You should have received a copy of the GNU Lesser General Public
19 // License along with this library; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 //
22 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
23 
24 #include "config.h"
25 
26 #include <string>
27 
28 #include <BESError.h>
29 #include <BESDebug.h>
30 
31 #include "DmrppByte.h"
32 
33 #include "DmrppInt8.h"
34 
35 #include "DmrppInt16.h"
36 #include "DmrppUInt16.h"
37 #include "DmrppInt32.h"
38 #include "DmrppUInt32.h"
39 
40 #include "DmrppInt64.h"
41 #include "DmrppUInt64.h"
42 
43 #include "DmrppFloat32.h"
44 #include "DmrppFloat64.h"
45 
46 #include "DmrppStr.h"
47 #include "DmrppUrl.h"
48 
49 #include "DmrppD4Enum.h"
50 
51 #include "DmrppD4Opaque.h"
52 
53 #include "DmrppArray.h"
54 #include "DmrppStructure.h"
55 
56 #include "DmrppD4Sequence.h"
57 #include "DmrppD4Group.h"
58 
59 #include "DmrppTypeFactory.h"
60 
61 using namespace libdap;
62 using namespace std;
63 
64 namespace dmrpp {
65 
66 BaseType *DmrppTypeFactory::NewVariable(Type t, const string &name) const
67 {
68  switch (t) {
69  case dods_byte_c:
70  return NewByte(name);
71  case dods_char_c:
72  return NewChar(name);
73 
74  case dods_uint8_c:
75  return NewUInt8(name);
76  case dods_int8_c:
77  return NewInt8(name);
78 
79  case dods_int16_c:
80  return NewInt16(name);
81  case dods_uint16_c:
82  return NewUInt16(name);
83  case dods_int32_c:
84  return NewInt32(name);
85  case dods_uint32_c:
86  return NewUInt32(name);
87 
88  case dods_int64_c:
89  return NewInt64(name);
90  case dods_uint64_c:
91  return NewUInt64(name);
92 
93  case dods_float32_c:
94  return NewFloat32(name);
95  case dods_float64_c:
96  return NewFloat64(name);
97 
98  case dods_str_c:
99  return NewStr(name);
100  case dods_url_c:
101  return NewURL(name);
102 
103  case dods_enum_c:
104  return NewEnum(name);
105 
106  case dods_opaque_c:
107  return NewOpaque(name);
108 
109  case dods_array_c:
110  return NewArray(name);
111 
112  case dods_structure_c:
113  return NewStructure(name);
114 
115  case dods_sequence_c:
116  return NewD4Sequence(name);
117 
118  case dods_group_c:
119  return NewGroup(name);
120 
121  default:
122  throw BESError("Unimplemented type in DAP4.", BES_INTERNAL_ERROR, __FILE__, __LINE__);
123  }
124 }
125 
126 Byte *
127 DmrppTypeFactory::NewByte(const string &n) const
128 {
129  return new DmrppByte(n);
130 }
131 
132 Byte *
133 DmrppTypeFactory::NewChar(const string &n) const
134 {
135  Byte *b = new DmrppByte(n);
136  b->set_type(dods_char_c);
137  return b;
138 }
139 
140 Byte *
141 DmrppTypeFactory::NewUInt8(const string &n) const
142 {
143  Byte *b = new DmrppByte(n);
144  b->set_type(dods_uint8_c);
145  return b;
146 }
147 
148 Int8 *
149 DmrppTypeFactory::NewInt8(const string &n) const
150 {
151  return new DmrppInt8(n);
152 }
153 
154 Int16 *
155 DmrppTypeFactory::NewInt16(const string &n) const
156 {
157  return new DmrppInt16(n);
158 }
159 
160 UInt16 *
161 DmrppTypeFactory::NewUInt16(const string &n) const
162 {
163  return new DmrppUInt16(n);
164 }
165 
166 Int32 *
167 DmrppTypeFactory::NewInt32(const string &n) const
168 {
169  BESDEBUG("dmrpp", "Inside DAP4BaseTypeFactory::NewInt32" << endl);
170  return new DmrppInt32(n);
171 }
172 
173 UInt32 *
174 DmrppTypeFactory::NewUInt32(const string &n) const
175 {
176  return new DmrppUInt32(n);
177 }
178 
179 Int64 *
180 DmrppTypeFactory::NewInt64(const string &n) const
181 {
182  BESDEBUG("dmrpp", "Inside DAP4BaseTypeFactory::NewInt64" << endl);
183  return new DmrppInt64(n);
184 }
185 
186 UInt64 *
187 DmrppTypeFactory::NewUInt64(const string &n) const
188 {
189  return new DmrppUInt64(n);
190 }
191 
192 Float32 *
193 DmrppTypeFactory::NewFloat32(const string &n) const
194 {
195  return new DmrppFloat32(n);
196 }
197 
198 Float64 *
199 DmrppTypeFactory::NewFloat64(const string &n) const
200 {
201  return new DmrppFloat64(n);
202 }
203 
204 Str *
205 DmrppTypeFactory::NewStr(const string &n) const
206 {
207  return new DmrppStr(n);
208 }
209 
210 Url *
211 DmrppTypeFactory::NewUrl(const string &n) const
212 {
213  return new DmrppUrl(n);
214 }
215 
218 Url *
219 DmrppTypeFactory::NewURL(const string &n) const
220 {
221  return NewUrl(n);
222 }
223 
224 D4Opaque *
225 DmrppTypeFactory::NewOpaque(const string &n) const
226 {
227  return new DmrppD4Opaque(n);
228 }
229 
230 D4Enum *
231 DmrppTypeFactory::NewEnum(const string &name, Type type) const
232 {
233  return new DmrppD4Enum(name, type);
234 }
235 
236 Array *
237 DmrppTypeFactory::NewArray(const string &n, BaseType *v) const
238 {
239  return new DmrppArray(n, v);
240 }
241 
242 Structure *
243 DmrppTypeFactory::NewStructure(const string &n) const
244 {
245  return new DmrppStructure(n);
246 }
247 
248 D4Sequence *
249 DmrppTypeFactory::NewD4Sequence(const string &n) const
250 {
251  return new DmrppD4Sequence(n);
252 }
253 
254 D4Group *
255 DmrppTypeFactory::NewGroup(const string &n) const
256 {
257  return new DmrppD4Group(n);
258 }
259 
260 } // namespace dmrpp
dmrpp::DmrppD4Opaque
Definition: DmrppD4Opaque.h:39
Type
Type
Type of JSON value.
Definition: cmr_module/rapidjson/rapidjson.h:603
libdap
Definition: BESDapFunctionResponseCache.h:35
BESError
Abstract exception class for the BES with basic string message.
Definition: BESError.h:58