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 ShaderProgramVariableChunk!
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"
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>
75 /***************************************************************************\
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",
104 ShaderProgramVariableChunk::getClassType(),
108 OSG_FIELDTRAITS_GETTYPE_NS(ShaderProgramVariableChunk
*, nsOSG
)
110 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
111 ShaderProgramVariableChunk
*,
114 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
115 ShaderProgramVariableChunk
*,
118 /***************************************************************************\
119 * Field Description *
120 \***************************************************************************/
122 void ShaderProgramVariableChunkBase::classDescInserter(TypeObject
&oType
)
124 FieldDescriptionBase
*pDesc
= NULL
;
127 pDesc
= new SFUnrecChildShaderProgramVariablesPtr::Description(
128 SFUnrecChildShaderProgramVariablesPtr::getClassType(),
131 VariablesFieldId
, VariablesFieldMask
,
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(),
143 DestroyedFunctorsFieldId
, DestroyedFunctorsFieldMask
,
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(),
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
)),
165 "<?xml version=\"1.0\"?>\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"
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"
192 " name=\"destroyedFunctors\"\n"
193 " type=\"ChangedFunctorCallback\"\n"
194 " cardinality=\"multi\"\n"
195 " visibility=\"internal\"\n"
197 " defaultHeader=\"OSGChangedFunctorMFields.h\"\n"
198 " fieldFlags=\"FClusterLocal\"\n"
201 "</FieldContainer>\n",
205 /*------------------------------ get -----------------------------------*/
207 FieldContainerType
&ShaderProgramVariableChunkBase::getType(void)
212 const FieldContainerType
&ShaderProgramVariableChunkBase::getType(void) const
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();
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
);
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
);
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
);
356 ShaderProgramVariableChunk
*ShaderProgramVariableChunkBase::createEmptyLocal(BitVector bFlags
)
358 ShaderProgramVariableChunk
*returnValue
;
360 newPtr
<ShaderProgramVariableChunk
>(returnValue
, bFlags
);
362 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
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();
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
;
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
;
409 FieldContainerTransitPtr
ShaderProgramVariableChunkBase::shallowCopy(void) const
411 ShaderProgramVariableChunk
*tmpPtr
;
414 dynamic_cast<const ShaderProgramVariableChunk
*>(this),
415 Thread::getCurrentLocalFlags());
417 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
419 FieldContainerTransitPtr
returnValue(tmpPtr
);
427 /*------------------------- constructors ----------------------------------*/
429 ShaderProgramVariableChunkBase::ShaderProgramVariableChunkBase(void) :
433 ShaderProgramVariables::ParentsFieldId
),
434 _mfDestroyedFunctors ()
438 ShaderProgramVariableChunkBase::ShaderProgramVariableChunkBase(const ShaderProgramVariableChunkBase
&source
) :
442 ShaderProgramVariables::ParentsFieldId
),
443 _mfDestroyedFunctors (source
._mfDestroyedFunctors
)
448 /*-------------------------- destructors ----------------------------------*/
450 ShaderProgramVariableChunkBase::~ShaderProgramVariableChunkBase(void)
454 /*-------------------------------------------------------------------------*/
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
);
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!"
494 return Inherited::unlinkChild(pChild
, childFieldId
);
497 void ShaderProgramVariableChunkBase::onCreate(const ShaderProgramVariableChunk
*source
)
499 Inherited::onCreate(source
);
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(
514 this->getType().getFieldDesc(VariablesFieldId
),
515 const_cast<ShaderProgramVariableChunkBase
*>(this)));
520 EditFieldHandlePtr
ShaderProgramVariableChunkBase::editHandleVariables (void)
522 SFUnrecChildShaderProgramVariablesPtr::EditHandlePtr
returnValue(
523 new SFUnrecChildShaderProgramVariablesPtr::EditHandle(
525 this->getType().getFieldDesc(VariablesFieldId
),
528 returnValue
->setSetMethod(
529 boost::bind(&ShaderProgramVariableChunk::setVariables
,
530 static_cast<ShaderProgramVariableChunk
*>(this), _1
));
532 editSField(VariablesFieldMask
);
537 GetFieldHandlePtr
ShaderProgramVariableChunkBase::getHandleDestroyedFunctors (void) const
539 MFChangedFunctorCallback::GetHandlePtr returnValue
;
544 EditFieldHandlePtr
ShaderProgramVariableChunkBase::editHandleDestroyedFunctors(void)
546 EditFieldHandlePtr 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
),
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));
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);
596 #ifdef OSG_MT_CPTR_ASPECT
597 _mfDestroyedFunctors
.terminateShare(Thread::getCurrentAspect(),