changed: gcc8 base update
[opensg.git] / Source / System / Material / Base / OSGChunkMaterialBase.cpp
blob0d9eeb5e5e34fb45cabd9c5b08bd8702606c81e5
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 ChunkMaterial!
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 "OSGChunkMaterialBase.h"
68 #include "OSGChunkMaterial.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::ChunkMaterial
79 The chunk material class. See \ref PageSystemMaterialChunkMaterial for a
80 description.
82 Chunks can be attached and detached from the material using
83 OSG::ChunkMaterial::addChunk() and OSG::ChunkMaterial::subChunk(). For more
84 complex manipulation of the chunk list use the OSG::ChunkMaterial::_mfChunks
85 field's functions.
88 /***************************************************************************\
89 * Field Documentation *
90 \***************************************************************************/
92 /*! \var StateChunk * ChunkMaterialBase::_mfChunks
96 /*! \var Int32 ChunkMaterialBase::_mfSlots
101 /***************************************************************************\
102 * FieldType/FieldTrait Instantiation *
103 \***************************************************************************/
105 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
106 PointerType FieldTraits<ChunkMaterial *, nsOSG>::_type(
107 "ChunkMaterialPtr",
108 "PrimeMaterialPtr",
109 ChunkMaterial::getClassType(),
110 nsOSG);
111 #endif
113 OSG_FIELDTRAITS_GETTYPE_NS(ChunkMaterial *, nsOSG)
115 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
116 ChunkMaterial *,
117 nsOSG)
119 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
120 ChunkMaterial *,
121 nsOSG)
123 /***************************************************************************\
124 * Field Description *
125 \***************************************************************************/
127 void ChunkMaterialBase::classDescInserter(TypeObject &oType)
129 FieldDescriptionBase *pDesc = NULL;
132 pDesc = new MFUnrecStateChunkPtr::Description(
133 MFUnrecStateChunkPtr::getClassType(),
134 "chunks",
136 ChunksFieldId, ChunksFieldMask,
137 false,
138 (Field::MFDefaultFlags | Field::FCustomAccess),
139 static_cast<FieldEditMethodSig>(&ChunkMaterial::editHandleChunks),
140 static_cast<FieldGetMethodSig >(&ChunkMaterial::getHandleChunks));
142 oType.addInitialDesc(pDesc);
144 pDesc = new MFInt32::Description(
145 MFInt32::getClassType(),
146 "slots",
148 SlotsFieldId, SlotsFieldMask,
149 false,
150 (Field::MFDefaultFlags | Field::FStdAccess),
151 static_cast<FieldEditMethodSig>(&ChunkMaterial::editHandleSlots),
152 static_cast<FieldGetMethodSig >(&ChunkMaterial::getHandleSlots));
154 oType.addInitialDesc(pDesc);
158 ChunkMaterialBase::TypeObject ChunkMaterialBase::_type(
159 ChunkMaterialBase::getClassname(),
160 Inherited::getClassname(),
161 "NULL",
162 nsOSG, //Namespace
163 reinterpret_cast<PrototypeCreateF>(&ChunkMaterialBase::createEmptyLocal),
164 reinterpret_cast<InitContainerF>(&ChunkMaterial::initMethod),
165 reinterpret_cast<ExitContainerF>(&ChunkMaterial::exitMethod),
166 reinterpret_cast<InitalInsertDescFunc>(
167 reinterpret_cast<void *>(&ChunkMaterial::classDescInserter)),
168 false,
170 "<?xml version=\"1.0\"?>\n"
171 "\n"
172 "<FieldContainer\n"
173 " name=\"ChunkMaterial\"\n"
174 " parent=\"PrimeMaterial\"\n"
175 " library=\"System\"\n"
176 " structure=\"concrete\"\n"
177 " pointerfieldtypes=\"both\"\n"
178 " systemcomponent=\"true\"\n"
179 " parentsystemcomponent=\"true\"\n"
180 " docGroupBase=\"GrpSystemMaterial\"\n"
181 " >\n"
182 "\n"
183 " The chunk material class. See \\ref PageSystemMaterialChunkMaterial for a\n"
184 " description.\n"
185 "\n"
186 " Chunks can be attached and detached from the material using\n"
187 " OSG::ChunkMaterial::addChunk() and OSG::ChunkMaterial::subChunk(). For more\n"
188 " complex manipulation of the chunk list use the OSG::ChunkMaterial::_mfChunks\n"
189 " field's functions.\n"
190 " <Field\n"
191 "\t name=\"chunks\"\n"
192 "\t type=\"StateChunkPtr\"\n"
193 "\t cardinality=\"multi\"\n"
194 "\t visibility=\"external\"\n"
195 " access=\"protected\"\n"
196 " ptrFieldAccess = \"custom\"\n"
197 " pushToFieldAs=\"pushToChunks\"\n"
198 " removeFromMFieldIndexAs=\"removeFromChunks\"\n"
199 " removeFromMFieldObjectAs=\"removeFromChunksByObj\"\n"
200 " replaceInMFieldIndexAs=\"replaceChunk\"\n"
201 " hasPushToField=\"True\"\n"
202 " hasRemoveFromMFieldIndex=\"True\"\n"
203 " hasRemoveFromMFieldObject=\"True\"\n"
204 " hasReplaceInMFieldIndex=\"True\"\n"
205 "\t >\n"
206 " </Field>\n"
207 " <Field\n"
208 "\t name=\"slots\"\n"
209 "\t type=\"Int32\"\n"
210 "\t cardinality=\"multi\"\n"
211 "\t visibility=\"external\"\n"
212 " access=\"protected\"\n"
213 "\t >\n"
214 " </Field>\n"
215 "</FieldContainer>\n",
216 "The chunk material class. See \\ref PageSystemMaterialChunkMaterial for a\n"
217 "description.\n"
218 "\n"
219 "Chunks can be attached and detached from the material using\n"
220 "OSG::ChunkMaterial::addChunk() and OSG::ChunkMaterial::subChunk(). For more\n"
221 "complex manipulation of the chunk list use the OSG::ChunkMaterial::_mfChunks\n"
222 "field's functions.\n"
225 /*------------------------------ get -----------------------------------*/
227 FieldContainerType &ChunkMaterialBase::getType(void)
229 return _type;
232 const FieldContainerType &ChunkMaterialBase::getType(void) const
234 return _type;
237 UInt32 ChunkMaterialBase::getContainerSize(void) const
239 return sizeof(ChunkMaterial);
242 /*------------------------- decorator get ------------------------------*/
245 //! Get the ChunkMaterial::_mfChunks field.
246 const MFUnrecStateChunkPtr *ChunkMaterialBase::getMFChunks(void) const
248 return &_mfChunks;
250 StateChunk * ChunkMaterialBase::getChunks(const UInt32 index) const
252 return _mfChunks[index];
255 MFInt32 *ChunkMaterialBase::editMFSlots(void)
257 editMField(SlotsFieldMask, _mfSlots);
259 return &_mfSlots;
262 const MFInt32 *ChunkMaterialBase::getMFSlots(void) const
264 return &_mfSlots;
273 /*------------------------------ access -----------------------------------*/
275 SizeT ChunkMaterialBase::getBinSize(ConstFieldMaskArg whichField)
277 SizeT returnValue = Inherited::getBinSize(whichField);
279 if(FieldBits::NoField != (ChunksFieldMask & whichField))
281 returnValue += _mfChunks.getBinSize();
283 if(FieldBits::NoField != (SlotsFieldMask & whichField))
285 returnValue += _mfSlots.getBinSize();
288 return returnValue;
291 void ChunkMaterialBase::copyToBin(BinaryDataHandler &pMem,
292 ConstFieldMaskArg whichField)
294 Inherited::copyToBin(pMem, whichField);
296 if(FieldBits::NoField != (ChunksFieldMask & whichField))
298 _mfChunks.copyToBin(pMem);
300 if(FieldBits::NoField != (SlotsFieldMask & whichField))
302 _mfSlots.copyToBin(pMem);
306 void ChunkMaterialBase::copyFromBin(BinaryDataHandler &pMem,
307 ConstFieldMaskArg whichField)
309 Inherited::copyFromBin(pMem, whichField);
311 if(FieldBits::NoField != (ChunksFieldMask & whichField))
313 editMField(ChunksFieldMask, _mfChunks);
314 _mfChunks.copyFromBin(pMem);
316 if(FieldBits::NoField != (SlotsFieldMask & whichField))
318 editMField(SlotsFieldMask, _mfSlots);
319 _mfSlots.copyFromBin(pMem);
323 //! create a new instance of the class
324 ChunkMaterialTransitPtr ChunkMaterialBase::createLocal(BitVector bFlags)
326 ChunkMaterialTransitPtr fc;
328 if(getClassType().getPrototype() != NULL)
330 FieldContainerTransitPtr tmpPtr =
331 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
333 fc = dynamic_pointer_cast<ChunkMaterial>(tmpPtr);
336 return fc;
339 //! create a new instance of the class, copy the container flags
340 ChunkMaterialTransitPtr ChunkMaterialBase::createDependent(BitVector bFlags)
342 ChunkMaterialTransitPtr fc;
344 if(getClassType().getPrototype() != NULL)
346 FieldContainerTransitPtr tmpPtr =
347 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
349 fc = dynamic_pointer_cast<ChunkMaterial>(tmpPtr);
352 return fc;
355 //! create a new instance of the class
356 ChunkMaterialTransitPtr ChunkMaterialBase::create(void)
358 ChunkMaterialTransitPtr fc;
360 if(getClassType().getPrototype() != NULL)
362 FieldContainerTransitPtr tmpPtr =
363 getClassType().getPrototype()-> shallowCopy();
365 fc = dynamic_pointer_cast<ChunkMaterial>(tmpPtr);
368 return fc;
371 ChunkMaterial *ChunkMaterialBase::createEmptyLocal(BitVector bFlags)
373 ChunkMaterial *returnValue;
375 newPtr<ChunkMaterial>(returnValue, bFlags);
377 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
379 return returnValue;
382 //! create an empty new instance of the class, do not copy the prototype
383 ChunkMaterial *ChunkMaterialBase::createEmpty(void)
385 ChunkMaterial *returnValue;
387 newPtr<ChunkMaterial>(returnValue, Thread::getCurrentLocalFlags());
389 returnValue->_pFieldFlags->_bNamespaceMask &=
390 ~Thread::getCurrentLocalFlags();
392 return returnValue;
396 FieldContainerTransitPtr ChunkMaterialBase::shallowCopyLocal(
397 BitVector bFlags) const
399 ChunkMaterial *tmpPtr;
401 newPtr(tmpPtr, dynamic_cast<const ChunkMaterial *>(this), bFlags);
403 FieldContainerTransitPtr returnValue(tmpPtr);
405 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
407 return returnValue;
410 FieldContainerTransitPtr ChunkMaterialBase::shallowCopyDependent(
411 BitVector bFlags) const
413 ChunkMaterial *tmpPtr;
415 newPtr(tmpPtr, dynamic_cast<const ChunkMaterial *>(this), ~bFlags);
417 FieldContainerTransitPtr returnValue(tmpPtr);
419 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
421 return returnValue;
424 FieldContainerTransitPtr ChunkMaterialBase::shallowCopy(void) const
426 ChunkMaterial *tmpPtr;
428 newPtr(tmpPtr,
429 dynamic_cast<const ChunkMaterial *>(this),
430 Thread::getCurrentLocalFlags());
432 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
434 FieldContainerTransitPtr returnValue(tmpPtr);
436 return returnValue;
442 /*------------------------- constructors ----------------------------------*/
444 ChunkMaterialBase::ChunkMaterialBase(void) :
445 Inherited(),
446 _mfChunks (),
447 _mfSlots ()
451 ChunkMaterialBase::ChunkMaterialBase(const ChunkMaterialBase &source) :
452 Inherited(source),
453 _mfChunks (),
454 _mfSlots (source._mfSlots )
459 /*-------------------------- destructors ----------------------------------*/
461 ChunkMaterialBase::~ChunkMaterialBase(void)
465 void ChunkMaterialBase::onCreate(const ChunkMaterial *source)
467 Inherited::onCreate(source);
469 if(source != NULL)
471 ChunkMaterial *pThis = static_cast<ChunkMaterial *>(this);
473 MFUnrecStateChunkPtr::const_iterator ChunksIt =
474 source->_mfChunks.begin();
475 MFUnrecStateChunkPtr::const_iterator ChunksEnd =
476 source->_mfChunks.end ();
478 while(ChunksIt != ChunksEnd)
480 pThis->pushToChunks(*ChunksIt);
482 ++ChunksIt;
487 GetFieldHandlePtr ChunkMaterialBase::getHandleChunks (void) const
489 MFUnrecStateChunkPtr::GetHandlePtr returnValue(
490 new MFUnrecStateChunkPtr::GetHandle(
491 &_mfChunks,
492 this->getType().getFieldDesc(ChunksFieldId),
493 const_cast<ChunkMaterialBase *>(this)));
495 return returnValue;
498 EditFieldHandlePtr ChunkMaterialBase::editHandleChunks (void)
500 MFUnrecStateChunkPtr::EditHandlePtr returnValue(
501 new MFUnrecStateChunkPtr::EditHandle(
502 &_mfChunks,
503 this->getType().getFieldDesc(ChunksFieldId),
504 this));
506 returnValue->setAddMethod(
507 boost::bind(&ChunkMaterial::pushToChunks,
508 static_cast<ChunkMaterial *>(this), _1));
509 returnValue->setReplaceMethod(
510 boost::bind(&ChunkMaterial::replaceChunk,
511 static_cast<ChunkMaterial *>(this), _1, _2));
512 returnValue->setRemoveMethod(
513 boost::bind(&ChunkMaterial::removeFromChunks,
514 static_cast<ChunkMaterial *>(this), _1));
515 returnValue->setRemoveObjMethod(
516 boost::bind(&ChunkMaterial::removeFromChunksByObj,
517 static_cast<ChunkMaterial *>(this), _1));
519 editMField(ChunksFieldMask, _mfChunks);
521 return returnValue;
524 GetFieldHandlePtr ChunkMaterialBase::getHandleSlots (void) const
526 MFInt32::GetHandlePtr returnValue(
527 new MFInt32::GetHandle(
528 &_mfSlots,
529 this->getType().getFieldDesc(SlotsFieldId),
530 const_cast<ChunkMaterialBase *>(this)));
532 return returnValue;
535 EditFieldHandlePtr ChunkMaterialBase::editHandleSlots (void)
537 MFInt32::EditHandlePtr returnValue(
538 new MFInt32::EditHandle(
539 &_mfSlots,
540 this->getType().getFieldDesc(SlotsFieldId),
541 this));
544 editMField(SlotsFieldMask, _mfSlots);
546 return returnValue;
550 #ifdef OSG_MT_CPTR_ASPECT
551 void ChunkMaterialBase::execSyncV( FieldContainer &oFrom,
552 ConstFieldMaskArg whichField,
553 AspectOffsetStore &oOffsets,
554 ConstFieldMaskArg syncMode,
555 const UInt32 uiSyncInfo)
557 ChunkMaterial *pThis = static_cast<ChunkMaterial *>(this);
559 pThis->execSync(static_cast<ChunkMaterial *>(&oFrom),
560 whichField,
561 oOffsets,
562 syncMode,
563 uiSyncInfo);
565 #endif
568 #ifdef OSG_MT_CPTR_ASPECT
569 FieldContainer *ChunkMaterialBase::createAspectCopy(
570 const FieldContainer *pRefAspect) const
572 ChunkMaterial *returnValue;
574 newAspectCopy(returnValue,
575 dynamic_cast<const ChunkMaterial *>(pRefAspect),
576 dynamic_cast<const ChunkMaterial *>(this));
578 return returnValue;
580 #endif
582 void ChunkMaterialBase::resolveLinks(void)
584 Inherited::resolveLinks();
586 static_cast<ChunkMaterial *>(this)->clearChunks();
588 #ifdef OSG_MT_CPTR_ASPECT
589 AspectOffsetStore oOffsets;
591 _pAspectStore->fillOffsetArray(oOffsets, this);
592 #endif
594 #ifdef OSG_MT_CPTR_ASPECT
595 _mfSlots.terminateShare(Thread::getCurrentAspect(),
596 oOffsets);
597 #endif
601 OSG_END_NAMESPACE