changed: gcc8 base update
[opensg.git] / Source / Contrib / CgFXMaterial / OSGCgFXTechniqueBase.cpp
blob9c7b3b75b7efa520fcc7209e9ba6b31c9fc6a20a
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 CgFXTechnique!
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"
65 #include "OSGState.h" // RenderPassStates Class
67 #include "OSGCgFXTechniqueBase.h"
68 #include "OSGCgFXTechnique.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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(
97 "CgFXTechniquePtr",
98 "PrimeMaterialPtr",
99 CgFXTechnique::getClassType(),
100 nsOSG);
101 #endif
103 OSG_FIELDTRAITS_GETTYPE_NS(CgFXTechnique *, nsOSG)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
106 CgFXTechnique *,
107 nsOSG)
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
110 CgFXTechnique *,
111 nsOSG)
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void CgFXTechniqueBase::classDescInserter(TypeObject &oType)
119 FieldDescriptionBase *pDesc = NULL;
122 pDesc = new MFUnrecStatePtr::Description(
123 MFUnrecStatePtr::getClassType(),
124 "renderPassStates",
126 RenderPassStatesFieldId, RenderPassStatesFieldMask,
127 true,
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(),
139 "NULL",
140 nsOSG, //Namespace
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)),
146 false,
148 "<?xml version=\"1.0\"?>\n"
149 "\n"
150 "<FieldContainer\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"
160 " >\n"
161 " <Field\n"
162 " name=\"renderPassStates\"\n"
163 " type=\"State\"\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"
176 " >\n"
177 " </Field>\n"
178 "</FieldContainer>\n",
182 /*------------------------------ get -----------------------------------*/
184 FieldContainerType &CgFXTechniqueBase::getType(void)
186 return _type;
189 const FieldContainerType &CgFXTechniqueBase::getType(void) const
191 return _type;
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)
216 if(value == NULL)
217 return;
219 editMField(RenderPassStatesFieldMask, _mfRenderPassStates);
221 _mfRenderPassStates.push_back(value);
224 void CgFXTechniqueBase::assignRenderPassStates(const MFUnrecStatePtr &value)
226 MFUnrecStatePtr ::const_iterator elemIt =
227 value.begin();
228 MFUnrecStatePtr ::const_iterator elemEnd =
229 value.end ();
231 static_cast<CgFXTechnique *>(this)->clearPassStates();
233 while(elemIt != elemEnd)
235 this->addPassState(*elemIt);
237 ++elemIt;
241 void CgFXTechniqueBase::insertPassState(UInt32 uiIndex,
242 State * const value )
244 if(value == NULL)
245 return;
247 editMField(RenderPassStatesFieldMask, _mfRenderPassStates);
249 MFUnrecStatePtr::iterator fieldIt = _mfRenderPassStates.begin_nc();
251 fieldIt += uiIndex;
253 _mfRenderPassStates.insert(fieldIt, value);
256 void CgFXTechniqueBase::replacePassState(UInt32 uiIndex,
257 State * const value )
259 if(value == NULL)
260 return;
262 if(uiIndex >= _mfRenderPassStates.size())
263 return;
265 editMField(RenderPassStatesFieldMask, _mfRenderPassStates);
267 _mfRenderPassStates.replace(uiIndex, value);
270 void CgFXTechniqueBase::replacePassStateByObj(State * const pOldElem,
271 State * const pNewElem)
273 if(pNewElem == NULL)
274 return;
276 Int32 elemIdx = _mfRenderPassStates.findIndex(pOldElem);
278 if(elemIdx != -1)
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);
300 if(iElemIdx != -1)
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();
328 return returnValue;
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);
367 return fc;
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);
383 return fc;
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);
399 return fc;
402 CgFXTechnique *CgFXTechniqueBase::createEmptyLocal(BitVector bFlags)
404 CgFXTechnique *returnValue;
406 newPtr<CgFXTechnique>(returnValue, bFlags);
408 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
410 return returnValue;
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();
423 return returnValue;
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;
438 return returnValue;
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;
452 return returnValue;
455 FieldContainerTransitPtr CgFXTechniqueBase::shallowCopy(void) const
457 CgFXTechnique *tmpPtr;
459 newPtr(tmpPtr,
460 dynamic_cast<const CgFXTechnique *>(this),
461 Thread::getCurrentLocalFlags());
463 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
465 FieldContainerTransitPtr returnValue(tmpPtr);
467 return returnValue;
473 /*------------------------- constructors ----------------------------------*/
475 CgFXTechniqueBase::CgFXTechniqueBase(void) :
476 Inherited(),
477 _mfRenderPassStates ()
481 CgFXTechniqueBase::CgFXTechniqueBase(const CgFXTechniqueBase &source) :
482 Inherited(source),
483 _mfRenderPassStates ()
488 /*-------------------------- destructors ----------------------------------*/
490 CgFXTechniqueBase::~CgFXTechniqueBase(void)
494 void CgFXTechniqueBase::onCreate(const CgFXTechnique *source)
496 Inherited::onCreate(source);
498 if(source != NULL)
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)));
524 return returnValue;
527 EditFieldHandlePtr CgFXTechniqueBase::editHandleRenderPassStates(void)
529 MFUnrecStatePtr::EditHandlePtr returnValue(
530 new MFUnrecStatePtr::EditHandle(
531 &_mfRenderPassStates,
532 this->getType().getFieldDesc(RenderPassStatesFieldId),
533 this));
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);
559 return returnValue;
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),
573 whichField,
574 oOffsets,
575 syncMode,
576 uiSyncInfo);
578 #endif
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));
591 return returnValue;
593 #endif
595 void CgFXTechniqueBase::resolveLinks(void)
597 Inherited::resolveLinks();
599 static_cast<CgFXTechnique *>(this)->clearPassStates();
605 OSG_END_NAMESPACE