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 "Byte.h" 00031 #include "Int16.h" 00032 #include "UInt16.h" 00033 #include "Int32.h" 00034 #include "UInt32.h" 00035 #include "Float32.h" 00036 #include "Float64.h" 00037 #include "Str.h" 00038 #include "Url.h" 00039 #include "Array.h" 00040 #include "Structure.h" 00041 #include "Sequence.h" 00042 #include "Grid.h" 00043 00044 #include "BaseTypeFactory.h" 00045 #include "debug.h" 00046 00047 namespace libdap { 00048 00049 BaseType * 00050 BaseTypeFactory::NewVariable(Type type, const string &name) const 00051 { 00052 switch (type) { 00053 case dods_byte_c: 00054 return NewByte(name); 00055 case dods_int16_c: 00056 return NewInt16(name); 00057 case dods_uint16_c: 00058 return NewUInt16(name); 00059 case dods_int32_c: 00060 return NewInt32(name); 00061 case dods_uint32_c: 00062 return NewUInt32(name); 00063 case dods_float32_c: 00064 return NewFloat32(name); 00065 case dods_float64_c: 00066 return NewFloat64(name); 00067 00068 case dods_str_c: 00069 return NewStr(name); 00070 case dods_url_c: 00071 return NewUrl(name); 00072 00073 case dods_array_c: 00074 return NewArray(name); 00075 case dods_structure_c: 00076 return NewStructure(name); 00077 case dods_sequence_c: 00078 return NewSequence(name); 00079 case dods_grid_c: 00080 return NewGrid(name); 00081 default: 00082 throw InternalErr(__FILE__, __LINE__, "Unknown type"); 00083 } 00084 } 00085 00086 Byte * 00087 BaseTypeFactory::NewByte(const string &n) const 00088 { 00089 return new Byte(n); 00090 } 00091 00092 Int16 * 00093 BaseTypeFactory::NewInt16(const string &n) const 00094 { 00095 return new Int16(n); 00096 } 00097 00098 UInt16 * 00099 BaseTypeFactory::NewUInt16(const string &n) const 00100 { 00101 return new UInt16(n); 00102 } 00103 00104 Int32 * 00105 BaseTypeFactory::NewInt32(const string &n) const 00106 { 00107 DBG(cerr << "Inside BaseTypeFactory::NewInt32" << endl); 00108 return new Int32(n); 00109 } 00110 00111 UInt32 * 00112 BaseTypeFactory::NewUInt32(const string &n) const 00113 { 00114 return new UInt32(n); 00115 } 00116 00117 Float32 * 00118 BaseTypeFactory::NewFloat32(const string &n) const 00119 { 00120 return new Float32(n); 00121 } 00122 00123 Float64 * 00124 BaseTypeFactory::NewFloat64(const string &n) const 00125 { 00126 return new Float64(n); 00127 } 00128 00129 Str * 00130 BaseTypeFactory::NewStr(const string &n) const 00131 { 00132 return new Str(n); 00133 } 00134 00135 Url * 00136 BaseTypeFactory::NewUrl(const string &n) const 00137 { 00138 return new Url(n); 00139 } 00140 00141 Array * 00142 BaseTypeFactory::NewArray(const string &n , BaseType *v) const 00143 { 00144 return new Array(n, v); 00145 } 00146 00147 Structure * 00148 BaseTypeFactory::NewStructure(const string &n) const 00149 { 00150 return new Structure(n); 00151 } 00152 00153 Sequence * 00154 BaseTypeFactory::NewSequence(const string &n) const 00155 { 00156 DBG(cerr << "Inside BaseTypeFactory::NewSequence" << endl); 00157 return new Sequence(n); 00158 } 00159 00160 Grid * 00161 BaseTypeFactory::NewGrid(const string &n) const 00162 { 00163 return new Grid(n); 00164 } 00165 00166 } // namespace libdap