changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Groups / Misc / OSGMaterialChunkOverrideGroupBase.cpp
blob97b150431b11ae5675c4c19dbffc225c2a5de9a7
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: Johannes Brunen *
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 MaterialChunkOverrideGroup!
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 "OSGMaterial.h" // Material Class
67 #include "OSGMaterialChunkOverrideGroupBase.h"
68 #include "OSGMaterialChunkOverrideGroup.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::MaterialChunkOverrideGroup
79 MaterialChunkOverrideGroup is a ChunkOverrideGroup node that takes a
80 material instead of individual chunks. If the material can't be finalized
81 to a ChunkMaterial the class behaves exactly as the MaterialGroup class,
82 i.e. overwriting the complete material instead of individual chunks.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var Material * MaterialChunkOverrideGroupBase::_sfMaterial
94 /***************************************************************************\
95 * FieldType/FieldTrait Instantiation *
96 \***************************************************************************/
98 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
99 PointerType FieldTraits<MaterialChunkOverrideGroup *, nsOSG>::_type(
100 "MaterialChunkOverrideGroupPtr",
101 "ChunkOverrideGroupPtr",
102 MaterialChunkOverrideGroup::getClassType(),
103 nsOSG);
104 #endif
106 OSG_FIELDTRAITS_GETTYPE_NS(MaterialChunkOverrideGroup *, nsOSG)
108 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
109 MaterialChunkOverrideGroup *,
110 nsOSG)
112 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
113 MaterialChunkOverrideGroup *,
114 nsOSG)
116 /***************************************************************************\
117 * Field Description *
118 \***************************************************************************/
120 void MaterialChunkOverrideGroupBase::classDescInserter(TypeObject &oType)
122 FieldDescriptionBase *pDesc = NULL;
125 pDesc = new SFUnrecMaterialPtr::Description(
126 SFUnrecMaterialPtr::getClassType(),
127 "material",
129 MaterialFieldId, MaterialFieldMask,
130 false,
131 (Field::SFDefaultFlags | Field::FStdAccess),
132 static_cast<FieldEditMethodSig>(&MaterialChunkOverrideGroup::editHandleMaterial),
133 static_cast<FieldGetMethodSig >(&MaterialChunkOverrideGroup::getHandleMaterial));
135 oType.addInitialDesc(pDesc);
139 MaterialChunkOverrideGroupBase::TypeObject MaterialChunkOverrideGroupBase::_type(
140 MaterialChunkOverrideGroupBase::getClassname(),
141 Inherited::getClassname(),
142 "NULL",
143 nsOSG, //Namespace
144 reinterpret_cast<PrototypeCreateF>(&MaterialChunkOverrideGroupBase::createEmptyLocal),
145 reinterpret_cast<InitContainerF>(&MaterialChunkOverrideGroup::initMethod),
146 reinterpret_cast<ExitContainerF>(&MaterialChunkOverrideGroup::exitMethod),
147 reinterpret_cast<InitalInsertDescFunc>(
148 reinterpret_cast<void *>(&MaterialChunkOverrideGroup::classDescInserter)),
149 false,
151 "<?xml version=\"1.0\"?>\n"
152 "\n"
153 "<FieldContainer\n"
154 " name=\"MaterialChunkOverrideGroup\"\n"
155 " parent=\"ChunkOverrideGroup\"\n"
156 " library=\"Group\"\n"
157 " pointerfieldtypes=\"both\"\n"
158 " structure=\"concrete\"\n"
159 " systemcomponent=\"true\"\n"
160 " parentsystemcomponent=\"true\"\n"
161 " isNodeCore=\"true\"\n"
162 " authors=\"Johannes Brunen\"\n"
163 " docGroupBase=\"GrpGroupMisc\"\n"
164 " >\n"
165 " MaterialChunkOverrideGroup is a ChunkOverrideGroup node that takes a\n"
166 " material instead of individual chunks. If the material can't be finalized\n"
167 " to a ChunkMaterial the class behaves exactly as the MaterialGroup class,\n"
168 " i.e. overwriting the complete material instead of individual chunks.\n"
169 "\n"
170 " <Field\n"
171 "\t name=\"material\"\n"
172 "\t type=\"Material\"\n"
173 "\t cardinality=\"single\"\n"
174 "\t visibility=\"external\"\n"
175 "\t access=\"public\"\n"
176 " category=\"pointer\"\n"
177 "\t >\n"
178 " </Field>\n"
179 "</FieldContainer>\n",
180 "MaterialChunkOverrideGroup is a ChunkOverrideGroup node that takes a\n"
181 "material instead of individual chunks. If the material can't be finalized\n"
182 "to a ChunkMaterial the class behaves exactly as the MaterialGroup class,\n"
183 "i.e. overwriting the complete material instead of individual chunks.\n"
186 /*------------------------------ get -----------------------------------*/
188 FieldContainerType &MaterialChunkOverrideGroupBase::getType(void)
190 return _type;
193 const FieldContainerType &MaterialChunkOverrideGroupBase::getType(void) const
195 return _type;
198 UInt32 MaterialChunkOverrideGroupBase::getContainerSize(void) const
200 return sizeof(MaterialChunkOverrideGroup);
203 /*------------------------- decorator get ------------------------------*/
206 //! Get the MaterialChunkOverrideGroup::_sfMaterial field.
207 const SFUnrecMaterialPtr *MaterialChunkOverrideGroupBase::getSFMaterial(void) const
209 return &_sfMaterial;
212 SFUnrecMaterialPtr *MaterialChunkOverrideGroupBase::editSFMaterial (void)
214 editSField(MaterialFieldMask);
216 return &_sfMaterial;
219 //! Get the value of the MaterialChunkOverrideGroup::_sfMaterial field.
220 Material * MaterialChunkOverrideGroupBase::getMaterial(void) const
222 return _sfMaterial.getValue();
225 //! Set the value of the MaterialChunkOverrideGroup::_sfMaterial field.
226 void MaterialChunkOverrideGroupBase::setMaterial(Material * const value)
228 editSField(MaterialFieldMask);
230 _sfMaterial.setValue(value);
238 /*------------------------------ access -----------------------------------*/
240 SizeT MaterialChunkOverrideGroupBase::getBinSize(ConstFieldMaskArg whichField)
242 SizeT returnValue = Inherited::getBinSize(whichField);
244 if(FieldBits::NoField != (MaterialFieldMask & whichField))
246 returnValue += _sfMaterial.getBinSize();
249 return returnValue;
252 void MaterialChunkOverrideGroupBase::copyToBin(BinaryDataHandler &pMem,
253 ConstFieldMaskArg whichField)
255 Inherited::copyToBin(pMem, whichField);
257 if(FieldBits::NoField != (MaterialFieldMask & whichField))
259 _sfMaterial.copyToBin(pMem);
263 void MaterialChunkOverrideGroupBase::copyFromBin(BinaryDataHandler &pMem,
264 ConstFieldMaskArg whichField)
266 Inherited::copyFromBin(pMem, whichField);
268 if(FieldBits::NoField != (MaterialFieldMask & whichField))
270 editSField(MaterialFieldMask);
271 _sfMaterial.copyFromBin(pMem);
275 //! create a new instance of the class
276 MaterialChunkOverrideGroupTransitPtr MaterialChunkOverrideGroupBase::createLocal(BitVector bFlags)
278 MaterialChunkOverrideGroupTransitPtr fc;
280 if(getClassType().getPrototype() != NULL)
282 FieldContainerTransitPtr tmpPtr =
283 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
285 fc = dynamic_pointer_cast<MaterialChunkOverrideGroup>(tmpPtr);
288 return fc;
291 //! create a new instance of the class, copy the container flags
292 MaterialChunkOverrideGroupTransitPtr MaterialChunkOverrideGroupBase::createDependent(BitVector bFlags)
294 MaterialChunkOverrideGroupTransitPtr fc;
296 if(getClassType().getPrototype() != NULL)
298 FieldContainerTransitPtr tmpPtr =
299 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
301 fc = dynamic_pointer_cast<MaterialChunkOverrideGroup>(tmpPtr);
304 return fc;
307 //! create a new instance of the class
308 MaterialChunkOverrideGroupTransitPtr MaterialChunkOverrideGroupBase::create(void)
310 MaterialChunkOverrideGroupTransitPtr fc;
312 if(getClassType().getPrototype() != NULL)
314 FieldContainerTransitPtr tmpPtr =
315 getClassType().getPrototype()-> shallowCopy();
317 fc = dynamic_pointer_cast<MaterialChunkOverrideGroup>(tmpPtr);
320 return fc;
323 MaterialChunkOverrideGroup *MaterialChunkOverrideGroupBase::createEmptyLocal(BitVector bFlags)
325 MaterialChunkOverrideGroup *returnValue;
327 newPtr<MaterialChunkOverrideGroup>(returnValue, bFlags);
329 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
331 return returnValue;
334 //! create an empty new instance of the class, do not copy the prototype
335 MaterialChunkOverrideGroup *MaterialChunkOverrideGroupBase::createEmpty(void)
337 MaterialChunkOverrideGroup *returnValue;
339 newPtr<MaterialChunkOverrideGroup>(returnValue, Thread::getCurrentLocalFlags());
341 returnValue->_pFieldFlags->_bNamespaceMask &=
342 ~Thread::getCurrentLocalFlags();
344 return returnValue;
348 FieldContainerTransitPtr MaterialChunkOverrideGroupBase::shallowCopyLocal(
349 BitVector bFlags) const
351 MaterialChunkOverrideGroup *tmpPtr;
353 newPtr(tmpPtr, dynamic_cast<const MaterialChunkOverrideGroup *>(this), bFlags);
355 FieldContainerTransitPtr returnValue(tmpPtr);
357 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
359 return returnValue;
362 FieldContainerTransitPtr MaterialChunkOverrideGroupBase::shallowCopyDependent(
363 BitVector bFlags) const
365 MaterialChunkOverrideGroup *tmpPtr;
367 newPtr(tmpPtr, dynamic_cast<const MaterialChunkOverrideGroup *>(this), ~bFlags);
369 FieldContainerTransitPtr returnValue(tmpPtr);
371 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
373 return returnValue;
376 FieldContainerTransitPtr MaterialChunkOverrideGroupBase::shallowCopy(void) const
378 MaterialChunkOverrideGroup *tmpPtr;
380 newPtr(tmpPtr,
381 dynamic_cast<const MaterialChunkOverrideGroup *>(this),
382 Thread::getCurrentLocalFlags());
384 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
386 FieldContainerTransitPtr returnValue(tmpPtr);
388 return returnValue;
394 /*------------------------- constructors ----------------------------------*/
396 MaterialChunkOverrideGroupBase::MaterialChunkOverrideGroupBase(void) :
397 Inherited(),
398 _sfMaterial (NULL)
402 MaterialChunkOverrideGroupBase::MaterialChunkOverrideGroupBase(const MaterialChunkOverrideGroupBase &source) :
403 Inherited(source),
404 _sfMaterial (NULL)
409 /*-------------------------- destructors ----------------------------------*/
411 MaterialChunkOverrideGroupBase::~MaterialChunkOverrideGroupBase(void)
415 void MaterialChunkOverrideGroupBase::onCreate(const MaterialChunkOverrideGroup *source)
417 Inherited::onCreate(source);
419 if(source != NULL)
421 MaterialChunkOverrideGroup *pThis = static_cast<MaterialChunkOverrideGroup *>(this);
423 pThis->setMaterial(source->getMaterial());
427 GetFieldHandlePtr MaterialChunkOverrideGroupBase::getHandleMaterial (void) const
429 SFUnrecMaterialPtr::GetHandlePtr returnValue(
430 new SFUnrecMaterialPtr::GetHandle(
431 &_sfMaterial,
432 this->getType().getFieldDesc(MaterialFieldId),
433 const_cast<MaterialChunkOverrideGroupBase *>(this)));
435 return returnValue;
438 EditFieldHandlePtr MaterialChunkOverrideGroupBase::editHandleMaterial (void)
440 SFUnrecMaterialPtr::EditHandlePtr returnValue(
441 new SFUnrecMaterialPtr::EditHandle(
442 &_sfMaterial,
443 this->getType().getFieldDesc(MaterialFieldId),
444 this));
446 returnValue->setSetMethod(
447 boost::bind(&MaterialChunkOverrideGroup::setMaterial,
448 static_cast<MaterialChunkOverrideGroup *>(this), _1));
450 editSField(MaterialFieldMask);
452 return returnValue;
456 #ifdef OSG_MT_CPTR_ASPECT
457 void MaterialChunkOverrideGroupBase::execSyncV( FieldContainer &oFrom,
458 ConstFieldMaskArg whichField,
459 AspectOffsetStore &oOffsets,
460 ConstFieldMaskArg syncMode,
461 const UInt32 uiSyncInfo)
463 MaterialChunkOverrideGroup *pThis = static_cast<MaterialChunkOverrideGroup *>(this);
465 pThis->execSync(static_cast<MaterialChunkOverrideGroup *>(&oFrom),
466 whichField,
467 oOffsets,
468 syncMode,
469 uiSyncInfo);
471 #endif
474 #ifdef OSG_MT_CPTR_ASPECT
475 FieldContainer *MaterialChunkOverrideGroupBase::createAspectCopy(
476 const FieldContainer *pRefAspect) const
478 MaterialChunkOverrideGroup *returnValue;
480 newAspectCopy(returnValue,
481 dynamic_cast<const MaterialChunkOverrideGroup *>(pRefAspect),
482 dynamic_cast<const MaterialChunkOverrideGroup *>(this));
484 return returnValue;
486 #endif
488 void MaterialChunkOverrideGroupBase::resolveLinks(void)
490 Inherited::resolveLinks();
492 static_cast<MaterialChunkOverrideGroup *>(this)->setMaterial(NULL);
498 OSG_END_NAMESPACE