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 ShaderExecutableVarChunk!
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"
65 #include "OSGShaderProgramVariableChunk.h" // ProgramVarChunks Class
66 #include "OSGShaderProgramVariables.h" // Variables Class
68 #include "OSGShaderExecutableVarChunkBase.h"
69 #include "OSGShaderExecutableVarChunk.h"
71 #include <boost/bind.hpp>
75 /***************************************************************************\
77 \***************************************************************************/
79 /*! \class OSG::ShaderExecutableVarChunk
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var ShaderProgramVariableChunk * ShaderExecutableVarChunkBase::_mfProgramVarChunks
91 /*! \var ShaderProgramVariables * ShaderExecutableVarChunkBase::_sfVariables
92 fragment program object
95 /*! \var Int32 ShaderExecutableVarChunkBase::_mfVariableLocations
96 fragment program object
99 /*! \var UInt32 ShaderExecutableVarChunkBase::_sfActiveShader
100 fragment program object
104 /***************************************************************************\
105 * FieldType/FieldTrait Instantiation *
106 \***************************************************************************/
108 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
109 PointerType FieldTraits
<ShaderExecutableVarChunk
*, nsOSG
>::_type(
110 "ShaderExecutableVarChunkPtr",
112 ShaderExecutableVarChunk::getClassType(),
116 OSG_FIELDTRAITS_GETTYPE_NS(ShaderExecutableVarChunk
*, nsOSG
)
118 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
119 ShaderExecutableVarChunk
*,
122 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
123 ShaderExecutableVarChunk
*,
126 /***************************************************************************\
127 * Field Description *
128 \***************************************************************************/
130 void ShaderExecutableVarChunkBase::classDescInserter(TypeObject
&oType
)
132 FieldDescriptionBase
*pDesc
= NULL
;
135 pDesc
= new MFUncountedShaderProgramVariableChunkPtr::Description(
136 MFUncountedShaderProgramVariableChunkPtr::getClassType(),
139 ProgramVarChunksFieldId
, ProgramVarChunksFieldMask
,
141 (Field::MFDefaultFlags
| Field::FStdAccess
),
142 static_cast <FieldEditMethodSig
>(&ShaderExecutableVarChunk::invalidEditField
),
143 static_cast <FieldGetMethodSig
>(&ShaderExecutableVarChunk::invalidGetField
));
145 oType
.addInitialDesc(pDesc
);
147 pDesc
= new SFUnrecChildShaderProgramVariablesPtr::Description(
148 SFUnrecChildShaderProgramVariablesPtr::getClassType(),
150 "fragment program object\n",
151 VariablesFieldId
, VariablesFieldMask
,
153 (Field::SFDefaultFlags
| Field::FStdAccess
),
154 static_cast<FieldEditMethodSig
>(&ShaderExecutableVarChunk::editHandleVariables
),
155 static_cast<FieldGetMethodSig
>(&ShaderExecutableVarChunk::getHandleVariables
));
157 oType
.addInitialDesc(pDesc
);
159 pDesc
= new MFInt32::Description(
160 MFInt32::getClassType(),
162 "fragment program object\n",
163 VariableLocationsFieldId
, VariableLocationsFieldMask
,
165 (Field::MFDefaultFlags
| Field::FStdAccess
),
166 static_cast<FieldEditMethodSig
>(&ShaderExecutableVarChunk::editHandleVariableLocations
),
167 static_cast<FieldGetMethodSig
>(&ShaderExecutableVarChunk::getHandleVariableLocations
));
169 oType
.addInitialDesc(pDesc
);
171 pDesc
= new SFUInt32::Description(
172 SFUInt32::getClassType(),
174 "fragment program object\n",
175 ActiveShaderFieldId
, ActiveShaderFieldMask
,
177 (Field::SFDefaultFlags
| Field::FStdAccess
),
178 static_cast<FieldEditMethodSig
>(&ShaderExecutableVarChunk::editHandleActiveShader
),
179 static_cast<FieldGetMethodSig
>(&ShaderExecutableVarChunk::getHandleActiveShader
));
181 oType
.addInitialDesc(pDesc
);
185 ShaderExecutableVarChunkBase::TypeObject
ShaderExecutableVarChunkBase::_type(
186 ShaderExecutableVarChunkBase::getClassname(),
187 Inherited::getClassname(),
190 reinterpret_cast<PrototypeCreateF
>(&ShaderExecutableVarChunkBase::createEmptyLocal
),
191 reinterpret_cast<InitContainerF
>(&ShaderExecutableVarChunk::initMethod
),
192 reinterpret_cast<ExitContainerF
>(&ShaderExecutableVarChunk::exitMethod
),
193 reinterpret_cast<InitalInsertDescFunc
>(
194 reinterpret_cast<void *>(&ShaderExecutableVarChunk::classDescInserter
)),
197 "<?xml version=\"1.0\"?>\n"
200 " name=\"ShaderExecutableVarChunk\"\n"
201 " parent=\"StateChunk\"\n"
202 " library=\"System\"\n"
203 " pointerfieldtypes=\"both\"\n"
204 " structure=\"concrete\"\n"
205 " systemcomponent=\"true\"\n"
206 " parentsystemcomponent=\"true\"\n"
207 " decoratable=\"false\"\n"
208 " useLocalIncludes=\"false\"\n"
209 " docGroupBase=\"GrpSystemShader\"\n"
212 "\t name=\"programVarChunks\"\n"
213 "\t type=\"ShaderProgramVariableChunk\"\n"
214 "\t cardinality=\"multi\"\n"
215 "\t visibility=\"external\"\n"
216 "\t access=\"none\"\n"
217 " category=\"uncountedpointer\"\n"
221 "\t name=\"ShaderExecytableChunk\"\n"
222 "\t type=\"ShaderExecutableChunk\"\n"
223 "\t cardinality=\"single\"\n"
224 "\t visibility=\"external\"\n"
225 "\t defaultValue=\"NULL\"\n"
226 "\t access=\"public\"\n"
227 " category=\"pointer\"\n"
231 "\t name=\"variables\"\n"
232 "\t type=\"ShaderProgramVariables\"\n"
233 "\t cardinality=\"single\"\n"
234 "\t visibility=\"external\"\n"
235 "\t access=\"public\"\n"
236 " category=\"childpointer\"\n"
237 " childParentType=\"FieldContainer\"\n"
238 " linkParentField=\"Parents\"\n"
240 "\tfragment program object\n"
243 "\t name=\"variableLocations\"\n"
244 "\t type=\"Int32\"\n"
245 "\t cardinality=\"multi\"\n"
246 "\t visibility=\"internal\"\n"
247 "\t access=\"protected\"\n"
249 "\tfragment program object\n"
252 "\t name=\"activeShader\"\n"
253 "\t type=\"UInt32\"\n"
254 "\t cardinality=\"single\"\n"
255 "\t visibility=\"internal\"\n"
256 "\t access=\"protected\"\n"
258 "\tfragment program object\n"
260 "</FieldContainer>\n",
264 /*------------------------------ get -----------------------------------*/
266 FieldContainerType
&ShaderExecutableVarChunkBase::getType(void)
271 const FieldContainerType
&ShaderExecutableVarChunkBase::getType(void) const
276 UInt32
ShaderExecutableVarChunkBase::getContainerSize(void) const
278 return sizeof(ShaderExecutableVarChunk
);
281 /*------------------------- decorator get ------------------------------*/
285 //! Get the ShaderExecutableVarChunk::_sfVariables field.
286 const SFUnrecChildShaderProgramVariablesPtr
*ShaderExecutableVarChunkBase::getSFVariables(void) const
288 return &_sfVariables
;
291 SFUnrecChildShaderProgramVariablesPtr
*ShaderExecutableVarChunkBase::editSFVariables (void)
293 editSField(VariablesFieldMask
);
295 return &_sfVariables
;
298 //! Get the value of the ShaderExecutableVarChunk::_sfVariables field.
299 ShaderProgramVariables
* ShaderExecutableVarChunkBase::getVariables(void) const
301 return _sfVariables
.getValue();
304 //! Set the value of the ShaderExecutableVarChunk::_sfVariables field.
305 void ShaderExecutableVarChunkBase::setVariables(ShaderProgramVariables
* const value
)
307 editSField(VariablesFieldMask
);
309 _sfVariables
.setValue(value
);
313 MFInt32
*ShaderExecutableVarChunkBase::editMFVariableLocations(void)
315 editMField(VariableLocationsFieldMask
, _mfVariableLocations
);
317 return &_mfVariableLocations
;
320 const MFInt32
*ShaderExecutableVarChunkBase::getMFVariableLocations(void) const
322 return &_mfVariableLocations
;
326 SFUInt32
*ShaderExecutableVarChunkBase::editSFActiveShader(void)
328 editSField(ActiveShaderFieldMask
);
330 return &_sfActiveShader
;
333 const SFUInt32
*ShaderExecutableVarChunkBase::getSFActiveShader(void) const
335 return &_sfActiveShader
;
343 /*------------------------------ access -----------------------------------*/
345 SizeT
ShaderExecutableVarChunkBase::getBinSize(ConstFieldMaskArg whichField
)
347 SizeT returnValue
= Inherited::getBinSize(whichField
);
349 if(FieldBits::NoField
!= (ProgramVarChunksFieldMask
& whichField
))
351 returnValue
+= _mfProgramVarChunks
.getBinSize();
353 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
355 returnValue
+= _sfVariables
.getBinSize();
357 if(FieldBits::NoField
!= (VariableLocationsFieldMask
& whichField
))
359 returnValue
+= _mfVariableLocations
.getBinSize();
361 if(FieldBits::NoField
!= (ActiveShaderFieldMask
& whichField
))
363 returnValue
+= _sfActiveShader
.getBinSize();
369 void ShaderExecutableVarChunkBase::copyToBin(BinaryDataHandler
&pMem
,
370 ConstFieldMaskArg whichField
)
372 Inherited::copyToBin(pMem
, whichField
);
374 if(FieldBits::NoField
!= (ProgramVarChunksFieldMask
& whichField
))
376 _mfProgramVarChunks
.copyToBin(pMem
);
378 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
380 _sfVariables
.copyToBin(pMem
);
382 if(FieldBits::NoField
!= (VariableLocationsFieldMask
& whichField
))
384 _mfVariableLocations
.copyToBin(pMem
);
386 if(FieldBits::NoField
!= (ActiveShaderFieldMask
& whichField
))
388 _sfActiveShader
.copyToBin(pMem
);
392 void ShaderExecutableVarChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
393 ConstFieldMaskArg whichField
)
395 Inherited::copyFromBin(pMem
, whichField
);
397 if(FieldBits::NoField
!= (ProgramVarChunksFieldMask
& whichField
))
399 editMField(ProgramVarChunksFieldMask
, _mfProgramVarChunks
);
400 _mfProgramVarChunks
.copyFromBin(pMem
);
402 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
404 editSField(VariablesFieldMask
);
405 _sfVariables
.copyFromBin(pMem
);
407 if(FieldBits::NoField
!= (VariableLocationsFieldMask
& whichField
))
409 editMField(VariableLocationsFieldMask
, _mfVariableLocations
);
410 _mfVariableLocations
.copyFromBin(pMem
);
412 if(FieldBits::NoField
!= (ActiveShaderFieldMask
& whichField
))
414 editSField(ActiveShaderFieldMask
);
415 _sfActiveShader
.copyFromBin(pMem
);
419 //! create a new instance of the class
420 ShaderExecutableVarChunkTransitPtr
ShaderExecutableVarChunkBase::createLocal(BitVector bFlags
)
422 ShaderExecutableVarChunkTransitPtr fc
;
424 if(getClassType().getPrototype() != NULL
)
426 FieldContainerTransitPtr tmpPtr
=
427 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
429 fc
= dynamic_pointer_cast
<ShaderExecutableVarChunk
>(tmpPtr
);
435 //! create a new instance of the class, copy the container flags
436 ShaderExecutableVarChunkTransitPtr
ShaderExecutableVarChunkBase::createDependent(BitVector bFlags
)
438 ShaderExecutableVarChunkTransitPtr fc
;
440 if(getClassType().getPrototype() != NULL
)
442 FieldContainerTransitPtr tmpPtr
=
443 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
445 fc
= dynamic_pointer_cast
<ShaderExecutableVarChunk
>(tmpPtr
);
451 //! create a new instance of the class
452 ShaderExecutableVarChunkTransitPtr
ShaderExecutableVarChunkBase::create(void)
454 ShaderExecutableVarChunkTransitPtr fc
;
456 if(getClassType().getPrototype() != NULL
)
458 FieldContainerTransitPtr tmpPtr
=
459 getClassType().getPrototype()-> shallowCopy();
461 fc
= dynamic_pointer_cast
<ShaderExecutableVarChunk
>(tmpPtr
);
467 ShaderExecutableVarChunk
*ShaderExecutableVarChunkBase::createEmptyLocal(BitVector bFlags
)
469 ShaderExecutableVarChunk
*returnValue
;
471 newPtr
<ShaderExecutableVarChunk
>(returnValue
, bFlags
);
473 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
478 //! create an empty new instance of the class, do not copy the prototype
479 ShaderExecutableVarChunk
*ShaderExecutableVarChunkBase::createEmpty(void)
481 ShaderExecutableVarChunk
*returnValue
;
483 newPtr
<ShaderExecutableVarChunk
>(returnValue
, Thread::getCurrentLocalFlags());
485 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
486 ~Thread::getCurrentLocalFlags();
492 FieldContainerTransitPtr
ShaderExecutableVarChunkBase::shallowCopyLocal(
493 BitVector bFlags
) const
495 ShaderExecutableVarChunk
*tmpPtr
;
497 newPtr(tmpPtr
, dynamic_cast<const ShaderExecutableVarChunk
*>(this), bFlags
);
499 FieldContainerTransitPtr
returnValue(tmpPtr
);
501 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
506 FieldContainerTransitPtr
ShaderExecutableVarChunkBase::shallowCopyDependent(
507 BitVector bFlags
) const
509 ShaderExecutableVarChunk
*tmpPtr
;
511 newPtr(tmpPtr
, dynamic_cast<const ShaderExecutableVarChunk
*>(this), ~bFlags
);
513 FieldContainerTransitPtr
returnValue(tmpPtr
);
515 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
520 FieldContainerTransitPtr
ShaderExecutableVarChunkBase::shallowCopy(void) const
522 ShaderExecutableVarChunk
*tmpPtr
;
525 dynamic_cast<const ShaderExecutableVarChunk
*>(this),
526 Thread::getCurrentLocalFlags());
528 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
530 FieldContainerTransitPtr
returnValue(tmpPtr
);
538 /*------------------------- constructors ----------------------------------*/
540 ShaderExecutableVarChunkBase::ShaderExecutableVarChunkBase(void) :
542 _mfProgramVarChunks (),
545 ShaderProgramVariables::ParentsFieldId
),
546 _mfVariableLocations (),
551 ShaderExecutableVarChunkBase::ShaderExecutableVarChunkBase(const ShaderExecutableVarChunkBase
&source
) :
553 _mfProgramVarChunks (),
556 ShaderProgramVariables::ParentsFieldId
),
557 _mfVariableLocations (source
._mfVariableLocations
),
558 _sfActiveShader (source
._sfActiveShader
)
563 /*-------------------------- destructors ----------------------------------*/
565 ShaderExecutableVarChunkBase::~ShaderExecutableVarChunkBase(void)
569 /*-------------------------------------------------------------------------*/
572 bool ShaderExecutableVarChunkBase::unlinkChild(
573 FieldContainer
* const pChild
,
574 UInt16
const childFieldId
)
576 if(childFieldId
== VariablesFieldId
)
578 ShaderProgramVariables
* pTypedChild
=
579 dynamic_cast<ShaderProgramVariables
*>(pChild
);
581 if(pTypedChild
!= NULL
)
583 if(_sfVariables
.getValue() == pTypedChild
)
585 editSField(VariablesFieldMask
);
587 _sfVariables
.setValue(NULL
);
592 SWARNING
<< "Parent ([" << this
593 << "] id [" << this->getId()
594 << "] type [" << this->getType().getCName()
595 << "] childFieldId [" << childFieldId
596 << "]) - Child ([" << pChild
597 << "] id [" << pChild
->getId()
598 << "] type [" << pChild
->getType().getCName()
599 << "]): link inconsistent!"
609 return Inherited::unlinkChild(pChild
, childFieldId
);
612 void ShaderExecutableVarChunkBase::onCreate(const ShaderExecutableVarChunk
*source
)
614 Inherited::onCreate(source
);
618 ShaderExecutableVarChunk
*pThis
= static_cast<ShaderExecutableVarChunk
*>(this);
620 pThis
->setVariables(source
->getVariables());
624 GetFieldHandlePtr
ShaderExecutableVarChunkBase::getHandleProgramVarChunks (void) const
626 MFUncountedShaderProgramVariableChunkPtr::GetHandlePtr returnValue
;
631 EditFieldHandlePtr
ShaderExecutableVarChunkBase::editHandleProgramVarChunks(void)
633 EditFieldHandlePtr returnValue
;
638 GetFieldHandlePtr
ShaderExecutableVarChunkBase::getHandleVariables (void) const
640 SFUnrecChildShaderProgramVariablesPtr::GetHandlePtr
returnValue(
641 new SFUnrecChildShaderProgramVariablesPtr::GetHandle(
643 this->getType().getFieldDesc(VariablesFieldId
),
644 const_cast<ShaderExecutableVarChunkBase
*>(this)));
649 EditFieldHandlePtr
ShaderExecutableVarChunkBase::editHandleVariables (void)
651 SFUnrecChildShaderProgramVariablesPtr::EditHandlePtr
returnValue(
652 new SFUnrecChildShaderProgramVariablesPtr::EditHandle(
654 this->getType().getFieldDesc(VariablesFieldId
),
657 returnValue
->setSetMethod(
658 boost::bind(&ShaderExecutableVarChunk::setVariables
,
659 static_cast<ShaderExecutableVarChunk
*>(this), _1
));
661 editSField(VariablesFieldMask
);
666 GetFieldHandlePtr
ShaderExecutableVarChunkBase::getHandleVariableLocations (void) const
668 MFInt32::GetHandlePtr
returnValue(
669 new MFInt32::GetHandle(
670 &_mfVariableLocations
,
671 this->getType().getFieldDesc(VariableLocationsFieldId
),
672 const_cast<ShaderExecutableVarChunkBase
*>(this)));
677 EditFieldHandlePtr
ShaderExecutableVarChunkBase::editHandleVariableLocations(void)
679 MFInt32::EditHandlePtr
returnValue(
680 new MFInt32::EditHandle(
681 &_mfVariableLocations
,
682 this->getType().getFieldDesc(VariableLocationsFieldId
),
686 editMField(VariableLocationsFieldMask
, _mfVariableLocations
);
691 GetFieldHandlePtr
ShaderExecutableVarChunkBase::getHandleActiveShader (void) const
693 SFUInt32::GetHandlePtr
returnValue(
694 new SFUInt32::GetHandle(
696 this->getType().getFieldDesc(ActiveShaderFieldId
),
697 const_cast<ShaderExecutableVarChunkBase
*>(this)));
702 EditFieldHandlePtr
ShaderExecutableVarChunkBase::editHandleActiveShader (void)
704 SFUInt32::EditHandlePtr
returnValue(
705 new SFUInt32::EditHandle(
707 this->getType().getFieldDesc(ActiveShaderFieldId
),
711 editSField(ActiveShaderFieldMask
);
717 #ifdef OSG_MT_CPTR_ASPECT
718 void ShaderExecutableVarChunkBase::execSyncV( FieldContainer
&oFrom
,
719 ConstFieldMaskArg whichField
,
720 AspectOffsetStore
&oOffsets
,
721 ConstFieldMaskArg syncMode
,
722 const UInt32 uiSyncInfo
)
724 ShaderExecutableVarChunk
*pThis
= static_cast<ShaderExecutableVarChunk
*>(this);
726 pThis
->execSync(static_cast<ShaderExecutableVarChunk
*>(&oFrom
),
735 #ifdef OSG_MT_CPTR_ASPECT
736 FieldContainer
*ShaderExecutableVarChunkBase::createAspectCopy(
737 const FieldContainer
*pRefAspect
) const
739 ShaderExecutableVarChunk
*returnValue
;
741 newAspectCopy(returnValue
,
742 dynamic_cast<const ShaderExecutableVarChunk
*>(pRefAspect
),
743 dynamic_cast<const ShaderExecutableVarChunk
*>(this));
749 void ShaderExecutableVarChunkBase::resolveLinks(void)
751 Inherited::resolveLinks();
753 static_cast<ShaderExecutableVarChunk
*>(this)->setVariables(NULL
);
755 #ifdef OSG_MT_CPTR_ASPECT
756 AspectOffsetStore oOffsets
;
758 _pAspectStore
->fillOffsetArray(oOffsets
, this);
761 #ifdef OSG_MT_CPTR_ASPECT
762 _mfVariableLocations
.terminateShare(Thread::getCurrentAspect(),