fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / Field / OSGSysFieldTraits.h
blobc6429172c0195ae8d14f550cd733c6725bdf00a8
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2003 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSYSFIELDTRAITS_H_
40 #define _OSGSYSFIELDTRAITS_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGFieldTraits.h"
46 #include "OSGDataType.h"
48 OSG_BEGIN_NAMESPACE
51 /*! \ingroup GrpBaseFieldTraits
52 \ingroup GrpLibOSGBase
55 template <>
56 struct FieldTraits<bool, 2> : public FieldTraitsPODTemplateBase<bool, 2>
58 private:
60 static DataType _type;
62 public:
64 typedef FieldTraits<bool, 2> Self;
67 enum { Convertible = (Self::ToStreamConvertible |
68 Self::FromStringConvertible) };
70 static OSG_BASE_DLLMAPPING
71 DataType &getType (void);
73 static const Char8 *getSName (void) { return "SFBool"; }
74 static const Char8 *getMName (void) { return "MFBool"; }
76 static bool getDefault (void) { return false; }
79 static SizeT getBinSize (const bool &)
81 return sizeof(UInt8);
84 static void copyToBin ( BinaryDataHandler &pMem,
85 const bool &oObject)
87 UInt8 value=oObject;
88 pMem.putValue(value);
91 static void copyFromBin( BinaryDataHandler &pMem,
92 bool &oObject)
94 UInt8 value;
95 pMem.getValue(value);
96 oObject=(value != 0);
99 static void putToStream(const bool &val,
100 OutStream &str)
102 if(val == true)
104 str << "TRUE";
106 else
108 str << "FALSE";
114 /*! \ingroup GrpBaseFieldTraits
115 \ingroup GrpLibOSGBase
118 template <>
119 struct FieldTraits<Int8> : public FieldTraitsPODTemplateBase<Int8>
121 private:
123 static DataType _type;
125 public:
127 typedef FieldTraits<Int8> Self;
129 enum { Convertible = (Self::ToStreamConvertible |
130 Self::FromStringConvertible)};
132 static OSG_BASE_DLLMAPPING
133 DataType &getType (void);
135 static const Char8 *getSName (void) { return "SFInt8"; }
136 static const Char8 *getMName (void) { return "MFInt8"; }
138 static Int8 getDefault (void) { return 0; }
142 /*! \ingroup GrpBaseFieldTraits
143 \ingroup GrpLibOSGBase
146 template <>
147 struct FieldTraits<UInt8> : public FieldTraitsPODTemplateBase<UInt8>
149 private:
151 static DataType _type;
153 public:
155 typedef FieldTraits<UInt8> Self;
157 enum { Convertible = (Self::ToStreamConvertible |
158 Self::FromStringConvertible) };
160 static OSG_BASE_DLLMAPPING
161 DataType &getType (void);
163 static const Char8 *getSName (void) { return "SFUInt8"; }
164 static const Char8 *getMName (void) { return "MFUInt8"; }
166 static UInt8 getDefault (void) { return 0; }
171 /*! \ingroup GrpBaseFieldTraits
172 \ingroup GrpLibOSGBase
175 template <>
176 struct FieldTraits<Int16> : public FieldTraitsPODTemplateBase<Int16>
178 private:
180 static DataType _type;
182 public:
184 typedef FieldTraits<Int16> Self;
186 enum { Convertible = (Self::ToStreamConvertible |
187 Self::FromStringConvertible) };
189 static OSG_BASE_DLLMAPPING
190 DataType &getType (void);
192 static const Char8 *getSName (void) { return "SFInt16"; }
193 static const Char8 *getMName (void) { return "MFInt16"; }
195 static Int16 getDefault (void) { return 0; }
200 /*! \ingroup GrpBaseFieldTraits
201 \ingroup GrpLibOSGBase
204 template <>
205 struct FieldTraits<UInt16> : public FieldTraitsPODTemplateBase<UInt16>
207 private:
209 static DataType _type;
211 public:
213 typedef FieldTraits<UInt16> Self;
215 enum { Convertible = (Self::ToStreamConvertible |
216 Self::FromStringConvertible) };
218 static OSG_BASE_DLLMAPPING
219 DataType &getType (void);
221 static const Char8 *getSName (void) { return "SFUInt16"; }
222 static const Char8 *getMName (void) { return "MFUInt16"; }
224 static UInt16 getDefault (void) { return 0; }
229 /*! \ingroup GrpBaseFieldTraits
230 \ingroup GrpLibOSGBase
233 template <>
234 struct FieldTraits<Int32> : public FieldTraitsPODTemplateBase<Int32>
236 private:
238 static DataType _type;
240 public:
242 typedef FieldTraits<Int32> Self;
244 enum { Convertible = (Self::ToStreamConvertible |
245 Self::FromStringConvertible) };
247 static OSG_BASE_DLLMAPPING
248 DataType &getType (void);
250 static const Char8 *getSName (void) { return "SFInt32"; }
251 static const Char8 *getMName (void) { return "MFInt32"; }
253 static Int32 getDefault (void) { return 0; }
258 /*! \ingroup GrpBaseFieldTraits
259 \ingroup GrpLibOSGBase
262 template <>
263 struct FieldTraits<UInt32> : public FieldTraitsPODTemplateBase<UInt32>
265 private:
267 static DataType _type;
269 public:
271 typedef FieldTraits<UInt32> Self;
273 enum { Convertible = (Self::ToStreamConvertible |
274 Self::FromStringConvertible) };
276 static OSG_BASE_DLLMAPPING
277 DataType &getType (void);
279 static const Char8 *getSName (void) { return "SFUInt32"; }
280 static const Char8 *getMName (void) { return "MFUInt32"; }
282 static UInt32 getDefault (void) { return 0; }
287 /*! \ingroup GrpBaseFieldTraits
288 \ingroup GrpLibOSGBase
291 template <>
292 struct FieldTraits<Int64> : public FieldTraitsPODTemplateBase<Int64>
294 private:
296 static DataType _type;
298 public:
300 typedef FieldTraits<Int64> Self;
302 enum { Convertible = (Self::ToStreamConvertible |
303 Self::FromStringConvertible) };
305 static OSG_BASE_DLLMAPPING
306 DataType &getType (void);
308 static const Char8 *getSName (void) { return "SFInt64"; }
309 static const Char8 *getMName (void) { return "MFInt64"; }
311 static Int64 getDefault (void) { return 0; }
315 /*! \ingroup GrpBaseFieldTraits
316 \ingroup GrpLibOSGBase
319 template <>
320 struct FieldTraits<UInt64> : public FieldTraitsPODTemplateBase<UInt64>
322 private:
324 static DataType _type;
326 public:
328 typedef FieldTraits<UInt64> Self;
330 enum { Convertible = (Self::ToStreamConvertible |
331 Self::FromStringConvertible) };
333 static OSG_BASE_DLLMAPPING
334 DataType &getType (void);
336 static const Char8 *getSName (void) { return "SFUInt64"; }
337 static const Char8 *getMName (void) { return "MFUInt64"; }
339 static UInt64 getDefault (void) { return 0; }
343 /*! \ingroup GrpBaseFieldTraits
344 \ingroup GrpLibOSGBase
347 template <>
348 struct FieldTraits<Real16> : public FieldTraitsPODTemplateBase<Real16>
350 private:
352 static DataType _type;
354 public:
356 typedef FieldTraits<Real16> Self;
358 enum { Convertible = (Self::ToStreamConvertible |
359 Self::FromStringConvertible) };
361 static OSG_BASE_DLLMAPPING
362 DataType &getType (void);
364 static const Char8 *getSName (void) { return "SFReal16"; }
365 static const Char8 *getMName (void) { return "MFReal16"; }
367 static Real32 getDefault (void) { return 0.f; }
371 /*! \ingroup GrpBaseFieldTraits
372 \ingroup GrpLibOSGBase
375 template <>
376 struct FieldTraits<Real32> : public FieldTraitsPODTemplateBase<Real32>
378 private:
380 static DataType _type;
382 public:
384 typedef FieldTraits<Real32> Self;
386 enum { Convertible = (Self::ToStreamConvertible |
387 Self::FromStringConvertible) };
389 static OSG_BASE_DLLMAPPING
390 DataType &getType (void);
392 static const Char8 *getSName (void) { return "SFReal32"; }
393 static const Char8 *getMName (void) { return "MFReal32"; }
395 static Real32 getDefault (void) { return 0.f; }
399 /*! \ingroup GrpBaseFieldTraits
400 \ingroup GrpLibOSGBase
403 template <>
404 struct FieldTraits<Fixed32> : public FieldTraitsPODTemplateBase<Fixed32>
406 private:
408 static DataType _type;
410 public:
412 typedef FieldTraits<Fixed32> Self;
414 enum { Convertible = (Self::ToStreamConvertible |
415 Self::FromStringConvertible) };
417 static OSG_BASE_DLLMAPPING
418 DataType &getType (void);
420 static const Char8 *getSName (void) { return "SFFixed32"; }
421 static const Char8 *getMName (void) { return "MFFixed32"; }
423 static Fixed32 getDefault (void) { return Fixed32(0.f); }
427 /*! \ingroup GrpBaseFieldTraits
428 \ingroup GrpLibOSGBase
431 template <>
432 struct FieldTraits<Real64> : public FieldTraitsPODTemplateBase<Real64>
434 private:
436 static DataType _type;
438 public:
440 typedef FieldTraits<Real64> Self;
442 enum { Convertible = (Self::ToStreamConvertible |
443 Self::FromStringConvertible) };
445 static OSG_BASE_DLLMAPPING
446 DataType &getType (void);
448 static const Char8 *getSName (void) { return "SFReal64"; }
449 static const Char8 *getMName (void) { return "MFReal64"; }
451 static Real64 getDefault (void) { return 0.; }
456 /*! \ingroup GrpBaseFieldTraits
457 \ingroup GrpLibOSGBase
460 template <>
461 struct FieldTraits<void *> : public FieldTraitsPODTemplateBase<void *>
463 private:
465 static DataType _type;
467 public:
469 typedef FieldTraits<void *> Self;
470 typedef void * ArgumentType;
471 typedef void * FieldTypeT;
473 enum { Convertible = Self::NotConvertible };
475 static OSG_BASE_DLLMAPPING
476 DataType &getType (void);
478 static const Char8 *getSName (void) { return "SFVoidP"; }
479 static const Char8 *getMName (void) { return "MFVoidP"; }
481 static void *getDefault (void) { return NULL; }
483 // Binary
485 // TODO Is it correct to just ignore these for binary ??
487 static SizeT getBinSize(void * const &)
489 return 0;
492 static SizeT getBinSize(void * const *,
493 SizeT )
495 return 0;
498 static void copyToBin(BinaryDataHandler &,
499 void * const & )
503 static void copyToBin(BinaryDataHandler &,
504 void * const *,
505 SizeT )
509 static void copyFromBin(BinaryDataHandler &,
510 void * const & )
514 static void copyFromBin(BinaryDataHandler &,
515 void * const *,
516 SizeT )
521 OSG_END_NAMESPACE
523 #endif /* _OSGSYSFIELDTRAITS_H_ */