changed: gcc8 base update
[opensg.git] / Source / System / Material / Base / OSGMultiPassMaterialBase.cpp
blob68acc33a408dd7d22da888daf5ca7bba0e8b5758
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 MultiPassMaterial!
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 "OSGPrimeMaterial.h" // Materials Class
67 #include "OSGMultiPassMaterialBase.h"
68 #include "OSGMultiPassMaterial.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::MultiPassMaterial
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var PrimeMaterial * MultiPassMaterialBase::_mfMaterials
91 /***************************************************************************\
92 * FieldType/FieldTrait Instantiation *
93 \***************************************************************************/
95 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
96 PointerType FieldTraits<MultiPassMaterial *, nsOSG>::_type(
97 "MultiPassMaterialPtr",
98 "PrimeMaterialPtr",
99 MultiPassMaterial::getClassType(),
100 nsOSG);
101 #endif
103 OSG_FIELDTRAITS_GETTYPE_NS(MultiPassMaterial *, nsOSG)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
106 MultiPassMaterial *,
107 nsOSG)
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
110 MultiPassMaterial *,
111 nsOSG)
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void MultiPassMaterialBase::classDescInserter(TypeObject &oType)
119 FieldDescriptionBase *pDesc = NULL;
122 pDesc = new MFUnrecPrimeMaterialPtr::Description(
123 MFUnrecPrimeMaterialPtr::getClassType(),
124 "materials",
126 MaterialsFieldId, MaterialsFieldMask,
127 false,
128 (Field::MFDefaultFlags | Field::FStdAccess),
129 static_cast<FieldEditMethodSig>(&MultiPassMaterial::editHandleMaterials),
130 static_cast<FieldGetMethodSig >(&MultiPassMaterial::getHandleMaterials));
132 oType.addInitialDesc(pDesc);
136 MultiPassMaterialBase::TypeObject MultiPassMaterialBase::_type(
137 MultiPassMaterialBase::getClassname(),
138 Inherited::getClassname(),
139 "NULL",
140 nsOSG, //Namespace
141 reinterpret_cast<PrototypeCreateF>(&MultiPassMaterialBase::createEmptyLocal),
142 reinterpret_cast<InitContainerF>(&MultiPassMaterial::initMethod),
143 reinterpret_cast<ExitContainerF>(&MultiPassMaterial::exitMethod),
144 reinterpret_cast<InitalInsertDescFunc>(
145 reinterpret_cast<void *>(&MultiPassMaterial::classDescInserter)),
146 false,
148 "<?xml version=\"1.0\"?>\n"
149 "\n"
150 "<FieldContainer\n"
151 " name=\"MultiPassMaterial\"\n"
152 " parent=\"PrimeMaterial\"\n"
153 " library=\"System\"\n"
154 " pointerfieldtypes=\"both\"\n"
155 " structure=\"concrete\"\n"
156 " systemcomponent=\"true\"\n"
157 " parentsystemcomponent=\"true\"\n"
158 " decoratable=\"false\"\n"
159 " useLocalIncludes=\"false\"\n"
160 " docGroupBase=\"GrpSystemMaterial\"\n"
161 " >\n"
162 " <Field\n"
163 "\t name=\"materials\"\n"
164 "\t type=\"PrimeMaterialPtr\"\n"
165 "\t cardinality=\"multi\"\n"
166 "\t visibility=\"external\"\n"
167 "\t access=\"public\"\n"
168 " pushToFieldAs=\"addMaterial\"\n"
169 " assignMFieldAs=\"assignMaterialsFrom\"\n"
170 " insertIntoMFieldAs=\"insertMaterial\"\n"
171 " replaceInMFieldIndexAs=\"replaceMaterial\"\n"
172 " replaceInMFieldObjectAs=\"replaceMaterialByObj\"\n"
173 " removeFromMFieldIndexAs=\"subMaterial\"\n"
174 " removeFromMFieldObjectAs=\"subMaterialByObj\"\n"
175 " clearFieldAs=\"clearMaterials\"\n"
176 "\t >\n"
177 " </Field>\n"
178 "</FieldContainer>\n",
182 /*------------------------------ get -----------------------------------*/
184 FieldContainerType &MultiPassMaterialBase::getType(void)
186 return _type;
189 const FieldContainerType &MultiPassMaterialBase::getType(void) const
191 return _type;
194 UInt32 MultiPassMaterialBase::getContainerSize(void) const
196 return sizeof(MultiPassMaterial);
199 /*------------------------- decorator get ------------------------------*/
202 //! Get the MultiPassMaterial::_mfMaterials field.
203 const MFUnrecPrimeMaterialPtr *MultiPassMaterialBase::getMFMaterials(void) const
205 return &_mfMaterials;
208 MFUnrecPrimeMaterialPtr *MultiPassMaterialBase::editMFMaterials (void)
210 editMField(MaterialsFieldMask, _mfMaterials);
212 return &_mfMaterials;
214 PrimeMaterial * MultiPassMaterialBase::getMaterials(const UInt32 index) const
216 return _mfMaterials[index];
221 void MultiPassMaterialBase::addMaterial(PrimeMaterial * const value)
223 editMField(MaterialsFieldMask, _mfMaterials);
225 _mfMaterials.push_back(value);
228 void MultiPassMaterialBase::assignMaterialsFrom(const MFUnrecPrimeMaterialPtr &value)
230 MFUnrecPrimeMaterialPtr::const_iterator elemIt =
231 value.begin();
232 MFUnrecPrimeMaterialPtr::const_iterator elemEnd =
233 value.end ();
235 static_cast<MultiPassMaterial *>(this)->clearMaterials();
237 while(elemIt != elemEnd)
239 this->addMaterial(*elemIt);
241 ++elemIt;
245 void MultiPassMaterialBase::subMaterial(UInt32 uiIndex)
247 if(uiIndex < _mfMaterials.size())
249 editMField(MaterialsFieldMask, _mfMaterials);
251 _mfMaterials.erase(uiIndex);
255 void MultiPassMaterialBase::subMaterialByObj(PrimeMaterial * const value)
257 Int32 iElemIdx = _mfMaterials.findIndex(value);
259 if(iElemIdx != -1)
261 editMField(MaterialsFieldMask, _mfMaterials);
263 _mfMaterials.erase(iElemIdx);
266 void MultiPassMaterialBase::clearMaterials(void)
268 editMField(MaterialsFieldMask, _mfMaterials);
271 _mfMaterials.clear();
276 /*------------------------------ access -----------------------------------*/
278 SizeT MultiPassMaterialBase::getBinSize(ConstFieldMaskArg whichField)
280 SizeT returnValue = Inherited::getBinSize(whichField);
282 if(FieldBits::NoField != (MaterialsFieldMask & whichField))
284 returnValue += _mfMaterials.getBinSize();
287 return returnValue;
290 void MultiPassMaterialBase::copyToBin(BinaryDataHandler &pMem,
291 ConstFieldMaskArg whichField)
293 Inherited::copyToBin(pMem, whichField);
295 if(FieldBits::NoField != (MaterialsFieldMask & whichField))
297 _mfMaterials.copyToBin(pMem);
301 void MultiPassMaterialBase::copyFromBin(BinaryDataHandler &pMem,
302 ConstFieldMaskArg whichField)
304 Inherited::copyFromBin(pMem, whichField);
306 if(FieldBits::NoField != (MaterialsFieldMask & whichField))
308 editMField(MaterialsFieldMask, _mfMaterials);
309 _mfMaterials.copyFromBin(pMem);
313 //! create a new instance of the class
314 MultiPassMaterialTransitPtr MultiPassMaterialBase::createLocal(BitVector bFlags)
316 MultiPassMaterialTransitPtr fc;
318 if(getClassType().getPrototype() != NULL)
320 FieldContainerTransitPtr tmpPtr =
321 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
323 fc = dynamic_pointer_cast<MultiPassMaterial>(tmpPtr);
326 return fc;
329 //! create a new instance of the class, copy the container flags
330 MultiPassMaterialTransitPtr MultiPassMaterialBase::createDependent(BitVector bFlags)
332 MultiPassMaterialTransitPtr fc;
334 if(getClassType().getPrototype() != NULL)
336 FieldContainerTransitPtr tmpPtr =
337 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
339 fc = dynamic_pointer_cast<MultiPassMaterial>(tmpPtr);
342 return fc;
345 //! create a new instance of the class
346 MultiPassMaterialTransitPtr MultiPassMaterialBase::create(void)
348 MultiPassMaterialTransitPtr fc;
350 if(getClassType().getPrototype() != NULL)
352 FieldContainerTransitPtr tmpPtr =
353 getClassType().getPrototype()-> shallowCopy();
355 fc = dynamic_pointer_cast<MultiPassMaterial>(tmpPtr);
358 return fc;
361 MultiPassMaterial *MultiPassMaterialBase::createEmptyLocal(BitVector bFlags)
363 MultiPassMaterial *returnValue;
365 newPtr<MultiPassMaterial>(returnValue, bFlags);
367 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
369 return returnValue;
372 //! create an empty new instance of the class, do not copy the prototype
373 MultiPassMaterial *MultiPassMaterialBase::createEmpty(void)
375 MultiPassMaterial *returnValue;
377 newPtr<MultiPassMaterial>(returnValue, Thread::getCurrentLocalFlags());
379 returnValue->_pFieldFlags->_bNamespaceMask &=
380 ~Thread::getCurrentLocalFlags();
382 return returnValue;
386 FieldContainerTransitPtr MultiPassMaterialBase::shallowCopyLocal(
387 BitVector bFlags) const
389 MultiPassMaterial *tmpPtr;
391 newPtr(tmpPtr, dynamic_cast<const MultiPassMaterial *>(this), bFlags);
393 FieldContainerTransitPtr returnValue(tmpPtr);
395 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
397 return returnValue;
400 FieldContainerTransitPtr MultiPassMaterialBase::shallowCopyDependent(
401 BitVector bFlags) const
403 MultiPassMaterial *tmpPtr;
405 newPtr(tmpPtr, dynamic_cast<const MultiPassMaterial *>(this), ~bFlags);
407 FieldContainerTransitPtr returnValue(tmpPtr);
409 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
411 return returnValue;
414 FieldContainerTransitPtr MultiPassMaterialBase::shallowCopy(void) const
416 MultiPassMaterial *tmpPtr;
418 newPtr(tmpPtr,
419 dynamic_cast<const MultiPassMaterial *>(this),
420 Thread::getCurrentLocalFlags());
422 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
424 FieldContainerTransitPtr returnValue(tmpPtr);
426 return returnValue;
432 /*------------------------- constructors ----------------------------------*/
434 MultiPassMaterialBase::MultiPassMaterialBase(void) :
435 Inherited(),
436 _mfMaterials ()
440 MultiPassMaterialBase::MultiPassMaterialBase(const MultiPassMaterialBase &source) :
441 Inherited(source),
442 _mfMaterials ()
447 /*-------------------------- destructors ----------------------------------*/
449 MultiPassMaterialBase::~MultiPassMaterialBase(void)
453 void MultiPassMaterialBase::onCreate(const MultiPassMaterial *source)
455 Inherited::onCreate(source);
457 if(source != NULL)
459 MultiPassMaterial *pThis = static_cast<MultiPassMaterial *>(this);
461 MFUnrecPrimeMaterialPtr::const_iterator MaterialsIt =
462 source->_mfMaterials.begin();
463 MFUnrecPrimeMaterialPtr::const_iterator MaterialsEnd =
464 source->_mfMaterials.end ();
466 while(MaterialsIt != MaterialsEnd)
468 pThis->addMaterial(*MaterialsIt);
470 ++MaterialsIt;
475 GetFieldHandlePtr MultiPassMaterialBase::getHandleMaterials (void) const
477 MFUnrecPrimeMaterialPtr::GetHandlePtr returnValue(
478 new MFUnrecPrimeMaterialPtr::GetHandle(
479 &_mfMaterials,
480 this->getType().getFieldDesc(MaterialsFieldId),
481 const_cast<MultiPassMaterialBase *>(this)));
483 return returnValue;
486 EditFieldHandlePtr MultiPassMaterialBase::editHandleMaterials (void)
488 MFUnrecPrimeMaterialPtr::EditHandlePtr returnValue(
489 new MFUnrecPrimeMaterialPtr::EditHandle(
490 &_mfMaterials,
491 this->getType().getFieldDesc(MaterialsFieldId),
492 this));
494 returnValue->setAddMethod(
495 boost::bind(&MultiPassMaterial::addMaterial,
496 static_cast<MultiPassMaterial *>(this), _1));
497 returnValue->setRemoveMethod(
498 boost::bind(&MultiPassMaterial::subMaterial,
499 static_cast<MultiPassMaterial *>(this), _1));
500 returnValue->setRemoveObjMethod(
501 boost::bind(&MultiPassMaterial::subMaterialByObj,
502 static_cast<MultiPassMaterial *>(this), _1));
503 returnValue->setClearMethod(
504 boost::bind(&MultiPassMaterial::clearMaterials,
505 static_cast<MultiPassMaterial *>(this)));
507 editMField(MaterialsFieldMask, _mfMaterials);
509 return returnValue;
513 #ifdef OSG_MT_CPTR_ASPECT
514 void MultiPassMaterialBase::execSyncV( FieldContainer &oFrom,
515 ConstFieldMaskArg whichField,
516 AspectOffsetStore &oOffsets,
517 ConstFieldMaskArg syncMode,
518 const UInt32 uiSyncInfo)
520 MultiPassMaterial *pThis = static_cast<MultiPassMaterial *>(this);
522 pThis->execSync(static_cast<MultiPassMaterial *>(&oFrom),
523 whichField,
524 oOffsets,
525 syncMode,
526 uiSyncInfo);
528 #endif
531 #ifdef OSG_MT_CPTR_ASPECT
532 FieldContainer *MultiPassMaterialBase::createAspectCopy(
533 const FieldContainer *pRefAspect) const
535 MultiPassMaterial *returnValue;
537 newAspectCopy(returnValue,
538 dynamic_cast<const MultiPassMaterial *>(pRefAspect),
539 dynamic_cast<const MultiPassMaterial *>(this));
541 return returnValue;
543 #endif
545 void MultiPassMaterialBase::resolveLinks(void)
547 Inherited::resolveLinks();
549 static_cast<MultiPassMaterial *>(this)->clearMaterials();
555 OSG_END_NAMESPACE