1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2003 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGSYSFIELDTRAITS_H_
40 #define _OSGSYSFIELDTRAITS_H_
45 #include "OSGFieldTraits.h"
46 #include "OSGDataType.h"
51 /*! \ingroup GrpBaseFieldTraits
52 \ingroup GrpLibOSGBase
56 struct FieldTraits
<bool, 2> : public FieldTraitsPODTemplateBase
<bool, 2>
60 static DataType _type
;
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 &)
84 static void copyToBin ( BinaryDataHandler
&pMem
,
91 static void copyFromBin( BinaryDataHandler
&pMem
,
99 static void putToStream(const bool &val
,
114 /*! \ingroup GrpBaseFieldTraits
115 \ingroup GrpLibOSGBase
119 struct FieldTraits
<Int8
> : public FieldTraitsPODTemplateBase
<Int8
>
123 static DataType _type
;
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
147 struct FieldTraits
<UInt8
> : public FieldTraitsPODTemplateBase
<UInt8
>
151 static DataType _type
;
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
176 struct FieldTraits
<Int16
> : public FieldTraitsPODTemplateBase
<Int16
>
180 static DataType _type
;
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
205 struct FieldTraits
<UInt16
> : public FieldTraitsPODTemplateBase
<UInt16
>
209 static DataType _type
;
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
234 struct FieldTraits
<Int32
> : public FieldTraitsPODTemplateBase
<Int32
>
238 static DataType _type
;
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
263 struct FieldTraits
<UInt32
> : public FieldTraitsPODTemplateBase
<UInt32
>
267 static DataType _type
;
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
292 struct FieldTraits
<Int64
> : public FieldTraitsPODTemplateBase
<Int64
>
296 static DataType _type
;
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
320 struct FieldTraits
<UInt64
> : public FieldTraitsPODTemplateBase
<UInt64
>
324 static DataType _type
;
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
348 struct FieldTraits
<Real16
> : public FieldTraitsPODTemplateBase
<Real16
>
352 static DataType _type
;
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
376 struct FieldTraits
<Real32
> : public FieldTraitsPODTemplateBase
<Real32
>
380 static DataType _type
;
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
404 struct FieldTraits
<Fixed32
> : public FieldTraitsPODTemplateBase
<Fixed32
>
408 static DataType _type
;
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
432 struct FieldTraits
<Real64
> : public FieldTraitsPODTemplateBase
<Real64
>
436 static DataType _type
;
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
461 struct FieldTraits
<void *> : public FieldTraitsPODTemplateBase
<void *>
465 static DataType _type
;
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
; }
485 // TODO Is it correct to just ignore these for binary ??
487 static SizeT
getBinSize(void * const &)
492 static SizeT
getBinSize(void * const *,
498 static void copyToBin(BinaryDataHandler
&,
503 static void copyToBin(BinaryDataHandler
&,
509 static void copyFromBin(BinaryDataHandler
&,
514 static void copyFromBin(BinaryDataHandler
&,
523 #endif /* _OSGSYSFIELDTRAITS_H_ */