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 _OSGCHUNKBLOCKMAPFIELDS_H_
40 #define _OSGCHUNKBLOCKMAPFIELDS_H_
45 #include "OSGSystemDef.h"
46 #include "OSGSField.h"
47 #include "OSGFieldTraits.h"
48 #include "OSGContainerForwards.h"
49 #include "OSGRenderPropertiesPool.h"
57 /*! \ingroup GrpSystemStateFieldTraits
60 typedef RenderPropertiesPool::Singleton::ValueType ChunkBlockMapKey
;
62 /*! \ingroup GrpSystemStateFieldTraits
64 typedef std::map
<ChunkBlockMapKey
, ChunkBlock
*> ChunkBlockMap
;
66 #ifndef DOXYGEN_SHOULD_SKIP_THIS
67 /*! \ingroup GrpSystemStateFieldSFields
69 typedef SField
<ChunkBlockMapKey
> SFChunkBlockMapKey
;
71 /*! \ingroup GrpSystemStateFieldMFields
73 typedef MField
<ChunkBlockMapKey
> MFChunkBlockMapKey
;
75 /*! \ingroup GrpSystemStateFieldSFields \ingroup GrpLibOSGSystem
77 struct SFChunkBlockMapKey
: public SField
<ChunkBlockMapKey
> {};
79 /*! \ingroup GrpSystemStateFieldMFields \ingroup GrpLibOSGSystem
81 struct MFChunkBlockMapKey
: public MField
<ChunkBlockMapKey
> {};
84 /*! \ingroup GrpSystemStateFieldTraits
85 \ingroup GrpLibOSGSystem
89 struct FieldTraits
<ChunkBlockMap
> :
90 public FieldTraitsTemplateBase
<ChunkBlockMap
>
94 static DataType _type
;
98 typedef FieldTraits
<ChunkBlockMap
> Self
;
100 typedef RenderPropertiesPool KeyPool
;
102 enum { Convertible
= Self::NotConvertible
};
104 static OSG_SYSTEM_DLLMAPPING
105 DataType
&getType (void);
107 static const Char8
*getSName (void)
109 return "SFChunkBlockPtrMap";
112 static const Char8
*getMName (void)
114 return "MFChunkBlockPtrMap";
117 static OSG_SYSTEM_DLLMAPPING SizeT
getBinSize(const ChunkBlockMap
&aMap
);
119 static SizeT
getBinSize(const ChunkBlockMap
*aMaps
,
124 // defaut: individual field sizes
125 for(SizeT i
= 0; i
< numObjects
; ++i
)
127 size
+= getBinSize(aMaps
[i
]);
133 static OSG_SYSTEM_DLLMAPPING
void copyToBin( BinaryDataHandler
&pMem
,
134 const ChunkBlockMap
&aMap
);
136 static void copyToBin( BinaryDataHandler
&pMem
,
137 const ChunkBlockMap
*aMaps
,
140 for(SizeT i
= 0; i
< numObjects
; ++i
)
142 copyToBin(pMem
, aMaps
[i
]);
146 static OSG_SYSTEM_DLLMAPPING
void copyFromBin(BinaryDataHandler
&pMem
,
147 ChunkBlockMap
&aMap
);
149 static void copyFromBin(BinaryDataHandler
&pMem
,
150 ChunkBlockMap
*aMaps
,
153 for(SizeT i
= 0; i
< numObjects
; ++i
)
155 copyFromBin(pMem
, aMaps
[i
]);
160 #ifndef DOXYGEN_SHOULD_SKIP_THIS
161 /*! \ingroup GrpSystemStateFieldSFields
163 typedef SField
<ChunkBlockMap
> SFChunkBlockPtrMap
;
165 /*! \ingroup GrpSystemStateFieldSFields \ingroup GrpLibOSGSystem
167 struct SFChunkBlockPtrMap
: public SField
<ChunkBlockMap
> {};
170 /*! \ingroup GrpSystemStateFieldHandle
174 class OSG_SYSTEM_DLLMAPPING GetSFieldHandle
<SFChunkBlockPtrMap
> :
175 public GetMapFieldHandle
177 /*========================= PROTECTED ===============================*/
181 typedef GetMapFieldHandle Inherited
;
182 typedef GetFieldHandle Base
;
184 /*========================== PUBLIC =================================*/
188 typedef boost::shared_ptr
<GetSFieldHandle
> Ptr
;
189 typedef FieldTraits
<ChunkBlockMap
> MapFieldTraits
;
190 typedef MapFieldTraits::KeyPool KeyPool
;
191 typedef KeyPool::Singleton::ValueType KeyType
;
193 /*---------------------------------------------------------------------*/
195 GetSFieldHandle(const GetSFieldHandle
&source
);
196 GetSFieldHandle(const SFChunkBlockPtrMap
*pField
,
197 const FieldDescriptionBase
*pDescription
,
198 FieldContainer
*pContainer
);
200 /*---------------------------------------------------------------------*/
202 virtual const FieldType
&getType (void) const;
203 virtual bool isPointerField(void) const;
205 /*---------------------------------------------------------------------*/
207 virtual void traverse(TraverseCallback oCallBack
);
209 /*---------------------------------------------------------------------*/
211 virtual bool empty (void );
212 virtual void flatten(MapList
&vList
);
213 virtual void flatten(ContainerList
&vList
);
215 /*---------------------------------------------------------------------*/
217 virtual void pushValueToStream(OutStream
&str
) const;
218 virtual void pushSizeToStream (OutStream
&str
) const;
220 /*---------------------------------------------------------------------*/
222 virtual bool equal(Base::Ptr rhs
) const;
224 /*---------------------------------------------------------------------*/
226 SFChunkBlockPtrMap
const * operator ->(void);
227 SFChunkBlockPtrMap
const & operator * (void);
230 /*! \ingroup GrpSystemStateFieldHandle
234 class OSG_SYSTEM_DLLMAPPING
235 EditSFieldHandle
<SFChunkBlockPtrMap
> : public EditMapFieldHandle
237 /*=========================== PRIVATE ================================*/
241 void operator =(const EditSFieldHandle
&rhs
);
243 /*========================= PROTECTED ===============================*/
247 typedef EditMapFieldHandle Inherited
;
248 typedef EditFieldHandle Base
;
250 typedef boost::function
<void(ChunkBlock
* const,
251 ChunkBlockMapKey
)> AddMethod
;
253 /*========================== PUBLIC =================================*/
255 FieldContainer
*_pContainer
;
256 AddMethod _fAddMethod
;
260 typedef boost::shared_ptr
<EditSFieldHandle
> Ptr
;
261 typedef FieldTraits
<ChunkBlockMap
> MapFieldTraits
;
262 typedef MapFieldTraits::KeyPool KeyPool
;
263 typedef KeyPool::Singleton::ValueType KeyType
;
265 /*---------------------------------------------------------------------*/
267 EditSFieldHandle(const EditSFieldHandle
&source
);
268 EditSFieldHandle( SFChunkBlockPtrMap
*pField
,
269 const FieldDescriptionBase
*pDescription
,
270 FieldContainer
*pContainer
);
272 /*---------------------------------------------------------------------*/
274 virtual const FieldType
&getType (void) const;
275 virtual bool isPointerField(void) const;
277 /*---------------------------------------------------------------------*/
279 virtual void add( FieldContainer
*rhs
,
280 const std::string
&szBindings
);
282 /*---------------------------------------------------------------------*/
284 virtual void traverse(TraverseCallback oCallBack
);
286 /*---------------------------------------------------------------------*/
288 virtual bool empty (void );
289 virtual void flatten(MapList
&vList
);
290 virtual void flatten(ContainerList
&vList
);
292 /*---------------------------------------------------------------------*/
294 virtual bool loadFromBin( BinaryDataHandler
*pMem
,
295 UInt32 uiNumElements
,
297 std::vector
<UInt16
> &vBindings
,
298 std::vector
<UInt32
> &vIds
);
300 virtual void fillFrom (const std::vector
<UInt16
> &vBindings
,
301 const std::vector
<UInt32
> &vIds
,
302 const std::map
<UInt32
, UInt32
> &vIdMap
);
304 /*---------------------------------------------------------------------*/
306 virtual void pushValueToStream(OutStream
&str
) const;
307 virtual void pushSizeToStream (OutStream
&str
) const;
309 /*---------------------------------------------------------------------*/
311 void setAddMethod(AddMethod fMethod
);
313 virtual bool equal (Base::Ptr rhs
) const;
315 /*---------------------------------------------------------------------*/
317 virtual void pushValueFromCString(const Char8
*str
);
319 virtual void copyValues ( GetFieldHandlePtr source
) const;
320 virtual void shareValues ( GetFieldHandlePtr source
) const;
322 /*---------------------------------------------------------------------*/
324 virtual void cloneValues(
325 GetFieldHandlePtr pSrc
,
326 const TypePtrVector
&shareTypes
= TypePtrVector(),
327 const TypePtrVector
&ignoreTypes
= TypePtrVector(),
328 const TypeIdVector
&shareGroupIds
= TypeIdVector (),
329 const TypeIdVector
&ignoreGroupIds
= TypeIdVector ()) const;
335 #include "OSGChunkBlockMapFields.inl"
337 #endif /* _OSGCHUNKBLOCKMAPFIELDS_H_ */