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 SimpleSHLVariableChunk!
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 "OSGShaderProgramVariables.h" // Variables Class
67 #include "OSGSimpleSHLVariableChunkBase.h"
68 #include "OSGSimpleSHLVariableChunk.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::SimpleSHLVariableChunk
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var ShaderProgramVariables * SimpleSHLVariableChunkBase::_sfVariables
87 fragment program object
90 /*! \var Int32 SimpleSHLVariableChunkBase::_mfVariableLocations
91 fragment program object
95 /***************************************************************************\
96 * FieldType/FieldTrait Instantiation *
97 \***************************************************************************/
99 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
100 PointerType FieldTraits
<SimpleSHLVariableChunk
*, nsOSG
>::_type(
101 "SimpleSHLVariableChunkPtr",
103 SimpleSHLVariableChunk::getClassType(),
107 OSG_FIELDTRAITS_GETTYPE_NS(SimpleSHLVariableChunk
*, nsOSG
)
109 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
110 SimpleSHLVariableChunk
*,
113 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
114 SimpleSHLVariableChunk
*,
117 /***************************************************************************\
118 * Field Description *
119 \***************************************************************************/
121 void SimpleSHLVariableChunkBase::classDescInserter(TypeObject
&oType
)
123 FieldDescriptionBase
*pDesc
= NULL
;
126 pDesc
= new SFUnrecChildShaderProgramVariablesPtr::Description(
127 SFUnrecChildShaderProgramVariablesPtr::getClassType(),
129 "fragment program object\n",
130 VariablesFieldId
, VariablesFieldMask
,
132 (Field::SFDefaultFlags
| Field::FStdAccess
),
133 static_cast<FieldEditMethodSig
>(&SimpleSHLVariableChunk::editHandleVariables
),
134 static_cast<FieldGetMethodSig
>(&SimpleSHLVariableChunk::getHandleVariables
));
136 oType
.addInitialDesc(pDesc
);
138 pDesc
= new MFInt32::Description(
139 MFInt32::getClassType(),
141 "fragment program object\n",
142 VariableLocationsFieldId
, VariableLocationsFieldMask
,
144 (Field::MFDefaultFlags
| Field::FStdAccess
),
145 static_cast<FieldEditMethodSig
>(&SimpleSHLVariableChunk::editHandleVariableLocations
),
146 static_cast<FieldGetMethodSig
>(&SimpleSHLVariableChunk::getHandleVariableLocations
));
148 oType
.addInitialDesc(pDesc
);
152 SimpleSHLVariableChunkBase::TypeObject
SimpleSHLVariableChunkBase::_type(
153 SimpleSHLVariableChunkBase::getClassname(),
154 Inherited::getClassname(),
157 reinterpret_cast<PrototypeCreateF
>(&SimpleSHLVariableChunkBase::createEmptyLocal
),
158 reinterpret_cast<InitContainerF
>(&SimpleSHLVariableChunk::initMethod
),
159 reinterpret_cast<ExitContainerF
>(&SimpleSHLVariableChunk::exitMethod
),
160 reinterpret_cast<InitalInsertDescFunc
>(
161 reinterpret_cast<void *>(&SimpleSHLVariableChunk::classDescInserter
)),
164 "<?xml version=\"1.0\"?>\n"
167 " name=\"SimpleSHLVariableChunk\"\n"
168 " parent=\"StateChunk\"\n"
169 " library=\"System\"\n"
170 " pointerfieldtypes=\"both\"\n"
171 " structure=\"concrete\"\n"
172 " systemcomponent=\"true\"\n"
173 " parentsystemcomponent=\"true\"\n"
174 " decoratable=\"false\"\n"
175 " useLocalIncludes=\"false\"\n"
176 " docGroupBase=\"GrpSystemShader\"\n"
179 "\t name=\"SHLChunk\"\n"
180 "\t type=\"SHLChunk\"\n"
181 "\t cardinality=\"single\"\n"
182 "\t visibility=\"external\"\n"
183 "\t defaultValue=\"NULL\"\n"
184 "\t access=\"public\"\n"
185 " category=\"pointer\"\n"
189 "\t name=\"variables\"\n"
190 "\t type=\"ShaderProgramVariables\"\n"
191 "\t cardinality=\"single\"\n"
192 "\t visibility=\"external\"\n"
193 "\t access=\"public\"\n"
194 " category=\"childpointer\"\n"
195 " childParentType=\"FieldContainer\"\n"
196 " linkParentField=\"Parents\"\n"
198 "\tfragment program object\n"
201 "\t name=\"variableLocations\"\n"
202 "\t type=\"Int32\"\n"
203 "\t cardinality=\"multi\"\n"
204 "\t visibility=\"internal\"\n"
205 "\t access=\"protected\"\n"
207 "\tfragment program object\n"
209 "</FieldContainer>\n",
213 /*------------------------------ get -----------------------------------*/
215 FieldContainerType
&SimpleSHLVariableChunkBase::getType(void)
220 const FieldContainerType
&SimpleSHLVariableChunkBase::getType(void) const
225 UInt32
SimpleSHLVariableChunkBase::getContainerSize(void) const
227 return sizeof(SimpleSHLVariableChunk
);
230 /*------------------------- decorator get ------------------------------*/
233 //! Get the SimpleSHLVariableChunk::_sfVariables field.
234 const SFUnrecChildShaderProgramVariablesPtr
*SimpleSHLVariableChunkBase::getSFVariables(void) const
236 return &_sfVariables
;
239 SFUnrecChildShaderProgramVariablesPtr
*SimpleSHLVariableChunkBase::editSFVariables (void)
241 editSField(VariablesFieldMask
);
243 return &_sfVariables
;
246 //! Get the value of the SimpleSHLVariableChunk::_sfVariables field.
247 ShaderProgramVariables
* SimpleSHLVariableChunkBase::getVariables(void) const
249 return _sfVariables
.getValue();
252 //! Set the value of the SimpleSHLVariableChunk::_sfVariables field.
253 void SimpleSHLVariableChunkBase::setVariables(ShaderProgramVariables
* const value
)
255 editSField(VariablesFieldMask
);
257 _sfVariables
.setValue(value
);
261 MFInt32
*SimpleSHLVariableChunkBase::editMFVariableLocations(void)
263 editMField(VariableLocationsFieldMask
, _mfVariableLocations
);
265 return &_mfVariableLocations
;
268 const MFInt32
*SimpleSHLVariableChunkBase::getMFVariableLocations(void) const
270 return &_mfVariableLocations
;
278 /*------------------------------ access -----------------------------------*/
280 SizeT
SimpleSHLVariableChunkBase::getBinSize(ConstFieldMaskArg whichField
)
282 SizeT returnValue
= Inherited::getBinSize(whichField
);
284 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
286 returnValue
+= _sfVariables
.getBinSize();
288 if(FieldBits::NoField
!= (VariableLocationsFieldMask
& whichField
))
290 returnValue
+= _mfVariableLocations
.getBinSize();
296 void SimpleSHLVariableChunkBase::copyToBin(BinaryDataHandler
&pMem
,
297 ConstFieldMaskArg whichField
)
299 Inherited::copyToBin(pMem
, whichField
);
301 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
303 _sfVariables
.copyToBin(pMem
);
305 if(FieldBits::NoField
!= (VariableLocationsFieldMask
& whichField
))
307 _mfVariableLocations
.copyToBin(pMem
);
311 void SimpleSHLVariableChunkBase::copyFromBin(BinaryDataHandler
&pMem
,
312 ConstFieldMaskArg whichField
)
314 Inherited::copyFromBin(pMem
, whichField
);
316 if(FieldBits::NoField
!= (VariablesFieldMask
& whichField
))
318 editSField(VariablesFieldMask
);
319 _sfVariables
.copyFromBin(pMem
);
321 if(FieldBits::NoField
!= (VariableLocationsFieldMask
& whichField
))
323 editMField(VariableLocationsFieldMask
, _mfVariableLocations
);
324 _mfVariableLocations
.copyFromBin(pMem
);
328 //! create a new instance of the class
329 SimpleSHLVariableChunkTransitPtr
SimpleSHLVariableChunkBase::createLocal(BitVector bFlags
)
331 SimpleSHLVariableChunkTransitPtr fc
;
333 if(getClassType().getPrototype() != NULL
)
335 FieldContainerTransitPtr tmpPtr
=
336 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
338 fc
= dynamic_pointer_cast
<SimpleSHLVariableChunk
>(tmpPtr
);
344 //! create a new instance of the class, copy the container flags
345 SimpleSHLVariableChunkTransitPtr
SimpleSHLVariableChunkBase::createDependent(BitVector bFlags
)
347 SimpleSHLVariableChunkTransitPtr fc
;
349 if(getClassType().getPrototype() != NULL
)
351 FieldContainerTransitPtr tmpPtr
=
352 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
354 fc
= dynamic_pointer_cast
<SimpleSHLVariableChunk
>(tmpPtr
);
360 //! create a new instance of the class
361 SimpleSHLVariableChunkTransitPtr
SimpleSHLVariableChunkBase::create(void)
363 SimpleSHLVariableChunkTransitPtr fc
;
365 if(getClassType().getPrototype() != NULL
)
367 FieldContainerTransitPtr tmpPtr
=
368 getClassType().getPrototype()-> shallowCopy();
370 fc
= dynamic_pointer_cast
<SimpleSHLVariableChunk
>(tmpPtr
);
376 SimpleSHLVariableChunk
*SimpleSHLVariableChunkBase::createEmptyLocal(BitVector bFlags
)
378 SimpleSHLVariableChunk
*returnValue
;
380 newPtr
<SimpleSHLVariableChunk
>(returnValue
, bFlags
);
382 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
387 //! create an empty new instance of the class, do not copy the prototype
388 SimpleSHLVariableChunk
*SimpleSHLVariableChunkBase::createEmpty(void)
390 SimpleSHLVariableChunk
*returnValue
;
392 newPtr
<SimpleSHLVariableChunk
>(returnValue
, Thread::getCurrentLocalFlags());
394 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
395 ~Thread::getCurrentLocalFlags();
401 FieldContainerTransitPtr
SimpleSHLVariableChunkBase::shallowCopyLocal(
402 BitVector bFlags
) const
404 SimpleSHLVariableChunk
*tmpPtr
;
406 newPtr(tmpPtr
, dynamic_cast<const SimpleSHLVariableChunk
*>(this), bFlags
);
408 FieldContainerTransitPtr
returnValue(tmpPtr
);
410 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
415 FieldContainerTransitPtr
SimpleSHLVariableChunkBase::shallowCopyDependent(
416 BitVector bFlags
) const
418 SimpleSHLVariableChunk
*tmpPtr
;
420 newPtr(tmpPtr
, dynamic_cast<const SimpleSHLVariableChunk
*>(this), ~bFlags
);
422 FieldContainerTransitPtr
returnValue(tmpPtr
);
424 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
429 FieldContainerTransitPtr
SimpleSHLVariableChunkBase::shallowCopy(void) const
431 SimpleSHLVariableChunk
*tmpPtr
;
434 dynamic_cast<const SimpleSHLVariableChunk
*>(this),
435 Thread::getCurrentLocalFlags());
437 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
439 FieldContainerTransitPtr
returnValue(tmpPtr
);
447 /*------------------------- constructors ----------------------------------*/
449 SimpleSHLVariableChunkBase::SimpleSHLVariableChunkBase(void) :
453 ShaderProgramVariables::ParentsFieldId
),
454 _mfVariableLocations ()
458 SimpleSHLVariableChunkBase::SimpleSHLVariableChunkBase(const SimpleSHLVariableChunkBase
&source
) :
462 ShaderProgramVariables::ParentsFieldId
),
463 _mfVariableLocations (source
._mfVariableLocations
)
468 /*-------------------------- destructors ----------------------------------*/
470 SimpleSHLVariableChunkBase::~SimpleSHLVariableChunkBase(void)
474 /*-------------------------------------------------------------------------*/
477 bool SimpleSHLVariableChunkBase::unlinkChild(
478 FieldContainer
* const pChild
,
479 UInt16
const childFieldId
)
481 if(childFieldId
== VariablesFieldId
)
483 ShaderProgramVariables
* pTypedChild
=
484 dynamic_cast<ShaderProgramVariables
*>(pChild
);
486 if(pTypedChild
!= NULL
)
488 if(_sfVariables
.getValue() == pTypedChild
)
490 editSField(VariablesFieldMask
);
492 _sfVariables
.setValue(NULL
);
497 SWARNING
<< "Parent ([" << this
498 << "] id [" << this->getId()
499 << "] type [" << this->getType().getCName()
500 << "] childFieldId [" << childFieldId
501 << "]) - Child ([" << pChild
502 << "] id [" << pChild
->getId()
503 << "] type [" << pChild
->getType().getCName()
504 << "]): link inconsistent!"
514 return Inherited::unlinkChild(pChild
, childFieldId
);
517 void SimpleSHLVariableChunkBase::onCreate(const SimpleSHLVariableChunk
*source
)
519 Inherited::onCreate(source
);
523 SimpleSHLVariableChunk
*pThis
= static_cast<SimpleSHLVariableChunk
*>(this);
525 pThis
->setVariables(source
->getVariables());
529 GetFieldHandlePtr
SimpleSHLVariableChunkBase::getHandleVariables (void) const
531 SFUnrecChildShaderProgramVariablesPtr::GetHandlePtr
returnValue(
532 new SFUnrecChildShaderProgramVariablesPtr::GetHandle(
534 this->getType().getFieldDesc(VariablesFieldId
),
535 const_cast<SimpleSHLVariableChunkBase
*>(this)));
540 EditFieldHandlePtr
SimpleSHLVariableChunkBase::editHandleVariables (void)
542 SFUnrecChildShaderProgramVariablesPtr::EditHandlePtr
returnValue(
543 new SFUnrecChildShaderProgramVariablesPtr::EditHandle(
545 this->getType().getFieldDesc(VariablesFieldId
),
548 returnValue
->setSetMethod(
549 boost::bind(&SimpleSHLVariableChunk::setVariables
,
550 static_cast<SimpleSHLVariableChunk
*>(this), _1
));
552 editSField(VariablesFieldMask
);
557 GetFieldHandlePtr
SimpleSHLVariableChunkBase::getHandleVariableLocations (void) const
559 MFInt32::GetHandlePtr
returnValue(
560 new MFInt32::GetHandle(
561 &_mfVariableLocations
,
562 this->getType().getFieldDesc(VariableLocationsFieldId
),
563 const_cast<SimpleSHLVariableChunkBase
*>(this)));
568 EditFieldHandlePtr
SimpleSHLVariableChunkBase::editHandleVariableLocations(void)
570 MFInt32::EditHandlePtr
returnValue(
571 new MFInt32::EditHandle(
572 &_mfVariableLocations
,
573 this->getType().getFieldDesc(VariableLocationsFieldId
),
577 editMField(VariableLocationsFieldMask
, _mfVariableLocations
);
583 #ifdef OSG_MT_CPTR_ASPECT
584 void SimpleSHLVariableChunkBase::execSyncV( FieldContainer
&oFrom
,
585 ConstFieldMaskArg whichField
,
586 AspectOffsetStore
&oOffsets
,
587 ConstFieldMaskArg syncMode
,
588 const UInt32 uiSyncInfo
)
590 SimpleSHLVariableChunk
*pThis
= static_cast<SimpleSHLVariableChunk
*>(this);
592 pThis
->execSync(static_cast<SimpleSHLVariableChunk
*>(&oFrom
),
601 #ifdef OSG_MT_CPTR_ASPECT
602 FieldContainer
*SimpleSHLVariableChunkBase::createAspectCopy(
603 const FieldContainer
*pRefAspect
) const
605 SimpleSHLVariableChunk
*returnValue
;
607 newAspectCopy(returnValue
,
608 dynamic_cast<const SimpleSHLVariableChunk
*>(pRefAspect
),
609 dynamic_cast<const SimpleSHLVariableChunk
*>(this));
615 void SimpleSHLVariableChunkBase::resolveLinks(void)
617 Inherited::resolveLinks();
619 static_cast<SimpleSHLVariableChunk
*>(this)->setVariables(NULL
);
621 #ifdef OSG_MT_CPTR_ASPECT
622 AspectOffsetStore oOffsets
;
624 _pAspectStore
->fillOffsetArray(oOffsets
, this);
627 #ifdef OSG_MT_CPTR_ASPECT
628 _mfVariableLocations
.terminateShare(Thread::getCurrentAspect(),