1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
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 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
65 #include "OSGStateChunk.h" // Chunks Class
67 #include "OSGChunkBlockBase.h"
68 #include "OSGChunkBlock.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::ChunkBlock
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var StateChunk * ChunkBlockBase::_mfChunks
91 /***************************************************************************\
92 * FieldType/FieldTrait Instantiation *
93 \***************************************************************************/
95 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
96 PointerType FieldTraits
<ChunkBlock
*, nsOSG
>::_type(
99 ChunkBlock::getClassType(),
103 OSG_FIELDTRAITS_GETTYPE_NS(ChunkBlock
*, nsOSG
)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void ChunkBlockBase::classDescInserter(TypeObject
&oType
)
119 FieldDescriptionBase
*pDesc
= NULL
;
122 pDesc
= new MFUnrecStateChunkPtr::Description(
123 MFUnrecStateChunkPtr::getClassType(),
126 ChunksFieldId
, ChunksFieldMask
,
128 (Field::MFDefaultFlags
| Field::FCustomAccess
),
129 static_cast<FieldEditMethodSig
>(&ChunkBlock::editHandleChunks
),
130 static_cast<FieldGetMethodSig
>(&ChunkBlock::getHandleChunks
));
132 oType
.addInitialDesc(pDesc
);
136 ChunkBlockBase::TypeObject
ChunkBlockBase::_type(
137 ChunkBlockBase::getClassname(),
138 Inherited::getClassname(),
141 reinterpret_cast<PrototypeCreateF
>(&ChunkBlockBase::createEmptyLocal
),
142 reinterpret_cast<InitContainerF
>(&ChunkBlock::initMethod
),
143 reinterpret_cast<ExitContainerF
>(&ChunkBlock::exitMethod
),
144 reinterpret_cast<InitalInsertDescFunc
>(
145 reinterpret_cast<void *>(&ChunkBlock::classDescInserter
)),
148 "<?xml version=\"1.0\"?>\n"
151 " name=\"ChunkBlock\"\n"
152 " parent=\"FieldContainer\"\n"
153 " library=\"System\"\n"
154 " pointerfieldtypes=\"both\"\n"
155 " structure=\"concrete\"\n"
156 " systemcomponent=\"true\"\n"
157 " parentsystemcomponent=\"true\"\n"
158 " isNodeCore=\"false\"\n"
162 " type=\"StateChunkPtr\"\n"
163 " cardinality=\"multi\"\n"
164 " visibility=\"external\"\n"
165 " access=\"protected\"\n"
166 " ptrFieldAccess = \"custom\"\n"
167 " pushToFieldAs=\"pushToChunks\"\n"
168 " replaceInMFieldIndexAs=\"replaceChunk\"\n"
171 "</FieldContainer>\n",
175 /*------------------------------ get -----------------------------------*/
177 FieldContainerType
&ChunkBlockBase::getType(void)
182 const FieldContainerType
&ChunkBlockBase::getType(void) const
187 UInt32
ChunkBlockBase::getContainerSize(void) const
189 return sizeof(ChunkBlock
);
192 /*------------------------- decorator get ------------------------------*/
195 //! Get the ChunkBlock::_mfChunks field.
196 const MFUnrecStateChunkPtr
*ChunkBlockBase::getMFChunks(void) const
200 StateChunk
* ChunkBlockBase::getChunks(const UInt32 index
) const
202 return _mfChunks
[index
];
210 /*------------------------------ access -----------------------------------*/
212 SizeT
ChunkBlockBase::getBinSize(ConstFieldMaskArg whichField
)
214 SizeT returnValue
= Inherited::getBinSize(whichField
);
216 if(FieldBits::NoField
!= (ChunksFieldMask
& whichField
))
218 returnValue
+= _mfChunks
.getBinSize();
224 void ChunkBlockBase::copyToBin(BinaryDataHandler
&pMem
,
225 ConstFieldMaskArg whichField
)
227 Inherited::copyToBin(pMem
, whichField
);
229 if(FieldBits::NoField
!= (ChunksFieldMask
& whichField
))
231 _mfChunks
.copyToBin(pMem
);
235 void ChunkBlockBase::copyFromBin(BinaryDataHandler
&pMem
,
236 ConstFieldMaskArg whichField
)
238 Inherited::copyFromBin(pMem
, whichField
);
240 if(FieldBits::NoField
!= (ChunksFieldMask
& whichField
))
242 editMField(ChunksFieldMask
, _mfChunks
);
243 _mfChunks
.copyFromBin(pMem
);
247 //! create a new instance of the class
248 ChunkBlockTransitPtr
ChunkBlockBase::createLocal(BitVector bFlags
)
250 ChunkBlockTransitPtr fc
;
252 if(getClassType().getPrototype() != NULL
)
254 FieldContainerTransitPtr tmpPtr
=
255 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
257 fc
= dynamic_pointer_cast
<ChunkBlock
>(tmpPtr
);
263 //! create a new instance of the class, copy the container flags
264 ChunkBlockTransitPtr
ChunkBlockBase::createDependent(BitVector bFlags
)
266 ChunkBlockTransitPtr fc
;
268 if(getClassType().getPrototype() != NULL
)
270 FieldContainerTransitPtr tmpPtr
=
271 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
273 fc
= dynamic_pointer_cast
<ChunkBlock
>(tmpPtr
);
279 //! create a new instance of the class
280 ChunkBlockTransitPtr
ChunkBlockBase::create(void)
282 ChunkBlockTransitPtr fc
;
284 if(getClassType().getPrototype() != NULL
)
286 FieldContainerTransitPtr tmpPtr
=
287 getClassType().getPrototype()-> shallowCopy();
289 fc
= dynamic_pointer_cast
<ChunkBlock
>(tmpPtr
);
295 ChunkBlock
*ChunkBlockBase::createEmptyLocal(BitVector bFlags
)
297 ChunkBlock
*returnValue
;
299 newPtr
<ChunkBlock
>(returnValue
, bFlags
);
301 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
306 //! create an empty new instance of the class, do not copy the prototype
307 ChunkBlock
*ChunkBlockBase::createEmpty(void)
309 ChunkBlock
*returnValue
;
311 newPtr
<ChunkBlock
>(returnValue
, Thread::getCurrentLocalFlags());
313 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
314 ~Thread::getCurrentLocalFlags();
320 FieldContainerTransitPtr
ChunkBlockBase::shallowCopyLocal(
321 BitVector bFlags
) const
325 newPtr(tmpPtr
, dynamic_cast<const ChunkBlock
*>(this), bFlags
);
327 FieldContainerTransitPtr
returnValue(tmpPtr
);
329 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
334 FieldContainerTransitPtr
ChunkBlockBase::shallowCopyDependent(
335 BitVector bFlags
) const
339 newPtr(tmpPtr
, dynamic_cast<const ChunkBlock
*>(this), ~bFlags
);
341 FieldContainerTransitPtr
returnValue(tmpPtr
);
343 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
348 FieldContainerTransitPtr
ChunkBlockBase::shallowCopy(void) const
353 dynamic_cast<const ChunkBlock
*>(this),
354 Thread::getCurrentLocalFlags());
356 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
358 FieldContainerTransitPtr
returnValue(tmpPtr
);
366 /*------------------------- constructors ----------------------------------*/
368 ChunkBlockBase::ChunkBlockBase(void) :
374 ChunkBlockBase::ChunkBlockBase(const ChunkBlockBase
&source
) :
381 /*-------------------------- destructors ----------------------------------*/
383 ChunkBlockBase::~ChunkBlockBase(void)
387 void ChunkBlockBase::onCreate(const ChunkBlock
*source
)
389 Inherited::onCreate(source
);
393 ChunkBlock
*pThis
= static_cast<ChunkBlock
*>(this);
395 MFUnrecStateChunkPtr::const_iterator ChunksIt
=
396 source
->_mfChunks
.begin();
397 MFUnrecStateChunkPtr::const_iterator ChunksEnd
=
398 source
->_mfChunks
.end ();
400 while(ChunksIt
!= ChunksEnd
)
402 pThis
->pushToChunks(*ChunksIt
);
409 GetFieldHandlePtr
ChunkBlockBase::getHandleChunks (void) const
411 MFUnrecStateChunkPtr::GetHandlePtr
returnValue(
412 new MFUnrecStateChunkPtr::GetHandle(
414 this->getType().getFieldDesc(ChunksFieldId
),
415 const_cast<ChunkBlockBase
*>(this)));
420 EditFieldHandlePtr
ChunkBlockBase::editHandleChunks (void)
422 MFUnrecStateChunkPtr::EditHandlePtr
returnValue(
423 new MFUnrecStateChunkPtr::EditHandle(
425 this->getType().getFieldDesc(ChunksFieldId
),
428 returnValue
->setAddMethod(
429 boost::bind(&ChunkBlock::pushToChunks
,
430 static_cast<ChunkBlock
*>(this), _1
));
431 returnValue
->setReplaceMethod(
432 boost::bind(&ChunkBlock::replaceChunk
,
433 static_cast<ChunkBlock
*>(this), _1
, _2
));
435 editMField(ChunksFieldMask
, _mfChunks
);
441 #ifdef OSG_MT_CPTR_ASPECT
442 void ChunkBlockBase::execSyncV( FieldContainer
&oFrom
,
443 ConstFieldMaskArg whichField
,
444 AspectOffsetStore
&oOffsets
,
445 ConstFieldMaskArg syncMode
,
446 const UInt32 uiSyncInfo
)
448 ChunkBlock
*pThis
= static_cast<ChunkBlock
*>(this);
450 pThis
->execSync(static_cast<ChunkBlock
*>(&oFrom
),
459 #ifdef OSG_MT_CPTR_ASPECT
460 FieldContainer
*ChunkBlockBase::createAspectCopy(
461 const FieldContainer
*pRefAspect
) const
463 ChunkBlock
*returnValue
;
465 newAspectCopy(returnValue
,
466 dynamic_cast<const ChunkBlock
*>(pRefAspect
),
467 dynamic_cast<const ChunkBlock
*>(this));
473 void ChunkBlockBase::resolveLinks(void)
475 Inherited::resolveLinks();
477 static_cast<ChunkBlock
*>(this)->clearChunks();