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 CgFXTechnique!
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 "OSGState.h" // RenderPassStates Class
67 #include "OSGCgFXTechniqueBase.h"
68 #include "OSGCgFXTechnique.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::CgFXTechnique
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var State * CgFXTechniqueBase::_mfRenderPassStates
91 /***************************************************************************\
92 * FieldType/FieldTrait Instantiation *
93 \***************************************************************************/
95 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
96 PointerType FieldTraits
<CgFXTechnique
*, nsOSG
>::_type(
99 CgFXTechnique::getClassType(),
103 OSG_FIELDTRAITS_GETTYPE_NS(CgFXTechnique
*, nsOSG
)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void CgFXTechniqueBase::classDescInserter(TypeObject
&oType
)
119 FieldDescriptionBase
*pDesc
= NULL
;
122 pDesc
= new MFUnrecStatePtr::Description(
123 MFUnrecStatePtr::getClassType(),
126 RenderPassStatesFieldId
, RenderPassStatesFieldMask
,
128 (Field::MFDefaultFlags
| Field::FNullCheckAccess
),
129 static_cast<FieldEditMethodSig
>(&CgFXTechnique::editHandleRenderPassStates
),
130 static_cast<FieldGetMethodSig
>(&CgFXTechnique::getHandleRenderPassStates
));
132 oType
.addInitialDesc(pDesc
);
136 CgFXTechniqueBase::TypeObject
CgFXTechniqueBase::_type(
137 CgFXTechniqueBase::getClassname(),
138 Inherited::getClassname(),
141 reinterpret_cast<PrototypeCreateF
>(&CgFXTechniqueBase::createEmptyLocal
),
142 reinterpret_cast<InitContainerF
>(&CgFXTechnique::initMethod
),
143 reinterpret_cast<ExitContainerF
>(&CgFXTechnique::exitMethod
),
144 reinterpret_cast<InitalInsertDescFunc
>(
145 reinterpret_cast<void *>(&CgFXTechnique::classDescInserter
)),
148 "<?xml version=\"1.0\"?>\n"
151 " name=\"CgFXTechnique\"\n"
152 " parent=\"PrimeMaterial\"\n"
153 " library=\"ContribCgFX\"\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"
162 " name=\"renderPassStates\"\n"
164 " category=\"pointer\"\n"
165 " cardinality=\"multi\"\n"
166 " visibility=\"internal\"\n"
167 " access=\"protected\"\n"
168 " pushToFieldAs=\"addPassState\"\n"
169 " insertIntoMFieldAs=\"insertPassState\"\n"
170 " replaceInMFieldIndexAs=\"replacePassState\"\n"
171 " replaceInMFieldObjectAs=\"replacePassStateByObj\"\n"
172 " removeFromMFieldIndexAs=\"subPassState\"\n"
173 " removeFromMFieldObjectAs=\"subPassStateByObj\"\n"
174 " clearFieldAs=\"clearPassStates\"\n"
175 " ptrFieldAccess = \"nullCheck\"\n"
178 "</FieldContainer>\n",
182 /*------------------------------ get -----------------------------------*/
184 FieldContainerType
&CgFXTechniqueBase::getType(void)
189 const FieldContainerType
&CgFXTechniqueBase::getType(void) const
194 UInt32
CgFXTechniqueBase::getContainerSize(void) const
196 return sizeof(CgFXTechnique
);
199 /*------------------------- decorator get ------------------------------*/
202 //! Get the CgFXTechnique::_mfRenderPassStates field.
203 const MFUnrecStatePtr
*CgFXTechniqueBase::getMFRenderPassStates(void) const
205 return &_mfRenderPassStates
;
207 State
* CgFXTechniqueBase::getRenderPassStates(const UInt32 index
) const
209 return _mfRenderPassStates
[index
];
214 void CgFXTechniqueBase::addPassState(State
* const value
)
219 editMField(RenderPassStatesFieldMask
, _mfRenderPassStates
);
221 _mfRenderPassStates
.push_back(value
);
224 void CgFXTechniqueBase::assignRenderPassStates(const MFUnrecStatePtr
&value
)
226 MFUnrecStatePtr ::const_iterator elemIt
=
228 MFUnrecStatePtr ::const_iterator elemEnd
=
231 static_cast<CgFXTechnique
*>(this)->clearPassStates();
233 while(elemIt
!= elemEnd
)
235 this->addPassState(*elemIt
);
241 void CgFXTechniqueBase::insertPassState(UInt32 uiIndex
,
242 State
* const value
)
247 editMField(RenderPassStatesFieldMask
, _mfRenderPassStates
);
249 MFUnrecStatePtr::iterator fieldIt
= _mfRenderPassStates
.begin_nc();
253 _mfRenderPassStates
.insert(fieldIt
, value
);
256 void CgFXTechniqueBase::replacePassState(UInt32 uiIndex
,
257 State
* const value
)
262 if(uiIndex
>= _mfRenderPassStates
.size())
265 editMField(RenderPassStatesFieldMask
, _mfRenderPassStates
);
267 _mfRenderPassStates
.replace(uiIndex
, value
);
270 void CgFXTechniqueBase::replacePassStateByObj(State
* const pOldElem
,
271 State
* const pNewElem
)
276 Int32 elemIdx
= _mfRenderPassStates
.findIndex(pOldElem
);
280 editMField(RenderPassStatesFieldMask
, _mfRenderPassStates
);
282 _mfRenderPassStates
.replace(elemIdx
, pNewElem
);
286 void CgFXTechniqueBase::subPassState(UInt32 uiIndex
)
288 if(uiIndex
< _mfRenderPassStates
.size())
290 editMField(RenderPassStatesFieldMask
, _mfRenderPassStates
);
292 _mfRenderPassStates
.erase(uiIndex
);
296 void CgFXTechniqueBase::subPassStateByObj(State
* const value
)
298 Int32 iElemIdx
= _mfRenderPassStates
.findIndex(value
);
302 editMField(RenderPassStatesFieldMask
, _mfRenderPassStates
);
304 _mfRenderPassStates
.erase(iElemIdx
);
307 void CgFXTechniqueBase::clearPassStates(void)
309 editMField(RenderPassStatesFieldMask
, _mfRenderPassStates
);
312 _mfRenderPassStates
.clear();
317 /*------------------------------ access -----------------------------------*/
319 SizeT
CgFXTechniqueBase::getBinSize(ConstFieldMaskArg whichField
)
321 SizeT returnValue
= Inherited::getBinSize(whichField
);
323 if(FieldBits::NoField
!= (RenderPassStatesFieldMask
& whichField
))
325 returnValue
+= _mfRenderPassStates
.getBinSize();
331 void CgFXTechniqueBase::copyToBin(BinaryDataHandler
&pMem
,
332 ConstFieldMaskArg whichField
)
334 Inherited::copyToBin(pMem
, whichField
);
336 if(FieldBits::NoField
!= (RenderPassStatesFieldMask
& whichField
))
338 _mfRenderPassStates
.copyToBin(pMem
);
342 void CgFXTechniqueBase::copyFromBin(BinaryDataHandler
&pMem
,
343 ConstFieldMaskArg whichField
)
345 Inherited::copyFromBin(pMem
, whichField
);
347 if(FieldBits::NoField
!= (RenderPassStatesFieldMask
& whichField
))
349 editMField(RenderPassStatesFieldMask
, _mfRenderPassStates
);
350 _mfRenderPassStates
.copyFromBin(pMem
);
354 //! create a new instance of the class
355 CgFXTechniqueTransitPtr
CgFXTechniqueBase::createLocal(BitVector bFlags
)
357 CgFXTechniqueTransitPtr fc
;
359 if(getClassType().getPrototype() != NULL
)
361 FieldContainerTransitPtr tmpPtr
=
362 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
364 fc
= dynamic_pointer_cast
<CgFXTechnique
>(tmpPtr
);
370 //! create a new instance of the class, copy the container flags
371 CgFXTechniqueTransitPtr
CgFXTechniqueBase::createDependent(BitVector bFlags
)
373 CgFXTechniqueTransitPtr fc
;
375 if(getClassType().getPrototype() != NULL
)
377 FieldContainerTransitPtr tmpPtr
=
378 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
380 fc
= dynamic_pointer_cast
<CgFXTechnique
>(tmpPtr
);
386 //! create a new instance of the class
387 CgFXTechniqueTransitPtr
CgFXTechniqueBase::create(void)
389 CgFXTechniqueTransitPtr fc
;
391 if(getClassType().getPrototype() != NULL
)
393 FieldContainerTransitPtr tmpPtr
=
394 getClassType().getPrototype()-> shallowCopy();
396 fc
= dynamic_pointer_cast
<CgFXTechnique
>(tmpPtr
);
402 CgFXTechnique
*CgFXTechniqueBase::createEmptyLocal(BitVector bFlags
)
404 CgFXTechnique
*returnValue
;
406 newPtr
<CgFXTechnique
>(returnValue
, bFlags
);
408 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
413 //! create an empty new instance of the class, do not copy the prototype
414 CgFXTechnique
*CgFXTechniqueBase::createEmpty(void)
416 CgFXTechnique
*returnValue
;
418 newPtr
<CgFXTechnique
>(returnValue
, Thread::getCurrentLocalFlags());
420 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
421 ~Thread::getCurrentLocalFlags();
427 FieldContainerTransitPtr
CgFXTechniqueBase::shallowCopyLocal(
428 BitVector bFlags
) const
430 CgFXTechnique
*tmpPtr
;
432 newPtr(tmpPtr
, dynamic_cast<const CgFXTechnique
*>(this), bFlags
);
434 FieldContainerTransitPtr
returnValue(tmpPtr
);
436 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
441 FieldContainerTransitPtr
CgFXTechniqueBase::shallowCopyDependent(
442 BitVector bFlags
) const
444 CgFXTechnique
*tmpPtr
;
446 newPtr(tmpPtr
, dynamic_cast<const CgFXTechnique
*>(this), ~bFlags
);
448 FieldContainerTransitPtr
returnValue(tmpPtr
);
450 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
455 FieldContainerTransitPtr
CgFXTechniqueBase::shallowCopy(void) const
457 CgFXTechnique
*tmpPtr
;
460 dynamic_cast<const CgFXTechnique
*>(this),
461 Thread::getCurrentLocalFlags());
463 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
465 FieldContainerTransitPtr
returnValue(tmpPtr
);
473 /*------------------------- constructors ----------------------------------*/
475 CgFXTechniqueBase::CgFXTechniqueBase(void) :
477 _mfRenderPassStates ()
481 CgFXTechniqueBase::CgFXTechniqueBase(const CgFXTechniqueBase
&source
) :
483 _mfRenderPassStates ()
488 /*-------------------------- destructors ----------------------------------*/
490 CgFXTechniqueBase::~CgFXTechniqueBase(void)
494 void CgFXTechniqueBase::onCreate(const CgFXTechnique
*source
)
496 Inherited::onCreate(source
);
500 CgFXTechnique
*pThis
= static_cast<CgFXTechnique
*>(this);
502 MFUnrecStatePtr::const_iterator RenderPassStatesIt
=
503 source
->_mfRenderPassStates
.begin();
504 MFUnrecStatePtr::const_iterator RenderPassStatesEnd
=
505 source
->_mfRenderPassStates
.end ();
507 while(RenderPassStatesIt
!= RenderPassStatesEnd
)
509 pThis
->addPassState(*RenderPassStatesIt
);
511 ++RenderPassStatesIt
;
516 GetFieldHandlePtr
CgFXTechniqueBase::getHandleRenderPassStates (void) const
518 MFUnrecStatePtr::GetHandlePtr
returnValue(
519 new MFUnrecStatePtr::GetHandle(
520 &_mfRenderPassStates
,
521 this->getType().getFieldDesc(RenderPassStatesFieldId
),
522 const_cast<CgFXTechniqueBase
*>(this)));
527 EditFieldHandlePtr
CgFXTechniqueBase::editHandleRenderPassStates(void)
529 MFUnrecStatePtr::EditHandlePtr
returnValue(
530 new MFUnrecStatePtr::EditHandle(
531 &_mfRenderPassStates
,
532 this->getType().getFieldDesc(RenderPassStatesFieldId
),
535 returnValue
->setAddMethod(
536 boost::bind(&CgFXTechnique::addPassState
,
537 static_cast<CgFXTechnique
*>(this), _1
));
538 returnValue
->setInsertMethod(
539 boost::bind(&CgFXTechnique::insertPassState
,
540 static_cast<CgFXTechnique
*>(this), _1
, _2
));
541 returnValue
->setReplaceMethod(
542 boost::bind(&CgFXTechnique::replacePassState
,
543 static_cast<CgFXTechnique
*>(this), _1
, _2
));
544 returnValue
->setReplaceObjMethod(
545 boost::bind(&CgFXTechnique::replacePassStateByObj
,
546 static_cast<CgFXTechnique
*>(this), _1
, _2
));
547 returnValue
->setRemoveMethod(
548 boost::bind(&CgFXTechnique::subPassState
,
549 static_cast<CgFXTechnique
*>(this), _1
));
550 returnValue
->setRemoveObjMethod(
551 boost::bind(&CgFXTechnique::subPassStateByObj
,
552 static_cast<CgFXTechnique
*>(this), _1
));
553 returnValue
->setClearMethod(
554 boost::bind(&CgFXTechnique::clearPassStates
,
555 static_cast<CgFXTechnique
*>(this)));
557 editMField(RenderPassStatesFieldMask
, _mfRenderPassStates
);
563 #ifdef OSG_MT_CPTR_ASPECT
564 void CgFXTechniqueBase::execSyncV( FieldContainer
&oFrom
,
565 ConstFieldMaskArg whichField
,
566 AspectOffsetStore
&oOffsets
,
567 ConstFieldMaskArg syncMode
,
568 const UInt32 uiSyncInfo
)
570 CgFXTechnique
*pThis
= static_cast<CgFXTechnique
*>(this);
572 pThis
->execSync(static_cast<CgFXTechnique
*>(&oFrom
),
581 #ifdef OSG_MT_CPTR_ASPECT
582 FieldContainer
*CgFXTechniqueBase::createAspectCopy(
583 const FieldContainer
*pRefAspect
) const
585 CgFXTechnique
*returnValue
;
587 newAspectCopy(returnValue
,
588 dynamic_cast<const CgFXTechnique
*>(pRefAspect
),
589 dynamic_cast<const CgFXTechnique
*>(this));
595 void CgFXTechniqueBase::resolveLinks(void)
597 Inherited::resolveLinks();
599 static_cast<CgFXTechnique
*>(this)->clearPassStates();