changed: gcc8 base update
[opensg.git] / Source / System / State / Base / OSGChunkBlockBase.cpp
blobc3b866687ee36e3fcd43a1329783adcfb4842cb3
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
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 /*****************************************************************************\
40 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class ChunkBlock!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
65 #include "OSGStateChunk.h" // Chunks Class
67 #include "OSGChunkBlockBase.h"
68 #include "OSGChunkBlock.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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(
97 "ChunkBlockPtr",
98 "FieldContainerPtr",
99 ChunkBlock::getClassType(),
100 nsOSG);
101 #endif
103 OSG_FIELDTRAITS_GETTYPE_NS(ChunkBlock *, nsOSG)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
106 ChunkBlock *,
107 nsOSG)
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
110 ChunkBlock *,
111 nsOSG)
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void ChunkBlockBase::classDescInserter(TypeObject &oType)
119 FieldDescriptionBase *pDesc = NULL;
122 pDesc = new MFUnrecStateChunkPtr::Description(
123 MFUnrecStateChunkPtr::getClassType(),
124 "chunks",
126 ChunksFieldId, ChunksFieldMask,
127 false,
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(),
139 "NULL",
140 nsOSG, //Namespace
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)),
146 false,
148 "<?xml version=\"1.0\"?>\n"
149 "\n"
150 "<FieldContainer\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"
159 " >\n"
160 " <Field\n"
161 " name=\"chunks\"\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"
169 " >\n"
170 " </Field>\n"
171 "</FieldContainer>\n",
175 /*------------------------------ get -----------------------------------*/
177 FieldContainerType &ChunkBlockBase::getType(void)
179 return _type;
182 const FieldContainerType &ChunkBlockBase::getType(void) const
184 return _type;
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
198 return &_mfChunks;
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();
221 return returnValue;
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);
260 return fc;
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);
276 return fc;
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);
292 return fc;
295 ChunkBlock *ChunkBlockBase::createEmptyLocal(BitVector bFlags)
297 ChunkBlock *returnValue;
299 newPtr<ChunkBlock>(returnValue, bFlags);
301 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
303 return returnValue;
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();
316 return returnValue;
320 FieldContainerTransitPtr ChunkBlockBase::shallowCopyLocal(
321 BitVector bFlags) const
323 ChunkBlock *tmpPtr;
325 newPtr(tmpPtr, dynamic_cast<const ChunkBlock *>(this), bFlags);
327 FieldContainerTransitPtr returnValue(tmpPtr);
329 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
331 return returnValue;
334 FieldContainerTransitPtr ChunkBlockBase::shallowCopyDependent(
335 BitVector bFlags) const
337 ChunkBlock *tmpPtr;
339 newPtr(tmpPtr, dynamic_cast<const ChunkBlock *>(this), ~bFlags);
341 FieldContainerTransitPtr returnValue(tmpPtr);
343 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
345 return returnValue;
348 FieldContainerTransitPtr ChunkBlockBase::shallowCopy(void) const
350 ChunkBlock *tmpPtr;
352 newPtr(tmpPtr,
353 dynamic_cast<const ChunkBlock *>(this),
354 Thread::getCurrentLocalFlags());
356 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
358 FieldContainerTransitPtr returnValue(tmpPtr);
360 return returnValue;
366 /*------------------------- constructors ----------------------------------*/
368 ChunkBlockBase::ChunkBlockBase(void) :
369 Inherited(),
370 _mfChunks ()
374 ChunkBlockBase::ChunkBlockBase(const ChunkBlockBase &source) :
375 Inherited(source),
376 _mfChunks ()
381 /*-------------------------- destructors ----------------------------------*/
383 ChunkBlockBase::~ChunkBlockBase(void)
387 void ChunkBlockBase::onCreate(const ChunkBlock *source)
389 Inherited::onCreate(source);
391 if(source != NULL)
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);
404 ++ChunksIt;
409 GetFieldHandlePtr ChunkBlockBase::getHandleChunks (void) const
411 MFUnrecStateChunkPtr::GetHandlePtr returnValue(
412 new MFUnrecStateChunkPtr::GetHandle(
413 &_mfChunks,
414 this->getType().getFieldDesc(ChunksFieldId),
415 const_cast<ChunkBlockBase *>(this)));
417 return returnValue;
420 EditFieldHandlePtr ChunkBlockBase::editHandleChunks (void)
422 MFUnrecStateChunkPtr::EditHandlePtr returnValue(
423 new MFUnrecStateChunkPtr::EditHandle(
424 &_mfChunks,
425 this->getType().getFieldDesc(ChunksFieldId),
426 this));
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);
437 return returnValue;
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),
451 whichField,
452 oOffsets,
453 syncMode,
454 uiSyncInfo);
456 #endif
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));
469 return returnValue;
471 #endif
473 void ChunkBlockBase::resolveLinks(void)
475 Inherited::resolveLinks();
477 static_cast<ChunkBlock *>(this)->clearChunks();
483 OSG_END_NAMESPACE