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 _OSGFIELDCONTAINERFIELDTRAITS_H_
40 #define _OSGFIELDCONTAINERFIELDTRAITS_H_
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"
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 *,
85 return sizeof(UInt32
) * uiNumObjects
;
88 static void copyToBin(BinaryDataHandler
&pMem
,
89 FieldContainer
* const &pObject
)
95 // containerId=0 indicates an Null Ptr
100 containerId
= pObject
->getId();
103 pMem
.putValue(containerId
);
106 static void copyToBin(BinaryDataHandler
&pMem
,
107 FieldContainer
* const *pObjectStore
,
110 for(SizeT i
= 0; i
< uiNumObjects
; i
++)
112 copyToBin(pMem
, pObjectStore
[i
]);
116 static void copyFromBin(BinaryDataHandler
&pMem
,
117 FieldContainer
*&pObject
)
121 pMem
.getValue(containerId
);
126 FieldContainerFactory::the()->getMappedContainer(containerId
);
134 static void copyFromBin(BinaryDataHandler
& pMem
,
135 FieldContainer
**pObjectStore
,
138 for(SizeT i
= 0; i
< uiNumObjects
; i
++)
140 copyFromBin(pMem
, pObjectStore
[i
]);
146 /*! \ingroup GrpBaseFieldContainerFieldTraits
147 \ingroup GrpLibOSGBase
151 struct FieldTraits
<FieldContainer
*> :
152 public FieldTraitsFCPtrBase
<FieldContainer
*>
156 static PointerType _type
;
157 static DataType _mapType
;
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);
182 const Char8
*FieldTraits
<FieldContainer
*,
183 0 >::getSName
<RecordedRefCountPolicy
>(
186 return "SFRecFieldContainerPtr";
190 const Char8
*FieldTraits
<FieldContainer
*,
191 0 >::getSName
<UnrecordedRefCountPolicy
>(
194 return "SFUnrecFieldContainerPtr";
198 const Char8
*FieldTraits
<FieldContainer
*,
199 0 >::getSName
<WeakRefCountPolicy
>(void)
201 return "SFWeakFieldContainerPtr";
205 const Char8
*FieldTraits
<FieldContainer
*,
206 0 >::getSName
<NoRefCountPolicy
>(void)
208 return "SFUnrefdFieldContainerPtr";
214 const Char8
*FieldTraits
<FieldContainer
*,
215 0 >::getMName
<RecordedRefCountPolicy
>(
218 return "MFRecFieldContainerPtr";
222 const Char8
*FieldTraits
<FieldContainer
*,
223 0 >::getMName
<UnrecordedRefCountPolicy
>(
226 return "MFUnrecFieldContainerPtr";
230 const Char8
*FieldTraits
<FieldContainer
*,
231 0 >::getMName
<WeakRefCountPolicy
>(void)
233 return "MFWeakFieldContainerPtr";
237 const Char8
*FieldTraits
<FieldContainer
*,
238 0 >::getMName
<NoRefCountPolicy
>(void)
240 return "MFUnrefdFieldContainerPtr";
244 /*! \ingroup GrpBaseFieldContainerFieldTraits
245 \ingroup GrpLibOSGBase
249 struct FieldTraits
<FieldContainer
*, 1> :
250 public FieldTraitsFCPtrBase
<FieldContainer
*, 1>
254 // static DataType _type;
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";
281 #endif /* _OSGFIELDCONTAINERFIELDTRAITS_H_ */