changed: gcc8 base update
[opensg.git] / Source / Base / FieldContainer / Fields / OSGFieldContainerFieldTraits.h
blob274261c0a56a95b8b94cd0a3698f9c5dfa39b457
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 _OSGFIELDCONTAINERFIELDTRAITS_H_
40 #define _OSGFIELDCONTAINERFIELDTRAITS_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGFieldTraits.h"
46 #include "OSGDataType.h"
48 #include "OSGContainerForwards.h"
49 #include "OSGFieldContainerFactory.h"
50 #include "OSGFieldContainer.h"
51 #include "OSGBaseRefCountPoliciesFwd.h"
52 #include "OSGContainerRefCountPoliciesFwd.h"
54 OSG_BEGIN_NAMESPACE
57 /*! \ingroup GrpBaseFieldContainerFieldTraits
58 \ingroup GrpLibOSGBase
61 template<class ValueT, Int32 iNamespace = 0>
62 struct FieldTraitsFCPtrBase :
63 public FieldTraitsTemplateBase<ValueT, iNamespace>
65 static const bool bIsPointerField = true;
67 static const Char8 *getSPName(void)
69 return "FieldContainerPtrSFieldBase";
72 static const Char8 *getMPName(void)
74 return "FieldContainerPtrMFieldBase";
77 static SizeT getBinSize(FieldContainer * const &)
79 return sizeof(UInt32);
82 static SizeT getBinSize(FieldContainer * const *,
83 SizeT uiNumObjects)
85 return sizeof(UInt32) * uiNumObjects;
88 static void copyToBin(BinaryDataHandler &pMem,
89 FieldContainer * const &pObject)
91 UInt32 containerId;
93 if(pObject == NULL)
95 // containerId=0 indicates an Null Ptr
96 containerId = 0;
98 else
100 containerId = pObject->getId();
103 pMem.putValue(containerId);
106 static void copyToBin(BinaryDataHandler &pMem,
107 FieldContainer * const *pObjectStore,
108 SizeT uiNumObjects)
110 for(SizeT i = 0; i < uiNumObjects; i++)
112 copyToBin(pMem, pObjectStore[i]);
116 static void copyFromBin(BinaryDataHandler &pMem,
117 FieldContainer *&pObject)
119 UInt32 containerId;
121 pMem.getValue(containerId);
123 if(0 != containerId)
125 pObject =
126 FieldContainerFactory::the()->getMappedContainer(containerId);
128 else
130 pObject = NULL;
134 static void copyFromBin(BinaryDataHandler & pMem,
135 FieldContainer **pObjectStore,
136 SizeT uiNumObjects)
138 for(SizeT i = 0; i < uiNumObjects; i++)
140 copyFromBin(pMem, pObjectStore[i]);
146 /*! \ingroup GrpBaseFieldContainerFieldTraits
147 \ingroup GrpLibOSGBase
150 template <>
151 struct FieldTraits<FieldContainer *> :
152 public FieldTraitsFCPtrBase<FieldContainer *>
154 private:
156 static PointerType _type;
157 static DataType _mapType;
159 public:
161 static const bool bIsPointerField = true;
163 typedef FieldTraits<FieldContainer *> Self;
166 enum { Convertible = Self::NotConvertible };
168 static OSG_BASE_DLLMAPPING
169 DataType &getType (void);
170 static OSG_BASE_DLLMAPPING
171 DataType &getMapType (void);
173 template<typename RefCountPolicy> inline
174 static const Char8 *getSName(void);
176 template<typename RefCountPolicy> inline
177 static const Char8 *getMName(void);
181 template<> inline
182 const Char8 *FieldTraits<FieldContainer *,
183 0 >::getSName<RecordedRefCountPolicy>(
184 void)
186 return "SFRecFieldContainerPtr";
189 template<> inline
190 const Char8 *FieldTraits<FieldContainer *,
191 0 >::getSName<UnrecordedRefCountPolicy>(
192 void)
194 return "SFUnrecFieldContainerPtr";
197 template<> inline
198 const Char8 *FieldTraits<FieldContainer *,
199 0 >::getSName<WeakRefCountPolicy>(void)
201 return "SFWeakFieldContainerPtr";
204 template<> inline
205 const Char8 *FieldTraits<FieldContainer *,
206 0 >::getSName<NoRefCountPolicy>(void)
208 return "SFUnrefdFieldContainerPtr";
213 template<> inline
214 const Char8 *FieldTraits<FieldContainer *,
215 0 >::getMName<RecordedRefCountPolicy>(
216 void)
218 return "MFRecFieldContainerPtr";
221 template<> inline
222 const Char8 *FieldTraits<FieldContainer *,
223 0 >::getMName<UnrecordedRefCountPolicy>(
224 void)
226 return "MFUnrecFieldContainerPtr";
229 template<> inline
230 const Char8 *FieldTraits<FieldContainer *,
231 0 >::getMName<WeakRefCountPolicy>(void)
233 return "MFWeakFieldContainerPtr";
236 template<> inline
237 const Char8 *FieldTraits<FieldContainer *,
238 0 >::getMName<NoRefCountPolicy>(void)
240 return "MFUnrefdFieldContainerPtr";
244 /*! \ingroup GrpBaseFieldContainerFieldTraits
245 \ingroup GrpLibOSGBase
248 template <>
249 struct FieldTraits<FieldContainer *, 1> :
250 public FieldTraitsFCPtrBase<FieldContainer *, 1>
252 private:
254 // static DataType _type;
256 public:
258 static const bool bIsPointerField = true;
260 typedef FieldTraits<FieldContainer *, 1> Self;
263 enum { Convertible = Self::NotConvertible };
265 static OSG_BASE_DLLMAPPING
266 DataType &getType (void);
268 static const Char8 *getSName(void)
270 return "SFParentFieldContainerPtr";
273 static const Char8 *getMName(void)
275 return "MFParentFieldContainerPtr";
279 OSG_END_NAMESPACE
281 #endif /* _OSGFIELDCONTAINERFIELDTRAITS_H_ */