libdap
Updated for version 3.17.0
|
00001 00002 // -*- mode: c++; c-basic-offset:4 -*- 00003 00004 // This file is part of libdap, A C++ implementation of the OPeNDAP Data 00005 // Access Protocol. 00006 00007 // Copyright (c) 2005 OPeNDAP, Inc. 00008 // Author: James Gallagher <jgallagher@opendap.org> 00009 // 00010 // This library is free software; you can redistribute it and/or 00011 // modify it under the terms of the GNU Lesser General Public 00012 // License as published by the Free Software Foundation; either 00013 // version 2.1 of the License, or (at your option) any later version. 00014 // 00015 // This library is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 // Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public 00021 // License along with this library; if not, write to the Free Software 00022 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00023 // 00024 // You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112. 00025 00026 #include "config.h" 00027 00028 #include <string> 00029 00030 #include "BaseType.h" 00031 #include "Type.h" 00032 00033 #include "Byte.h" 00034 #include "Int8.h" 00035 #include "Int16.h" 00036 #include "UInt16.h" 00037 #include "Int32.h" 00038 #include "UInt32.h" 00039 00040 #include "Int64.h" 00041 #include "UInt64.h" 00042 00043 #include "Float32.h" 00044 #include "Float64.h" 00045 00046 #include "D4Enum.h" 00047 00048 #include "Str.h" 00049 #include "Url.h" 00050 00051 #include "D4Opaque.h" 00052 00053 #include "Array.h" 00054 00055 #include "Structure.h" 00056 #include "D4Sequence.h" 00057 00058 #include "D4Group.h" 00059 00060 #include "D4BaseTypeFactory.h" 00061 #include "debug.h" 00062 00063 namespace libdap { 00064 00065 BaseType *D4BaseTypeFactory::NewVariable(Type t, const string &name) const 00066 { 00067 switch (t) { 00068 case dods_byte_c: 00069 return NewByte(name); 00070 case dods_char_c: 00071 return NewChar(name); 00072 case dods_uint8_c: 00073 return NewUInt8(name); 00074 case dods_int8_c: 00075 return NewInt8(name); 00076 00077 case dods_int16_c: 00078 return NewInt16(name); 00079 case dods_uint16_c: 00080 return NewUInt16(name); 00081 case dods_int32_c: 00082 return NewInt32(name); 00083 case dods_uint32_c: 00084 return NewUInt32(name); 00085 00086 case dods_int64_c: 00087 return NewInt64(name); 00088 case dods_uint64_c: 00089 return NewUInt64(name); 00090 00091 case dods_float32_c: 00092 return NewFloat32(name); 00093 case dods_float64_c: 00094 return NewFloat64(name); 00095 00096 case dods_enum_c: 00097 return NewEnum(name); 00098 00099 case dods_str_c: 00100 return NewStr(name); 00101 case dods_url_c: 00102 return NewURL(name); 00103 00104 case dods_opaque_c: 00105 return NewOpaque(name); 00106 00107 case dods_structure_c: 00108 return NewStructure(name); 00109 00110 case dods_sequence_c: 00111 return NewD4Sequence(name); 00112 00113 case dods_array_c: 00114 return NewArray(name); 00115 00116 case dods_group_c: 00117 return NewGroup(name); 00118 00119 default: 00120 throw InternalErr(__FILE__, __LINE__, "Unimplemented type in DAP4"); 00121 } 00122 } 00123 00124 Byte * 00125 D4BaseTypeFactory::NewByte(const string &n) const 00126 { 00127 return new Byte(n); 00128 } 00129 00130 // Use the type constants specific to Char and UInt8 so the print reps will 00131 // match the server's idea of the types. 00132 Byte * 00133 D4BaseTypeFactory::NewChar(const string &n) const 00134 { 00135 Byte *b = new Byte(n); 00136 b->set_type(dods_char_c); 00137 return b; 00138 } 00139 00140 Byte * 00141 D4BaseTypeFactory::NewUInt8(const string &n) const 00142 { 00143 Byte *b = new Byte(n); 00144 b->set_type(dods_uint8_c); 00145 return b; 00146 } 00147 00148 Int8 * 00149 D4BaseTypeFactory::NewInt8(const string &n) const 00150 { 00151 return new Int8(n); 00152 } 00153 00154 Int16 * 00155 D4BaseTypeFactory::NewInt16(const string &n) const 00156 { 00157 return new Int16(n); 00158 } 00159 00160 UInt16 * 00161 D4BaseTypeFactory::NewUInt16(const string &n) const 00162 { 00163 return new UInt16(n); 00164 } 00165 00166 Int32 * 00167 D4BaseTypeFactory::NewInt32(const string &n) const 00168 { 00169 DBG(cerr << "Inside DAP4BaseTypeFactory::NewInt32" << endl); 00170 return new Int32(n); 00171 } 00172 00173 UInt32 * 00174 D4BaseTypeFactory::NewUInt32(const string &n) const 00175 { 00176 return new UInt32(n); 00177 } 00178 00179 Int64 * 00180 D4BaseTypeFactory::NewInt64(const string &n) const 00181 { 00182 DBG(cerr << "Inside DAP4BaseTypeFactory::NewInt64" << endl); 00183 return new Int64(n); 00184 } 00185 00186 UInt64 * 00187 D4BaseTypeFactory::NewUInt64(const string &n) const 00188 { 00189 return new UInt64(n); 00190 } 00191 00192 Float32 * 00193 D4BaseTypeFactory::NewFloat32(const string &n) const 00194 { 00195 return new Float32(n); 00196 } 00197 00198 Float64 * 00199 D4BaseTypeFactory::NewFloat64(const string &n) const 00200 { 00201 return new Float64(n); 00202 } 00203 00211 D4Enum * 00212 D4BaseTypeFactory::NewEnum(const string &name, Type type) const 00213 { 00214 return new D4Enum(name, type); 00215 } 00216 00217 00218 Str * 00219 D4BaseTypeFactory::NewStr(const string &n) const 00220 { 00221 return new Str(n); 00222 } 00223 00224 Url * 00225 D4BaseTypeFactory::NewUrl(const string &n) const 00226 { 00227 return new Url(n); 00228 } 00229 00230 D4Opaque * 00231 D4BaseTypeFactory::NewOpaque(const string &n) const 00232 { 00233 return new D4Opaque(n); 00234 } 00235 00238 Url * 00239 D4BaseTypeFactory::NewURL(const string &n) const 00240 { 00241 return new Url(n); 00242 } 00243 00244 Array * 00245 D4BaseTypeFactory::NewArray(const string &n, BaseType *v) const 00246 { 00247 return new Array(n, v, true /* is_dap4 */); 00248 } 00249 00250 Structure * 00251 D4BaseTypeFactory::NewStructure(const string &n) const 00252 { 00253 return new Structure(n); 00254 } 00255 00256 D4Sequence * 00257 D4BaseTypeFactory::NewD4Sequence(const string &n) const 00258 { 00259 return new D4Sequence(n); 00260 } 00261 00262 D4Group * 00263 D4BaseTypeFactory::NewGroup(const string &n) const 00264 { 00265 return new D4Group(n); 00266 } 00267 00268 } // namespace libdap