1 /***************************************************************************
2 typetraits.cpp - type parameterization
3 -------------------
4 begin : July 22 2002
5 copyright : (C) 2002-2006 by Marc Schellens
6 email : m_schellens@users.sf.net
7 ***************************************************************************/
8
9 /***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18 #include "includefirst.hpp"
19
20 #include "typetraits.hpp"
21 #include "datatypes.hpp"
22 #include "dstructgdl.hpp"
23
24 using namespace std;
25
26 const DType SpDByte::t=GDL_BYTE; // type ID
27 const string SpDByte::str("BYTE"); // type string
28 const DByte SpDByte::zero=0;
GetTag() const29 BaseGDL* SpDByte::GetTag() const { return new SpDByte(*this);}
Type() const30 DType SpDByte::Type() const { return t;}
TypeStr() const31 const std::string& SpDByte::TypeStr() const { return str;}
32
33 const DType SpDInt::t=GDL_INT; // type ID
34 const string SpDInt::str("INT"); // type string
35 const DInt SpDInt::zero=0;
GetTag() const36 BaseGDL* SpDInt::GetTag() const { return new SpDInt(*this);}
Type() const37 DType SpDInt::Type() const { return t;}
TypeStr() const38 const std::string& SpDInt::TypeStr() const { return str;}
39
40 const DType SpDUInt::t=GDL_UINT; // type ID
41 const string SpDUInt::str("UINT"); // type string
42 const DUInt SpDUInt::zero=0;
GetTag() const43 BaseGDL* SpDUInt::GetTag() const { return new SpDUInt(*this);}
Type() const44 DType SpDUInt::Type() const { return t;}
TypeStr() const45 const std::string& SpDUInt::TypeStr() const { return str;}
46
47
48 const DType SpDLong::t=GDL_LONG; // type ID
49 const string SpDLong::str("LONG"); // type string
50 const DLong SpDLong::zero=0;
GetTag() const51 BaseGDL* SpDLong::GetTag() const { return new SpDLong(*this);}
Type() const52 DType SpDLong::Type() const { return t;}
TypeStr() const53 const std::string& SpDLong::TypeStr() const { return str;}
54
55 const DType SpDULong::t=GDL_ULONG; // type ID
56 const string SpDULong::str("ULONG"); // type string
57 const DULong SpDULong::zero=0;
GetTag() const58 BaseGDL* SpDULong::GetTag() const { return new SpDULong(*this);}
Type() const59 DType SpDULong::Type() const { return t;}
TypeStr() const60 const std::string& SpDULong::TypeStr() const { return str;}
61
62 const DType SpDLong64::t=GDL_LONG64; // type ID
63 const string SpDLong64::str("LONG64"); // type string
64 const DLong64 SpDLong64::zero=0;
GetTag() const65 BaseGDL* SpDLong64::GetTag() const { return new SpDLong64(*this);}
Type() const66 DType SpDLong64::Type() const { return t;}
TypeStr() const67 const std::string& SpDLong64::TypeStr() const { return str;}
68
69 const DType SpDULong64::t=GDL_ULONG64; // type ID
70 const string SpDULong64::str("ULONG64"); // type string
71 const DULong64 SpDULong64::zero=0;
GetTag() const72 BaseGDL* SpDULong64::GetTag() const { return new SpDULong64(*this);}
Type() const73 DType SpDULong64::Type() const { return t;}
TypeStr() const74 const std::string& SpDULong64::TypeStr() const { return str;}
75
76 const DType SpDFloat::t=GDL_FLOAT; // type ID
77 const string SpDFloat::str("FLOAT"); // type string
78 const DFloat SpDFloat::zero=0.0;
GetTag() const79 BaseGDL* SpDFloat::GetTag() const { return new SpDFloat(*this);}
Type() const80 DType SpDFloat::Type() const { return t;}
TypeStr() const81 const std::string& SpDFloat::TypeStr() const { return str;}
82
83 const DType SpDDouble::t=GDL_DOUBLE; // type ID
84 const string SpDDouble::str("DOUBLE"); // type string
85 const DDouble SpDDouble::zero=0.0;
GetTag() const86 BaseGDL* SpDDouble::GetTag() const { return new SpDDouble(*this);}
Type() const87 DType SpDDouble::Type() const { return t;}
TypeStr() const88 const std::string& SpDDouble::TypeStr() const { return str;}
89
90 const DType SpDString::t=GDL_STRING; // type ID
91 const string SpDString::str("STRING"); // type string
92 const DString SpDString::zero(""); // zero string
GetTag() const93 BaseGDL* SpDString::GetTag() const { return new SpDString(*this);}
Type() const94 DType SpDString::Type() const { return t;}
TypeStr() const95 const std::string& SpDString::TypeStr() const { return str;}
96
97 const DType SpDStruct::t=GDL_STRUCT; // type ID
98 const string SpDStruct::str("STRUCT"); // type string
99 const SpDStruct::Ty SpDStruct::zero=0; // zero struct, special meaning
GetTag() const100 BaseGDL* SpDStruct::GetTag() const
101 {
102 SpDStruct* newTag = new SpDStruct(*this);
103 newTag->MakeOwnDesc();
104 return newTag;
105 }
Type() const106 DType SpDStruct::Type() const { return t;}
TypeStr() const107 const std::string& SpDStruct::TypeStr() const { return str;}
108
109 const DType SpDPtr::t=GDL_PTR; // type ID
110 const string SpDPtr::str("POINTER"); // type string
111 const DPtr SpDPtr::zero=0; // zero ptr
GetTag() const112 BaseGDL* SpDPtr::GetTag() const { return new SpDPtr(*this);}
Type() const113 DType SpDPtr::Type() const { return t;}
TypeStr() const114 const std::string& SpDPtr::TypeStr() const { return str;}
115
116 const DType SpDObj::t=GDL_OBJ; // type ID
117 const string SpDObj::str("OBJREF"); // type string
118 const DObj SpDObj::zero=0; // zero ptr/obj
GetTag() const119 BaseGDL* SpDObj::GetTag() const { return new SpDObj(*this);}
Type() const120 DType SpDObj::Type() const { return t;}
TypeStr() const121 const std::string& SpDObj::TypeStr() const { return str;}
122
123 const DType SpDComplex::t=GDL_COMPLEX; // type ID
124 const string SpDComplex::str("COMPLEX"); // type string
125 const DComplex SpDComplex::zero(0.0,0.0);
GetTag() const126 BaseGDL* SpDComplex::GetTag() const { return new SpDComplex(*this);}
Type() const127 DType SpDComplex::Type() const { return t;}
TypeStr() const128 const std::string& SpDComplex::TypeStr() const { return str;}
129
130 const DType SpDComplexDbl::t=GDL_COMPLEXDBL; // type ID
131 const string SpDComplexDbl::str("DCOMPLEX"); // type string
132 const DComplexDbl SpDComplexDbl::zero(0.0,0.0);
GetTag() const133 BaseGDL* SpDComplexDbl::GetTag() const { return new SpDComplexDbl(*this);}
Type() const134 DType SpDComplexDbl::Type() const { return t;}
TypeStr() const135 const std::string& SpDComplexDbl::TypeStr() const { return str;}
136
137 // for GDL structs
138 // returns an empty instance (for actually holding data)
GetInstance() const139 BaseGDL* SpDByte::GetInstance() const { return new Data_<SpDByte>(dim);}
GetInstance() const140 BaseGDL* SpDInt::GetInstance() const { return new Data_<SpDInt>(dim);}
GetInstance() const141 BaseGDL* SpDUInt::GetInstance() const { return new Data_<SpDUInt>(dim);}
GetInstance() const142 BaseGDL* SpDLong::GetInstance() const { return new Data_<SpDLong>(dim);}
GetInstance() const143 BaseGDL* SpDULong::GetInstance() const { return new Data_<SpDULong>(dim);}
GetInstance() const144 BaseGDL* SpDLong64::GetInstance() const { return new Data_<SpDLong64>(dim);}
GetInstance() const145 BaseGDL* SpDULong64::GetInstance() const { return new Data_<SpDULong64>(dim);}
GetInstance() const146 BaseGDL* SpDFloat::GetInstance() const { return new Data_<SpDFloat>(dim);}
GetInstance() const147 BaseGDL* SpDDouble::GetInstance() const { return new Data_<SpDDouble>(dim);}
GetInstance() const148 BaseGDL* SpDString::GetInstance() const { return new Data_<SpDString>(dim);}
GetInstance() const149 BaseGDL* SpDPtr::GetInstance() const { return new Data_<SpDPtr>(dim);}
GetInstance() const150 BaseGDL* SpDObj::GetInstance() const { return new Data_<SpDObj>(dim);}
GetInstance() const151 BaseGDL* SpDStruct::GetInstance() const
152 {
153 DStructGDL* newInstance = new DStructGDL(desc,dim);
154 newInstance->MakeOwnDesc();
155 return newInstance;
156 }
GetInstance() const157 BaseGDL* SpDComplex::GetInstance() const { return new Data_<SpDComplex>(dim);}
GetInstance() const158 BaseGDL* SpDComplexDbl::GetInstance() const { return new Data_<SpDComplexDbl>(dim);}
159
160 // returns an instance without allocating memory
GetEmptyInstance() const161 BaseGDL* SpDByte::GetEmptyInstance() const { return new Data_<SpDByte>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const162 BaseGDL* SpDInt::GetEmptyInstance() const { return new Data_<SpDInt>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const163 BaseGDL* SpDUInt::GetEmptyInstance() const { return new Data_<SpDUInt>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const164 BaseGDL* SpDLong::GetEmptyInstance() const { return new Data_<SpDLong>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const165 BaseGDL* SpDULong::GetEmptyInstance() const { return new Data_<SpDULong>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const166 BaseGDL* SpDLong64::GetEmptyInstance() const { return new Data_<SpDLong64>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const167 BaseGDL* SpDULong64::GetEmptyInstance() const { return new Data_<SpDULong64>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const168 BaseGDL* SpDFloat::GetEmptyInstance() const { return new Data_<SpDFloat>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const169 BaseGDL* SpDDouble::GetEmptyInstance() const { return new Data_<SpDDouble>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const170 BaseGDL* SpDString::GetEmptyInstance() const { return new Data_<SpDString>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const171 BaseGDL* SpDPtr::GetEmptyInstance() const { return new Data_<SpDPtr>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const172 BaseGDL* SpDObj::GetEmptyInstance() const { return new Data_<SpDObj>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const173 BaseGDL* SpDStruct::GetEmptyInstance() const
174 {
175 DStructGDL* newInstance = new DStructGDL( desc, dim, BaseGDL::NOALLOC);
176 newInstance->MakeOwnDesc();
177 return newInstance;
178 }
GetEmptyInstance() const179 BaseGDL* SpDComplex::GetEmptyInstance() const { return new Data_<SpDComplex>( dim, BaseGDL::NOALLOC);}
GetEmptyInstance() const180 BaseGDL* SpDComplexDbl::GetEmptyInstance() const { return new Data_<SpDComplexDbl>( dim, BaseGDL::NOALLOC);}
181
SpDByte()182 SpDByte::SpDByte(): BaseGDL() {}
SpDByte(const dimension & dim_)183 SpDByte::SpDByte( const dimension& dim_): BaseGDL(dim_) {}
~SpDByte()184 SpDByte::~SpDByte() {}
185
SpDInt()186 SpDInt::SpDInt(): BaseGDL() {}
SpDInt(const dimension & dim_)187 SpDInt::SpDInt( const dimension& dim_): BaseGDL(dim_) {}
~SpDInt()188 SpDInt::~SpDInt() {}
189
SpDUInt()190 SpDUInt::SpDUInt(): BaseGDL() {}
SpDUInt(const dimension & dim_)191 SpDUInt::SpDUInt( const dimension& dim_): BaseGDL(dim_) {}
~SpDUInt()192 SpDUInt::~SpDUInt() {};
193
SpDLong()194 SpDLong::SpDLong(): BaseGDL() {}
SpDLong(const dimension & dim_)195 SpDLong::SpDLong( const dimension& dim_): BaseGDL(dim_) {}
~SpDLong()196 SpDLong::~SpDLong() {}
197
SpDULong()198 SpDULong::SpDULong(): BaseGDL() {}
SpDULong(const dimension & dim_)199 SpDULong::SpDULong( const dimension& dim_): BaseGDL(dim_) {}
~SpDULong()200 SpDULong::~SpDULong() {}
201
SpDLong64()202 SpDLong64::SpDLong64(): BaseGDL() {}
SpDLong64(const dimension & dim_)203 SpDLong64::SpDLong64( const dimension& dim_): BaseGDL(dim_) {}
~SpDLong64()204 SpDLong64::~SpDLong64() {}
205
SpDULong64()206 SpDULong64::SpDULong64(): BaseGDL() {}
SpDULong64(const dimension & dim_)207 SpDULong64::SpDULong64( const dimension& dim_): BaseGDL(dim_) {}
~SpDULong64()208 SpDULong64::~SpDULong64() {}
209
SpDFloat()210 SpDFloat::SpDFloat(): BaseGDL() {}
SpDFloat(const dimension & dim_)211 SpDFloat::SpDFloat( const dimension& dim_): BaseGDL(dim_) {}
~SpDFloat()212 SpDFloat::~SpDFloat() {}
213
SpDDouble()214 SpDDouble::SpDDouble(): BaseGDL() {}
SpDDouble(const dimension & dim_)215 SpDDouble::SpDDouble( const dimension& dim_): BaseGDL(dim_) {}
~SpDDouble()216 SpDDouble::~SpDDouble() {}
217
SpDString()218 SpDString::SpDString(): BaseGDL() {}
SpDString(const dimension & dim_)219 SpDString::SpDString( const dimension& dim_): BaseGDL(dim_) {}
~SpDString()220 SpDString::~SpDString() {}
221
SpDStruct(DStructDesc * desc_)222 SpDStruct::SpDStruct( DStructDesc* desc_):
223 BaseGDL(),
224 desc(desc_)
225 {
226 // if( desc != NULL && desc->IsUnnamed())
227 // desc = new DStructDesc( desc);
228 }
229
SpDStruct(DStructDesc * desc_,const dimension & dim_)230 SpDStruct::SpDStruct( DStructDesc* desc_, const dimension& dim_):
231 BaseGDL(dim_),
232 desc(desc_)
233 {
234 // if( desc == NULL) cout << "SpDStruct::SpDStruct( DStructDesc* desc_, const dimension& dim_): desc_ == NULL" << endl;
235 // if( desc_ != NULL && desc_->IsUnnamed())
236 // desc = new DStructDesc( desc_);
237 }
238
~SpDStruct()239 SpDStruct::~SpDStruct()
240 {
241 if( desc != NULL && desc->IsUnnamed()) desc->Delete();
242 }
243
SpDPtr()244 SpDPtr::SpDPtr(): BaseGDL() {}
SpDPtr(const dimension & dim_)245 SpDPtr::SpDPtr( const dimension& dim_): BaseGDL(dim_) {}
~SpDPtr()246 SpDPtr::~SpDPtr() {}
247
SpDObj()248 SpDObj::SpDObj(): BaseGDL() {}
SpDObj(const dimension & dim_)249 SpDObj::SpDObj( const dimension& dim_): BaseGDL(dim_) {}
~SpDObj()250 SpDObj::~SpDObj() {}
251
SpDComplex()252 SpDComplex::SpDComplex(): BaseGDL() {}
SpDComplex(const dimension & dim_)253 SpDComplex::SpDComplex( const dimension& dim_): BaseGDL(dim_) {}
~SpDComplex()254 SpDComplex::~SpDComplex() {}
255
SpDComplexDbl()256 SpDComplexDbl::SpDComplexDbl(): BaseGDL() {}
SpDComplexDbl(const dimension & dim_)257 SpDComplexDbl::SpDComplexDbl( const dimension& dim_): BaseGDL(dim_) {}
~SpDComplexDbl()258 SpDComplexDbl::~SpDComplexDbl() {}
259
260
261
262
263 /*
264
265 const bool SpDByte::IS_INTEGER=true;
266 const bool SpDByte::IS_SIGNED=false;
267 const bool SpDByte::IS_NUMERIC=true;
268 const bool SpDByte::IS_COMPLEX=false;
269 const bool SpDByte::IS_POD=true;
270 const bool SpDByte::IS_CONVERTABLE=true;
271
272 const bool SpDInt::IS_INTEGER=true;
273 const bool SpDInt::IS_SIGNED=true;
274 const bool SpDInt::IS_NUMERIC=true;
275 const bool SpDInt::IS_COMPLEX=false;
276 const bool SpDInt::IS_POD=true;
277 const bool SpDInt::IS_CONVERTABLE=true;
278
279 const bool SpDUInt::IS_INTEGER=true;
280 const bool SpDUInt::IS_SIGNED=false;
281 const bool SpDUInt::IS_NUMERIC=true;
282 const bool SpDUInt::IS_COMPLEX=false;
283
284 const bool SpDLong::IS_INTEGER=true;
285 const bool SpDLong::IS_SIGNED=true;
286 const bool SpDLong::IS_NUMERIC=true;
287 const bool SpDLong::IS_COMPLEX=false;
288
289 const bool SpDULong::IS_INTEGER=true;
290 const bool SpDULong::IS_SIGNED=false;
291 const bool SpDULong::IS_NUMERIC=true;
292 const bool SpDULong::IS_COMPLEX=false;
293
294 const bool SpDLong64::IS_INTEGER=true;
295 const bool SpDLong64::IS_SIGNED=true;
296 const bool SpDLong64::IS_NUMERIC=true;
297 const bool SpDLong64::IS_COMPLEX=false;
298
299 const bool SpDFloat::IS_INTEGER=false;
300 const bool SpDFloat::IS_SIGNED=true;
301 const bool SpDFloat::IS_NUMERIC=true;
302 const bool SpDFloat::IS_COMPLEX=false;
303
304 const bool SpDULong64::IS_INTEGER=true;
305 const bool SpDULong64::IS_SIGNED=false;
306 const bool SpDULong64::IS_NUMERIC=true;
307 const bool SpDULong64::IS_COMPLEX=false;
308
309 const bool SpDDouble::IS_INTEGER=false;
310 const bool SpDDouble::IS_SIGNED=true;
311 const bool SpDDouble::IS_NUMERIC=true;
312 const bool SpDDouble::IS_COMPLEX=false;
313
314 const bool SpDString::IS_INTEGER=false;
315 const bool SpDString::IS_SIGNED=false;
316 const bool SpDString::IS_NUMERIC=false;
317 const bool SpDString::IS_COMPLEX=false;
318
319 const bool SpDStruct::IS_INTEGER=false;
320 const bool SpDStruct::IS_SIGNED=false;
321 const bool SpDStruct::IS_NUMERIC=false;
322 const bool SpDStruct::IS_COMPLEX=false;
323
324 const bool SpDPtr::IS_INTEGER=false;
325 const bool SpDPtr::IS_SIGNED=false;
326 const bool SpDPtr::IS_NUMERIC=false;
327 const bool SpDPtr::IS_COMPLEX=false;
328
329 const bool SpDObj::IS_INTEGER=false;
330 const bool SpDObj::IS_SIGNED=false;
331 const bool SpDObj::IS_NUMERIC=false;
332 const bool SpDObj::IS_COMPLEX=false;
333
334 const bool SpDComplex::IS_INTEGER=false;
335 const bool SpDComplex::IS_SIGNED=true;
336 const bool SpDComplex::IS_NUMERIC=true;
337 const bool SpDComplex::IS_COMPLEX=true;
338
339 const bool SpDComplexDbl::IS_INTEGER=false;
340 const bool SpDComplexDbl::IS_SIGNED=true;
341 const bool SpDComplexDbl::IS_NUMERIC=true;
342 const bool SpDComplexDbl::IS_COMPLEX=true;
343
344
345 */
346