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