libdap  Updated for version 3.20.6
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 
47 namespace libdap {
48 
49 BaseType *
50 BaseTypeFactory::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 
86 Byte *
87 BaseTypeFactory::NewByte(const string &n) const
88 {
89  return new Byte(n);
90 }
91 
92 Int16 *
93 BaseTypeFactory::NewInt16(const string &n) const
94 {
95  return new Int16(n);
96 }
97 
98 UInt16 *
99 BaseTypeFactory::NewUInt16(const string &n) const
100 {
101  return new UInt16(n);
102 }
103 
104 Int32 *
105 BaseTypeFactory::NewInt32(const string &n) const
106 {
107  DBG(cerr << "Inside BaseTypeFactory::NewInt32" << endl);
108  return new Int32(n);
109 }
110 
111 UInt32 *
112 BaseTypeFactory::NewUInt32(const string &n) const
113 {
114  return new UInt32(n);
115 }
116 
117 Float32 *
118 BaseTypeFactory::NewFloat32(const string &n) const
119 {
120  return new Float32(n);
121 }
122 
123 Float64 *
124 BaseTypeFactory::NewFloat64(const string &n) const
125 {
126  return new Float64(n);
127 }
128 
129 Str *
130 BaseTypeFactory::NewStr(const string &n) const
131 {
132  return new Str(n);
133 }
134 
135 Url *
136 BaseTypeFactory::NewUrl(const string &n) const
137 {
138  return new Url(n);
139 }
140 
141 Array *
142 BaseTypeFactory::NewArray(const string &n , BaseType *v) const
143 {
144  return new Array(n, v);
145 }
146 
147 Structure *
148 BaseTypeFactory::NewStructure(const string &n) const
149 {
150  return new Structure(n);
151 }
152 
153 Sequence *
154 BaseTypeFactory::NewSequence(const string &n) const
155 {
156  DBG(cerr << "Inside BaseTypeFactory::NewSequence" << endl);
157  return new Sequence(n);
158 }
159 
160 Grid *
161 BaseTypeFactory::NewGrid(const string &n) const
162 {
163  return new Grid(n);
164 }
165 
166 } // namespace libdap
Holds an Internet address (URL).
Definition: Url.h:68
Holds an unsigned 16-bit integer.
Definition: UInt16.h:57
Holds a structure (aggregate) type.
Definition: Structure.h:83
Type
Identifies the data type.
Definition: Type.h:94
Holds a 32-bit floating point value.
Definition: Float32.h:61
top level DAP object to house generic methods
Definition: AISConnect.cc:30
A class for software fault reporting.
Definition: InternalErr.h:64
Holds character string data.
Definition: Str.h:62
virtual BaseType * NewVariable(Type t, const string &name="") const
Holds a 16-bit signed integer value.
Definition: Int16.h:59
Holds the Grid data type.
Definition: Grid.h:122
Holds a sequence.
Definition: Sequence.h:162
The basic data type for the DODS DAP types.
Definition: BaseType.h:117
Holds a 64-bit (double precision) floating point value.
Definition: Float64.h:60
Holds a single byte.
Definition: Byte.h:60
Holds a 32-bit unsigned integer.
Definition: UInt32.h:59
A multidimensional array of identical data types.
Definition: Array.h:112
Holds a 32-bit signed integer.
Definition: Int32.h:65