fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Base / OSGChunkOverrideGroupBase.cpp
blob1147f88c029ceb4ad2ea27c2468bebd1415ce48f
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 ChunkOverrideGroup!
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 "OSGChunkBlock.h" // FallbackChunkBlock Class
67 #include "OSGChunkOverrideGroupBase.h"
68 #include "OSGChunkOverrideGroup.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::ChunkOverrideGroup
79 ChunkOverrideGroup is a simple group node that allows for material chunks
80 to be set that will override all chunks stored in materials in the entire
81 subtree. Currently the last chunk override wins (note the difference to
82 the material group). This might change in future.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var ChunkBlock * ChunkOverrideGroupBase::_sfFallbackChunkBlock
93 /*! \var bool ChunkOverrideGroupBase::_sfSubOverride
94 If true, the ChunkOverrideGroup group does not add new override chunks,
95 but subtract the chunks from the list of already defined override chunks.
96 Basically, that allows to negate overrides at a deeper level in the scene graph.
100 /***************************************************************************\
101 * FieldType/FieldTrait Instantiation *
102 \***************************************************************************/
104 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
105 PointerType FieldTraits<ChunkOverrideGroup *, nsOSG>::_type(
106 "ChunkOverrideGroupPtr",
107 "GroupPtr",
108 ChunkOverrideGroup::getClassType(),
109 nsOSG);
110 #endif
112 OSG_FIELDTRAITS_GETTYPE_NS(ChunkOverrideGroup *, nsOSG)
114 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
115 ChunkOverrideGroup *,
116 nsOSG)
118 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
119 ChunkOverrideGroup *,
120 nsOSG)
122 /***************************************************************************\
123 * Field Description *
124 \***************************************************************************/
126 void ChunkOverrideGroupBase::classDescInserter(TypeObject &oType)
128 FieldDescriptionBase *pDesc = NULL;
131 pDesc = new SFUnrecChunkBlockPtr::Description(
132 SFUnrecChunkBlockPtr::getClassType(),
133 "fallbackChunkBlock",
135 FallbackChunkBlockFieldId, FallbackChunkBlockFieldMask,
136 false,
137 (Field::SFDefaultFlags | Field::FStdAccess),
138 static_cast<FieldEditMethodSig>(&ChunkOverrideGroup::editHandleFallbackChunkBlock),
139 static_cast<FieldGetMethodSig >(&ChunkOverrideGroup::getHandleFallbackChunkBlock));
141 oType.addInitialDesc(pDesc);
143 pDesc = new SFBool::Description(
144 SFBool::getClassType(),
145 "subOverride",
146 "If true, the ChunkOverrideGroup group does not add new override chunks, \n"
147 "but subtract the chunks from the list of already defined override chunks.\n"
148 "Basically, that allows to negate overrides at a deeper level in the scene graph.\n",
149 SubOverrideFieldId, SubOverrideFieldMask,
150 false,
151 (Field::SFDefaultFlags | Field::FStdAccess),
152 static_cast<FieldEditMethodSig>(&ChunkOverrideGroup::editHandleSubOverride),
153 static_cast<FieldGetMethodSig >(&ChunkOverrideGroup::getHandleSubOverride));
155 oType.addInitialDesc(pDesc);
159 ChunkOverrideGroupBase::TypeObject ChunkOverrideGroupBase::_type(
160 ChunkOverrideGroupBase::getClassname(),
161 Inherited::getClassname(),
162 "NULL",
163 nsOSG, //Namespace
164 reinterpret_cast<PrototypeCreateF>(&ChunkOverrideGroupBase::createEmptyLocal),
165 reinterpret_cast<InitContainerF>(&ChunkOverrideGroup::initMethod),
166 reinterpret_cast<ExitContainerF>(&ChunkOverrideGroup::exitMethod),
167 reinterpret_cast<InitalInsertDescFunc>(
168 reinterpret_cast<void *>(&ChunkOverrideGroup::classDescInserter)),
169 false,
171 "<?xml version=\"1.0\"?>\n"
172 "\n"
173 "<FieldContainer\n"
174 " name=\"ChunkOverrideGroup\"\n"
175 " parent=\"Group\"\n"
176 " library=\"System\"\n"
177 " pointerfieldtypes=\"both\"\n"
178 " structure=\"concrete\"\n"
179 " systemcomponent=\"true\"\n"
180 " parentsystemcomponent=\"true\"\n"
181 " isNodeCore=\"true\"\n"
182 " docGroupBase=\"GrpSystemNodeCoreGroups\"\n"
183 " >\n"
184 "\n"
185 " ChunkOverrideGroup is a simple group node that allows for material chunks\n"
186 " to be set that will override all chunks stored in materials in the entire \n"
187 " subtree. Currently the last chunk override wins (note the difference to\n"
188 " the material group). This might change in future.\n"
189 "\n"
190 " <Field\n"
191 "\t name=\"fallbackChunkBlock\"\n"
192 "\t type=\"ChunkBlockPtr\"\n"
193 "\t cardinality=\"single\"\n"
194 "\t visibility=\"external\"\n"
195 "\t access=\"public\"\n"
196 "\t >\n"
197 " </Field>\n"
198 "\n"
199 "<Field\n"
200 " name=\"subOverride\"\n"
201 " type=\"bool\"\n"
202 " cardinality=\"single\"\n"
203 " visibility=\"external\"\n"
204 " defaultValue=\"false\"\n"
205 " access=\"public\"\n"
206 "\t>\n"
207 " If true, the ChunkOverrideGroup group does not add new override chunks, \n"
208 " but subtract the chunks from the list of already defined override chunks.\n"
209 " Basically, that allows to negate overrides at a deeper level in the scene graph.\n"
210 "</Field>\n"
211 "\n"
212 "</FieldContainer>\n"
213 "\n",
214 "ChunkOverrideGroup is a simple group node that allows for material chunks\n"
215 "to be set that will override all chunks stored in materials in the entire \n"
216 "subtree. Currently the last chunk override wins (note the difference to\n"
217 "the material group). This might change in future.\n"
220 /*------------------------------ get -----------------------------------*/
222 FieldContainerType &ChunkOverrideGroupBase::getType(void)
224 return _type;
227 const FieldContainerType &ChunkOverrideGroupBase::getType(void) const
229 return _type;
232 UInt32 ChunkOverrideGroupBase::getContainerSize(void) const
234 return sizeof(ChunkOverrideGroup);
237 /*------------------------- decorator get ------------------------------*/
240 //! Get the ChunkOverrideGroup::_sfFallbackChunkBlock field.
241 const SFUnrecChunkBlockPtr *ChunkOverrideGroupBase::getSFFallbackChunkBlock(void) const
243 return &_sfFallbackChunkBlock;
246 SFUnrecChunkBlockPtr *ChunkOverrideGroupBase::editSFFallbackChunkBlock(void)
248 editSField(FallbackChunkBlockFieldMask);
250 return &_sfFallbackChunkBlock;
253 //! Get the value of the ChunkOverrideGroup::_sfFallbackChunkBlock field.
254 ChunkBlock * ChunkOverrideGroupBase::getFallbackChunkBlock(void) const
256 return _sfFallbackChunkBlock.getValue();
259 //! Set the value of the ChunkOverrideGroup::_sfFallbackChunkBlock field.
260 void ChunkOverrideGroupBase::setFallbackChunkBlock(ChunkBlock * const value)
262 editSField(FallbackChunkBlockFieldMask);
264 _sfFallbackChunkBlock.setValue(value);
268 SFBool *ChunkOverrideGroupBase::editSFSubOverride(void)
270 editSField(SubOverrideFieldMask);
272 return &_sfSubOverride;
275 const SFBool *ChunkOverrideGroupBase::getSFSubOverride(void) const
277 return &_sfSubOverride;
285 /*------------------------------ access -----------------------------------*/
287 SizeT ChunkOverrideGroupBase::getBinSize(ConstFieldMaskArg whichField)
289 SizeT returnValue = Inherited::getBinSize(whichField);
291 if(FieldBits::NoField != (FallbackChunkBlockFieldMask & whichField))
293 returnValue += _sfFallbackChunkBlock.getBinSize();
295 if(FieldBits::NoField != (SubOverrideFieldMask & whichField))
297 returnValue += _sfSubOverride.getBinSize();
300 return returnValue;
303 void ChunkOverrideGroupBase::copyToBin(BinaryDataHandler &pMem,
304 ConstFieldMaskArg whichField)
306 Inherited::copyToBin(pMem, whichField);
308 if(FieldBits::NoField != (FallbackChunkBlockFieldMask & whichField))
310 _sfFallbackChunkBlock.copyToBin(pMem);
312 if(FieldBits::NoField != (SubOverrideFieldMask & whichField))
314 _sfSubOverride.copyToBin(pMem);
318 void ChunkOverrideGroupBase::copyFromBin(BinaryDataHandler &pMem,
319 ConstFieldMaskArg whichField)
321 Inherited::copyFromBin(pMem, whichField);
323 if(FieldBits::NoField != (FallbackChunkBlockFieldMask & whichField))
325 editSField(FallbackChunkBlockFieldMask);
326 _sfFallbackChunkBlock.copyFromBin(pMem);
328 if(FieldBits::NoField != (SubOverrideFieldMask & whichField))
330 editSField(SubOverrideFieldMask);
331 _sfSubOverride.copyFromBin(pMem);
335 //! create a new instance of the class
336 ChunkOverrideGroupTransitPtr ChunkOverrideGroupBase::createLocal(BitVector bFlags)
338 ChunkOverrideGroupTransitPtr fc;
340 if(getClassType().getPrototype() != NULL)
342 FieldContainerTransitPtr tmpPtr =
343 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
345 fc = dynamic_pointer_cast<ChunkOverrideGroup>(tmpPtr);
348 return fc;
351 //! create a new instance of the class, copy the container flags
352 ChunkOverrideGroupTransitPtr ChunkOverrideGroupBase::createDependent(BitVector bFlags)
354 ChunkOverrideGroupTransitPtr fc;
356 if(getClassType().getPrototype() != NULL)
358 FieldContainerTransitPtr tmpPtr =
359 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
361 fc = dynamic_pointer_cast<ChunkOverrideGroup>(tmpPtr);
364 return fc;
367 //! create a new instance of the class
368 ChunkOverrideGroupTransitPtr ChunkOverrideGroupBase::create(void)
370 ChunkOverrideGroupTransitPtr fc;
372 if(getClassType().getPrototype() != NULL)
374 FieldContainerTransitPtr tmpPtr =
375 getClassType().getPrototype()-> shallowCopy();
377 fc = dynamic_pointer_cast<ChunkOverrideGroup>(tmpPtr);
380 return fc;
383 ChunkOverrideGroup *ChunkOverrideGroupBase::createEmptyLocal(BitVector bFlags)
385 ChunkOverrideGroup *returnValue;
387 newPtr<ChunkOverrideGroup>(returnValue, bFlags);
389 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
391 return returnValue;
394 //! create an empty new instance of the class, do not copy the prototype
395 ChunkOverrideGroup *ChunkOverrideGroupBase::createEmpty(void)
397 ChunkOverrideGroup *returnValue;
399 newPtr<ChunkOverrideGroup>(returnValue, Thread::getCurrentLocalFlags());
401 returnValue->_pFieldFlags->_bNamespaceMask &=
402 ~Thread::getCurrentLocalFlags();
404 return returnValue;
408 FieldContainerTransitPtr ChunkOverrideGroupBase::shallowCopyLocal(
409 BitVector bFlags) const
411 ChunkOverrideGroup *tmpPtr;
413 newPtr(tmpPtr, dynamic_cast<const ChunkOverrideGroup *>(this), bFlags);
415 FieldContainerTransitPtr returnValue(tmpPtr);
417 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
419 return returnValue;
422 FieldContainerTransitPtr ChunkOverrideGroupBase::shallowCopyDependent(
423 BitVector bFlags) const
425 ChunkOverrideGroup *tmpPtr;
427 newPtr(tmpPtr, dynamic_cast<const ChunkOverrideGroup *>(this), ~bFlags);
429 FieldContainerTransitPtr returnValue(tmpPtr);
431 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
433 return returnValue;
436 FieldContainerTransitPtr ChunkOverrideGroupBase::shallowCopy(void) const
438 ChunkOverrideGroup *tmpPtr;
440 newPtr(tmpPtr,
441 dynamic_cast<const ChunkOverrideGroup *>(this),
442 Thread::getCurrentLocalFlags());
444 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
446 FieldContainerTransitPtr returnValue(tmpPtr);
448 return returnValue;
454 /*------------------------- constructors ----------------------------------*/
456 ChunkOverrideGroupBase::ChunkOverrideGroupBase(void) :
457 Inherited(),
458 _sfFallbackChunkBlock (NULL),
459 _sfSubOverride (bool(false))
463 ChunkOverrideGroupBase::ChunkOverrideGroupBase(const ChunkOverrideGroupBase &source) :
464 Inherited(source),
465 _sfFallbackChunkBlock (NULL),
466 _sfSubOverride (source._sfSubOverride )
471 /*-------------------------- destructors ----------------------------------*/
473 ChunkOverrideGroupBase::~ChunkOverrideGroupBase(void)
477 void ChunkOverrideGroupBase::onCreate(const ChunkOverrideGroup *source)
479 Inherited::onCreate(source);
481 if(source != NULL)
483 ChunkOverrideGroup *pThis = static_cast<ChunkOverrideGroup *>(this);
485 pThis->setFallbackChunkBlock(source->getFallbackChunkBlock());
489 GetFieldHandlePtr ChunkOverrideGroupBase::getHandleFallbackChunkBlock (void) const
491 SFUnrecChunkBlockPtr::GetHandlePtr returnValue(
492 new SFUnrecChunkBlockPtr::GetHandle(
493 &_sfFallbackChunkBlock,
494 this->getType().getFieldDesc(FallbackChunkBlockFieldId),
495 const_cast<ChunkOverrideGroupBase *>(this)));
497 return returnValue;
500 EditFieldHandlePtr ChunkOverrideGroupBase::editHandleFallbackChunkBlock(void)
502 SFUnrecChunkBlockPtr::EditHandlePtr returnValue(
503 new SFUnrecChunkBlockPtr::EditHandle(
504 &_sfFallbackChunkBlock,
505 this->getType().getFieldDesc(FallbackChunkBlockFieldId),
506 this));
508 returnValue->setSetMethod(
509 boost::bind(&ChunkOverrideGroup::setFallbackChunkBlock,
510 static_cast<ChunkOverrideGroup *>(this), _1));
512 editSField(FallbackChunkBlockFieldMask);
514 return returnValue;
517 GetFieldHandlePtr ChunkOverrideGroupBase::getHandleSubOverride (void) const
519 SFBool::GetHandlePtr returnValue(
520 new SFBool::GetHandle(
521 &_sfSubOverride,
522 this->getType().getFieldDesc(SubOverrideFieldId),
523 const_cast<ChunkOverrideGroupBase *>(this)));
525 return returnValue;
528 EditFieldHandlePtr ChunkOverrideGroupBase::editHandleSubOverride (void)
530 SFBool::EditHandlePtr returnValue(
531 new SFBool::EditHandle(
532 &_sfSubOverride,
533 this->getType().getFieldDesc(SubOverrideFieldId),
534 this));
537 editSField(SubOverrideFieldMask);
539 return returnValue;
543 #ifdef OSG_MT_CPTR_ASPECT
544 void ChunkOverrideGroupBase::execSyncV( FieldContainer &oFrom,
545 ConstFieldMaskArg whichField,
546 AspectOffsetStore &oOffsets,
547 ConstFieldMaskArg syncMode,
548 const UInt32 uiSyncInfo)
550 ChunkOverrideGroup *pThis = static_cast<ChunkOverrideGroup *>(this);
552 pThis->execSync(static_cast<ChunkOverrideGroup *>(&oFrom),
553 whichField,
554 oOffsets,
555 syncMode,
556 uiSyncInfo);
558 #endif
561 #ifdef OSG_MT_CPTR_ASPECT
562 FieldContainer *ChunkOverrideGroupBase::createAspectCopy(
563 const FieldContainer *pRefAspect) const
565 ChunkOverrideGroup *returnValue;
567 newAspectCopy(returnValue,
568 dynamic_cast<const ChunkOverrideGroup *>(pRefAspect),
569 dynamic_cast<const ChunkOverrideGroup *>(this));
571 return returnValue;
573 #endif
575 void ChunkOverrideGroupBase::resolveLinks(void)
577 Inherited::resolveLinks();
579 static_cast<ChunkOverrideGroup *>(this)->setFallbackChunkBlock(NULL);
585 OSG_END_NAMESPACE