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 **
48 ** class ChunkMaterial!
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 "OSGChunkMaterialBase.h"
68 #include "OSGChunkMaterial.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::ChunkMaterial
79 The chunk material class. See \ref PageSystemMaterialChunkMaterial for a
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
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(
109 ChunkMaterial::getClassType(),
113 OSG_FIELDTRAITS_GETTYPE_NS(ChunkMaterial
*, nsOSG
)
115 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
119 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
123 /***************************************************************************\
124 * Field Description *
125 \***************************************************************************/
127 void ChunkMaterialBase::classDescInserter(TypeObject
&oType
)
129 FieldDescriptionBase
*pDesc
= NULL
;
132 pDesc
= new MFUnrecStateChunkPtr::Description(
133 MFUnrecStateChunkPtr::getClassType(),
136 ChunksFieldId
, ChunksFieldMask
,
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(),
148 SlotsFieldId
, SlotsFieldMask
,
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(),
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
)),
170 "<?xml version=\"1.0\"?>\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"
183 " The chunk material class. See \\ref PageSystemMaterialChunkMaterial for a\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"
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"
208 "\t name=\"slots\"\n"
209 "\t type=\"Int32\"\n"
210 "\t cardinality=\"multi\"\n"
211 "\t visibility=\"external\"\n"
212 " access=\"protected\"\n"
215 "</FieldContainer>\n",
216 "The chunk material class. See \\ref PageSystemMaterialChunkMaterial for a\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)
232 const FieldContainerType
&ChunkMaterialBase::getType(void) const
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
250 StateChunk
* ChunkMaterialBase::getChunks(const UInt32 index
) const
252 return _mfChunks
[index
];
255 MFInt32
*ChunkMaterialBase::editMFSlots(void)
257 editMField(SlotsFieldMask
, _mfSlots
);
262 const MFInt32
*ChunkMaterialBase::getMFSlots(void) const
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();
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
);
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
);
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
);
371 ChunkMaterial
*ChunkMaterialBase::createEmptyLocal(BitVector bFlags
)
373 ChunkMaterial
*returnValue
;
375 newPtr
<ChunkMaterial
>(returnValue
, bFlags
);
377 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
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();
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
;
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
;
424 FieldContainerTransitPtr
ChunkMaterialBase::shallowCopy(void) const
426 ChunkMaterial
*tmpPtr
;
429 dynamic_cast<const ChunkMaterial
*>(this),
430 Thread::getCurrentLocalFlags());
432 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
434 FieldContainerTransitPtr
returnValue(tmpPtr
);
442 /*------------------------- constructors ----------------------------------*/
444 ChunkMaterialBase::ChunkMaterialBase(void) :
451 ChunkMaterialBase::ChunkMaterialBase(const ChunkMaterialBase
&source
) :
454 _mfSlots (source
._mfSlots
)
459 /*-------------------------- destructors ----------------------------------*/
461 ChunkMaterialBase::~ChunkMaterialBase(void)
465 void ChunkMaterialBase::onCreate(const ChunkMaterial
*source
)
467 Inherited::onCreate(source
);
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
);
487 GetFieldHandlePtr
ChunkMaterialBase::getHandleChunks (void) const
489 MFUnrecStateChunkPtr::GetHandlePtr
returnValue(
490 new MFUnrecStateChunkPtr::GetHandle(
492 this->getType().getFieldDesc(ChunksFieldId
),
493 const_cast<ChunkMaterialBase
*>(this)));
498 EditFieldHandlePtr
ChunkMaterialBase::editHandleChunks (void)
500 MFUnrecStateChunkPtr::EditHandlePtr
returnValue(
501 new MFUnrecStateChunkPtr::EditHandle(
503 this->getType().getFieldDesc(ChunksFieldId
),
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
);
524 GetFieldHandlePtr
ChunkMaterialBase::getHandleSlots (void) const
526 MFInt32::GetHandlePtr
returnValue(
527 new MFInt32::GetHandle(
529 this->getType().getFieldDesc(SlotsFieldId
),
530 const_cast<ChunkMaterialBase
*>(this)));
535 EditFieldHandlePtr
ChunkMaterialBase::editHandleSlots (void)
537 MFInt32::EditHandlePtr
returnValue(
538 new MFInt32::EditHandle(
540 this->getType().getFieldDesc(SlotsFieldId
),
544 editMField(SlotsFieldMask
, _mfSlots
);
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
),
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));
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);
594 #ifdef OSG_MT_CPTR_ASPECT
595 _mfSlots
.terminateShare(Thread::getCurrentAspect(),