changed: gcc8 base update
[opensg.git] / Source / System / State / Shader / Chunks / OSGShaderProgramVariableChunkBase.cpp
blob5a80c40fc39049f0c91d7735d0fa3088b22f7543
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 ShaderProgramVariableChunk!
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"
64 #include "OSGChangedFunctorMFields.h" // DestroyedFunctors default header
66 #include "OSGShaderProgramVariables.h" // Variables Class
68 #include "OSGShaderProgramVariableChunkBase.h"
69 #include "OSGShaderProgramVariableChunk.h"
71 #include <boost/bind.hpp>
73 OSG_BEGIN_NAMESPACE
75 /***************************************************************************\
76 * Description *
77 \***************************************************************************/
79 /*! \class OSG::ShaderProgramVariableChunk
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var ShaderProgramVariables * ShaderProgramVariableChunkBase::_sfVariables
91 /*! \var ChangedFunctorCallback ShaderProgramVariableChunkBase::_mfDestroyedFunctors
96 /***************************************************************************\
97 * FieldType/FieldTrait Instantiation *
98 \***************************************************************************/
100 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
101 PointerType FieldTraits<ShaderProgramVariableChunk *, nsOSG>::_type(
102 "ShaderProgramVariableChunkPtr",
103 "StateChunkPtr",
104 ShaderProgramVariableChunk::getClassType(),
105 nsOSG);
106 #endif
108 OSG_FIELDTRAITS_GETTYPE_NS(ShaderProgramVariableChunk *, nsOSG)
110 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
111 ShaderProgramVariableChunk *,
112 nsOSG)
114 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
115 ShaderProgramVariableChunk *,
116 nsOSG)
118 /***************************************************************************\
119 * Field Description *
120 \***************************************************************************/
122 void ShaderProgramVariableChunkBase::classDescInserter(TypeObject &oType)
124 FieldDescriptionBase *pDesc = NULL;
127 pDesc = new SFUnrecChildShaderProgramVariablesPtr::Description(
128 SFUnrecChildShaderProgramVariablesPtr::getClassType(),
129 "variables",
131 VariablesFieldId, VariablesFieldMask,
132 false,
133 (Field::SFDefaultFlags | Field::FStdAccess),
134 static_cast<FieldEditMethodSig>(&ShaderProgramVariableChunk::editHandleVariables),
135 static_cast<FieldGetMethodSig >(&ShaderProgramVariableChunk::getHandleVariables));
137 oType.addInitialDesc(pDesc);
139 pDesc = new MFChangedFunctorCallback::Description(
140 MFChangedFunctorCallback::getClassType(),
141 "destroyedFunctors",
143 DestroyedFunctorsFieldId, DestroyedFunctorsFieldMask,
144 true,
145 (Field::FClusterLocal),
146 static_cast <FieldEditMethodSig>(&ShaderProgramVariableChunk::invalidEditField),
147 static_cast <FieldGetMethodSig >(&ShaderProgramVariableChunk::invalidGetField));
149 oType.addInitialDesc(pDesc);
153 ShaderProgramVariableChunkBase::TypeObject ShaderProgramVariableChunkBase::_type(
154 ShaderProgramVariableChunkBase::getClassname(),
155 Inherited::getClassname(),
156 "NULL",
157 nsOSG, //Namespace
158 reinterpret_cast<PrototypeCreateF>(&ShaderProgramVariableChunkBase::createEmptyLocal),
159 reinterpret_cast<InitContainerF>(&ShaderProgramVariableChunk::initMethod),
160 reinterpret_cast<ExitContainerF>(&ShaderProgramVariableChunk::exitMethod),
161 reinterpret_cast<InitalInsertDescFunc>(
162 reinterpret_cast<void *>(&ShaderProgramVariableChunk::classDescInserter)),
163 false,
165 "<?xml version=\"1.0\"?>\n"
166 "\n"
167 "<FieldContainer\n"
168 " name=\"ShaderProgramVariableChunk\"\n"
169 " parent=\"StateChunk\"\n"
170 " library=\"System\"\n"
171 " pointerfieldtypes=\"both\"\n"
172 " structure=\"concrete\"\n"
173 " systemcomponent=\"true\"\n"
174 " parentsystemcomponent=\"true\"\n"
175 " decoratable=\"false\"\n"
176 " useLocalIncludes=\"false\"\n"
177 " docGroupBase=\"GrpSystemShader\"\n"
178 " >\n"
179 " <Field\n"
180 " name=\"variables\"\n"
181 " type=\"ShaderProgramVariables\"\n"
182 " cardinality=\"single\"\n"
183 " visibility=\"external\"\n"
184 " access=\"public\"\n"
185 " category=\"childpointer\"\n"
186 " childParentType=\"FieldContainer\"\n"
187 " linkParentField=\"Parents\"\n"
188 " >\n"
189 " </Field>\n"
190 "\n"
191 " <Field\n"
192 " name=\"destroyedFunctors\"\n"
193 " type=\"ChangedFunctorCallback\"\n"
194 " cardinality=\"multi\"\n"
195 " visibility=\"internal\"\n"
196 " access=\"none\"\n"
197 " defaultHeader=\"OSGChangedFunctorMFields.h\"\n"
198 " fieldFlags=\"FClusterLocal\"\n"
199 " >\n"
200 " </Field> \n"
201 "</FieldContainer>\n",
205 /*------------------------------ get -----------------------------------*/
207 FieldContainerType &ShaderProgramVariableChunkBase::getType(void)
209 return _type;
212 const FieldContainerType &ShaderProgramVariableChunkBase::getType(void) const
214 return _type;
217 UInt32 ShaderProgramVariableChunkBase::getContainerSize(void) const
219 return sizeof(ShaderProgramVariableChunk);
222 /*------------------------- decorator get ------------------------------*/
225 //! Get the ShaderProgramVariableChunk::_sfVariables field.
226 const SFUnrecChildShaderProgramVariablesPtr *ShaderProgramVariableChunkBase::getSFVariables(void) const
228 return &_sfVariables;
231 SFUnrecChildShaderProgramVariablesPtr *ShaderProgramVariableChunkBase::editSFVariables (void)
233 editSField(VariablesFieldMask);
235 return &_sfVariables;
238 //! Get the value of the ShaderProgramVariableChunk::_sfVariables field.
239 ShaderProgramVariables * ShaderProgramVariableChunkBase::getVariables(void) const
241 return _sfVariables.getValue();
244 //! Set the value of the ShaderProgramVariableChunk::_sfVariables field.
245 void ShaderProgramVariableChunkBase::setVariables(ShaderProgramVariables * const value)
247 editSField(VariablesFieldMask);
249 _sfVariables.setValue(value);
258 /*------------------------------ access -----------------------------------*/
260 SizeT ShaderProgramVariableChunkBase::getBinSize(ConstFieldMaskArg whichField)
262 SizeT returnValue = Inherited::getBinSize(whichField);
264 if(FieldBits::NoField != (VariablesFieldMask & whichField))
266 returnValue += _sfVariables.getBinSize();
268 if(FieldBits::NoField != (DestroyedFunctorsFieldMask & whichField))
270 returnValue += _mfDestroyedFunctors.getBinSize();
273 return returnValue;
276 void ShaderProgramVariableChunkBase::copyToBin(BinaryDataHandler &pMem,
277 ConstFieldMaskArg whichField)
279 Inherited::copyToBin(pMem, whichField);
281 if(FieldBits::NoField != (VariablesFieldMask & whichField))
283 _sfVariables.copyToBin(pMem);
285 if(FieldBits::NoField != (DestroyedFunctorsFieldMask & whichField))
287 _mfDestroyedFunctors.copyToBin(pMem);
291 void ShaderProgramVariableChunkBase::copyFromBin(BinaryDataHandler &pMem,
292 ConstFieldMaskArg whichField)
294 Inherited::copyFromBin(pMem, whichField);
296 if(FieldBits::NoField != (VariablesFieldMask & whichField))
298 editSField(VariablesFieldMask);
299 _sfVariables.copyFromBin(pMem);
301 if(FieldBits::NoField != (DestroyedFunctorsFieldMask & whichField))
303 editMField(DestroyedFunctorsFieldMask, _mfDestroyedFunctors);
304 _mfDestroyedFunctors.copyFromBin(pMem);
308 //! create a new instance of the class
309 ShaderProgramVariableChunkTransitPtr ShaderProgramVariableChunkBase::createLocal(BitVector bFlags)
311 ShaderProgramVariableChunkTransitPtr fc;
313 if(getClassType().getPrototype() != NULL)
315 FieldContainerTransitPtr tmpPtr =
316 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
318 fc = dynamic_pointer_cast<ShaderProgramVariableChunk>(tmpPtr);
321 return fc;
324 //! create a new instance of the class, copy the container flags
325 ShaderProgramVariableChunkTransitPtr ShaderProgramVariableChunkBase::createDependent(BitVector bFlags)
327 ShaderProgramVariableChunkTransitPtr fc;
329 if(getClassType().getPrototype() != NULL)
331 FieldContainerTransitPtr tmpPtr =
332 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
334 fc = dynamic_pointer_cast<ShaderProgramVariableChunk>(tmpPtr);
337 return fc;
340 //! create a new instance of the class
341 ShaderProgramVariableChunkTransitPtr ShaderProgramVariableChunkBase::create(void)
343 ShaderProgramVariableChunkTransitPtr fc;
345 if(getClassType().getPrototype() != NULL)
347 FieldContainerTransitPtr tmpPtr =
348 getClassType().getPrototype()-> shallowCopy();
350 fc = dynamic_pointer_cast<ShaderProgramVariableChunk>(tmpPtr);
353 return fc;
356 ShaderProgramVariableChunk *ShaderProgramVariableChunkBase::createEmptyLocal(BitVector bFlags)
358 ShaderProgramVariableChunk *returnValue;
360 newPtr<ShaderProgramVariableChunk>(returnValue, bFlags);
362 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
364 return returnValue;
367 //! create an empty new instance of the class, do not copy the prototype
368 ShaderProgramVariableChunk *ShaderProgramVariableChunkBase::createEmpty(void)
370 ShaderProgramVariableChunk *returnValue;
372 newPtr<ShaderProgramVariableChunk>(returnValue, Thread::getCurrentLocalFlags());
374 returnValue->_pFieldFlags->_bNamespaceMask &=
375 ~Thread::getCurrentLocalFlags();
377 return returnValue;
381 FieldContainerTransitPtr ShaderProgramVariableChunkBase::shallowCopyLocal(
382 BitVector bFlags) const
384 ShaderProgramVariableChunk *tmpPtr;
386 newPtr(tmpPtr, dynamic_cast<const ShaderProgramVariableChunk *>(this), bFlags);
388 FieldContainerTransitPtr returnValue(tmpPtr);
390 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
392 return returnValue;
395 FieldContainerTransitPtr ShaderProgramVariableChunkBase::shallowCopyDependent(
396 BitVector bFlags) const
398 ShaderProgramVariableChunk *tmpPtr;
400 newPtr(tmpPtr, dynamic_cast<const ShaderProgramVariableChunk *>(this), ~bFlags);
402 FieldContainerTransitPtr returnValue(tmpPtr);
404 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
406 return returnValue;
409 FieldContainerTransitPtr ShaderProgramVariableChunkBase::shallowCopy(void) const
411 ShaderProgramVariableChunk *tmpPtr;
413 newPtr(tmpPtr,
414 dynamic_cast<const ShaderProgramVariableChunk *>(this),
415 Thread::getCurrentLocalFlags());
417 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
419 FieldContainerTransitPtr returnValue(tmpPtr);
421 return returnValue;
427 /*------------------------- constructors ----------------------------------*/
429 ShaderProgramVariableChunkBase::ShaderProgramVariableChunkBase(void) :
430 Inherited(),
431 _sfVariables (this,
432 VariablesFieldId,
433 ShaderProgramVariables::ParentsFieldId),
434 _mfDestroyedFunctors ()
438 ShaderProgramVariableChunkBase::ShaderProgramVariableChunkBase(const ShaderProgramVariableChunkBase &source) :
439 Inherited(source),
440 _sfVariables (this,
441 VariablesFieldId,
442 ShaderProgramVariables::ParentsFieldId),
443 _mfDestroyedFunctors (source._mfDestroyedFunctors )
448 /*-------------------------- destructors ----------------------------------*/
450 ShaderProgramVariableChunkBase::~ShaderProgramVariableChunkBase(void)
454 /*-------------------------------------------------------------------------*/
455 /* Child linking */
457 bool ShaderProgramVariableChunkBase::unlinkChild(
458 FieldContainer * const pChild,
459 UInt16 const childFieldId)
461 if(childFieldId == VariablesFieldId)
463 ShaderProgramVariables * pTypedChild =
464 dynamic_cast<ShaderProgramVariables *>(pChild);
466 if(pTypedChild != NULL)
468 if(_sfVariables.getValue() == pTypedChild)
470 editSField(VariablesFieldMask);
472 _sfVariables.setValue(NULL);
474 return true;
477 SWARNING << "Parent ([" << this
478 << "] id [" << this->getId()
479 << "] type [" << this->getType().getCName()
480 << "] childFieldId [" << childFieldId
481 << "]) - Child ([" << pChild
482 << "] id [" << pChild->getId()
483 << "] type [" << pChild->getType().getCName()
484 << "]): link inconsistent!"
485 << std::endl;
487 return false;
490 return false;
494 return Inherited::unlinkChild(pChild, childFieldId);
497 void ShaderProgramVariableChunkBase::onCreate(const ShaderProgramVariableChunk *source)
499 Inherited::onCreate(source);
501 if(source != NULL)
503 ShaderProgramVariableChunk *pThis = static_cast<ShaderProgramVariableChunk *>(this);
505 pThis->setVariables(source->getVariables());
509 GetFieldHandlePtr ShaderProgramVariableChunkBase::getHandleVariables (void) const
511 SFUnrecChildShaderProgramVariablesPtr::GetHandlePtr returnValue(
512 new SFUnrecChildShaderProgramVariablesPtr::GetHandle(
513 &_sfVariables,
514 this->getType().getFieldDesc(VariablesFieldId),
515 const_cast<ShaderProgramVariableChunkBase *>(this)));
517 return returnValue;
520 EditFieldHandlePtr ShaderProgramVariableChunkBase::editHandleVariables (void)
522 SFUnrecChildShaderProgramVariablesPtr::EditHandlePtr returnValue(
523 new SFUnrecChildShaderProgramVariablesPtr::EditHandle(
524 &_sfVariables,
525 this->getType().getFieldDesc(VariablesFieldId),
526 this));
528 returnValue->setSetMethod(
529 boost::bind(&ShaderProgramVariableChunk::setVariables,
530 static_cast<ShaderProgramVariableChunk *>(this), _1));
532 editSField(VariablesFieldMask);
534 return returnValue;
537 GetFieldHandlePtr ShaderProgramVariableChunkBase::getHandleDestroyedFunctors (void) const
539 MFChangedFunctorCallback::GetHandlePtr returnValue;
541 return returnValue;
544 EditFieldHandlePtr ShaderProgramVariableChunkBase::editHandleDestroyedFunctors(void)
546 EditFieldHandlePtr returnValue;
548 return returnValue;
552 #ifdef OSG_MT_CPTR_ASPECT
553 void ShaderProgramVariableChunkBase::execSyncV( FieldContainer &oFrom,
554 ConstFieldMaskArg whichField,
555 AspectOffsetStore &oOffsets,
556 ConstFieldMaskArg syncMode,
557 const UInt32 uiSyncInfo)
559 ShaderProgramVariableChunk *pThis = static_cast<ShaderProgramVariableChunk *>(this);
561 pThis->execSync(static_cast<ShaderProgramVariableChunk *>(&oFrom),
562 whichField,
563 oOffsets,
564 syncMode,
565 uiSyncInfo);
567 #endif
570 #ifdef OSG_MT_CPTR_ASPECT
571 FieldContainer *ShaderProgramVariableChunkBase::createAspectCopy(
572 const FieldContainer *pRefAspect) const
574 ShaderProgramVariableChunk *returnValue;
576 newAspectCopy(returnValue,
577 dynamic_cast<const ShaderProgramVariableChunk *>(pRefAspect),
578 dynamic_cast<const ShaderProgramVariableChunk *>(this));
580 return returnValue;
582 #endif
584 void ShaderProgramVariableChunkBase::resolveLinks(void)
586 Inherited::resolveLinks();
588 static_cast<ShaderProgramVariableChunk *>(this)->setVariables(NULL);
590 #ifdef OSG_MT_CPTR_ASPECT
591 AspectOffsetStore oOffsets;
593 _pAspectStore->fillOffsetArray(oOffsets, this);
594 #endif
596 #ifdef OSG_MT_CPTR_ASPECT
597 _mfDestroyedFunctors.terminateShare(Thread::getCurrentAspect(),
598 oOffsets);
599 #endif
603 OSG_END_NAMESPACE