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 VariantMaterial!
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 "OSGPrimeMaterial.h" // FallbackMaterial Class
67 #include "OSGVariantMaterialBase.h"
68 #include "OSGVariantMaterial.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::VariantMaterial
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var PrimeMaterial * VariantMaterialBase::_sfFallbackMaterial
91 /***************************************************************************\
92 * FieldType/FieldTrait Instantiation *
93 \***************************************************************************/
95 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
96 PointerType FieldTraits
<VariantMaterial
*, nsOSG
>::_type(
98 "CompositeMaterialPtr",
99 VariantMaterial::getClassType(),
103 OSG_FIELDTRAITS_GETTYPE_NS(VariantMaterial
*, nsOSG
)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void VariantMaterialBase::classDescInserter(TypeObject
&oType
)
119 FieldDescriptionBase
*pDesc
= NULL
;
122 pDesc
= new SFUnrecPrimeMaterialPtr::Description(
123 SFUnrecPrimeMaterialPtr::getClassType(),
126 FallbackMaterialFieldId
, FallbackMaterialFieldMask
,
128 (Field::SFDefaultFlags
| Field::FStdAccess
),
129 static_cast<FieldEditMethodSig
>(&VariantMaterial::editHandleFallbackMaterial
),
130 static_cast<FieldGetMethodSig
>(&VariantMaterial::getHandleFallbackMaterial
));
132 oType
.addInitialDesc(pDesc
);
136 VariantMaterialBase::TypeObject
VariantMaterialBase::_type(
137 VariantMaterialBase::getClassname(),
138 Inherited::getClassname(),
141 reinterpret_cast<PrototypeCreateF
>(&VariantMaterialBase::createEmptyLocal
),
142 reinterpret_cast<InitContainerF
>(&VariantMaterial::initMethod
),
143 reinterpret_cast<ExitContainerF
>(&VariantMaterial::exitMethod
),
144 reinterpret_cast<InitalInsertDescFunc
>(
145 reinterpret_cast<void *>(&VariantMaterial::classDescInserter
)),
148 "<?xml version=\"1.0\"?>\n"
151 " name=\"VariantMaterial\"\n"
152 " parent=\"CompositeMaterial\"\n"
153 " library=\"System\"\n"
154 " structure=\"concrete\"\n"
155 " pointerfieldtypes=\"both\"\n"
156 " systemcomponent=\"true\"\n"
157 " parentsystemcomponent=\"true\"\n"
158 " docGroupBase=\"GrpSystemMaterial\"\n"
161 "\t name=\"fallbackMaterial\"\n"
162 "\t type=\"PrimeMaterialPtr\"\n"
163 "\t cardinality=\"single\"\n"
164 "\t visibility=\"external\"\n"
165 "\t access=\"public\"\n"
168 "</FieldContainer>\n",
172 /*------------------------------ get -----------------------------------*/
174 FieldContainerType
&VariantMaterialBase::getType(void)
179 const FieldContainerType
&VariantMaterialBase::getType(void) const
184 UInt32
VariantMaterialBase::getContainerSize(void) const
186 return sizeof(VariantMaterial
);
189 /*------------------------- decorator get ------------------------------*/
192 //! Get the VariantMaterial::_sfFallbackMaterial field.
193 const SFUnrecPrimeMaterialPtr
*VariantMaterialBase::getSFFallbackMaterial(void) const
195 return &_sfFallbackMaterial
;
198 SFUnrecPrimeMaterialPtr
*VariantMaterialBase::editSFFallbackMaterial(void)
200 editSField(FallbackMaterialFieldMask
);
202 return &_sfFallbackMaterial
;
205 //! Get the value of the VariantMaterial::_sfFallbackMaterial field.
206 PrimeMaterial
* VariantMaterialBase::getFallbackMaterial(void) const
208 return _sfFallbackMaterial
.getValue();
211 //! Set the value of the VariantMaterial::_sfFallbackMaterial field.
212 void VariantMaterialBase::setFallbackMaterial(PrimeMaterial
* const value
)
214 editSField(FallbackMaterialFieldMask
);
216 _sfFallbackMaterial
.setValue(value
);
224 /*------------------------------ access -----------------------------------*/
226 SizeT
VariantMaterialBase::getBinSize(ConstFieldMaskArg whichField
)
228 SizeT returnValue
= Inherited::getBinSize(whichField
);
230 if(FieldBits::NoField
!= (FallbackMaterialFieldMask
& whichField
))
232 returnValue
+= _sfFallbackMaterial
.getBinSize();
238 void VariantMaterialBase::copyToBin(BinaryDataHandler
&pMem
,
239 ConstFieldMaskArg whichField
)
241 Inherited::copyToBin(pMem
, whichField
);
243 if(FieldBits::NoField
!= (FallbackMaterialFieldMask
& whichField
))
245 _sfFallbackMaterial
.copyToBin(pMem
);
249 void VariantMaterialBase::copyFromBin(BinaryDataHandler
&pMem
,
250 ConstFieldMaskArg whichField
)
252 Inherited::copyFromBin(pMem
, whichField
);
254 if(FieldBits::NoField
!= (FallbackMaterialFieldMask
& whichField
))
256 editSField(FallbackMaterialFieldMask
);
257 _sfFallbackMaterial
.copyFromBin(pMem
);
261 //! create a new instance of the class
262 VariantMaterialTransitPtr
VariantMaterialBase::createLocal(BitVector bFlags
)
264 VariantMaterialTransitPtr fc
;
266 if(getClassType().getPrototype() != NULL
)
268 FieldContainerTransitPtr tmpPtr
=
269 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
271 fc
= dynamic_pointer_cast
<VariantMaterial
>(tmpPtr
);
277 //! create a new instance of the class, copy the container flags
278 VariantMaterialTransitPtr
VariantMaterialBase::createDependent(BitVector bFlags
)
280 VariantMaterialTransitPtr fc
;
282 if(getClassType().getPrototype() != NULL
)
284 FieldContainerTransitPtr tmpPtr
=
285 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
287 fc
= dynamic_pointer_cast
<VariantMaterial
>(tmpPtr
);
293 //! create a new instance of the class
294 VariantMaterialTransitPtr
VariantMaterialBase::create(void)
296 VariantMaterialTransitPtr fc
;
298 if(getClassType().getPrototype() != NULL
)
300 FieldContainerTransitPtr tmpPtr
=
301 getClassType().getPrototype()-> shallowCopy();
303 fc
= dynamic_pointer_cast
<VariantMaterial
>(tmpPtr
);
309 VariantMaterial
*VariantMaterialBase::createEmptyLocal(BitVector bFlags
)
311 VariantMaterial
*returnValue
;
313 newPtr
<VariantMaterial
>(returnValue
, bFlags
);
315 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
320 //! create an empty new instance of the class, do not copy the prototype
321 VariantMaterial
*VariantMaterialBase::createEmpty(void)
323 VariantMaterial
*returnValue
;
325 newPtr
<VariantMaterial
>(returnValue
, Thread::getCurrentLocalFlags());
327 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
328 ~Thread::getCurrentLocalFlags();
334 FieldContainerTransitPtr
VariantMaterialBase::shallowCopyLocal(
335 BitVector bFlags
) const
337 VariantMaterial
*tmpPtr
;
339 newPtr(tmpPtr
, dynamic_cast<const VariantMaterial
*>(this), bFlags
);
341 FieldContainerTransitPtr
returnValue(tmpPtr
);
343 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
348 FieldContainerTransitPtr
VariantMaterialBase::shallowCopyDependent(
349 BitVector bFlags
) const
351 VariantMaterial
*tmpPtr
;
353 newPtr(tmpPtr
, dynamic_cast<const VariantMaterial
*>(this), ~bFlags
);
355 FieldContainerTransitPtr
returnValue(tmpPtr
);
357 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
362 FieldContainerTransitPtr
VariantMaterialBase::shallowCopy(void) const
364 VariantMaterial
*tmpPtr
;
367 dynamic_cast<const VariantMaterial
*>(this),
368 Thread::getCurrentLocalFlags());
370 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
372 FieldContainerTransitPtr
returnValue(tmpPtr
);
380 /*------------------------- constructors ----------------------------------*/
382 VariantMaterialBase::VariantMaterialBase(void) :
384 _sfFallbackMaterial (NULL
)
388 VariantMaterialBase::VariantMaterialBase(const VariantMaterialBase
&source
) :
390 _sfFallbackMaterial (NULL
)
395 /*-------------------------- destructors ----------------------------------*/
397 VariantMaterialBase::~VariantMaterialBase(void)
401 void VariantMaterialBase::onCreate(const VariantMaterial
*source
)
403 Inherited::onCreate(source
);
407 VariantMaterial
*pThis
= static_cast<VariantMaterial
*>(this);
409 pThis
->setFallbackMaterial(source
->getFallbackMaterial());
413 GetFieldHandlePtr
VariantMaterialBase::getHandleFallbackMaterial (void) const
415 SFUnrecPrimeMaterialPtr::GetHandlePtr
returnValue(
416 new SFUnrecPrimeMaterialPtr::GetHandle(
417 &_sfFallbackMaterial
,
418 this->getType().getFieldDesc(FallbackMaterialFieldId
),
419 const_cast<VariantMaterialBase
*>(this)));
424 EditFieldHandlePtr
VariantMaterialBase::editHandleFallbackMaterial(void)
426 SFUnrecPrimeMaterialPtr::EditHandlePtr
returnValue(
427 new SFUnrecPrimeMaterialPtr::EditHandle(
428 &_sfFallbackMaterial
,
429 this->getType().getFieldDesc(FallbackMaterialFieldId
),
432 returnValue
->setSetMethod(
433 boost::bind(&VariantMaterial::setFallbackMaterial
,
434 static_cast<VariantMaterial
*>(this), _1
));
436 editSField(FallbackMaterialFieldMask
);
442 #ifdef OSG_MT_CPTR_ASPECT
443 void VariantMaterialBase::execSyncV( FieldContainer
&oFrom
,
444 ConstFieldMaskArg whichField
,
445 AspectOffsetStore
&oOffsets
,
446 ConstFieldMaskArg syncMode
,
447 const UInt32 uiSyncInfo
)
449 VariantMaterial
*pThis
= static_cast<VariantMaterial
*>(this);
451 pThis
->execSync(static_cast<VariantMaterial
*>(&oFrom
),
460 #ifdef OSG_MT_CPTR_ASPECT
461 FieldContainer
*VariantMaterialBase::createAspectCopy(
462 const FieldContainer
*pRefAspect
) const
464 VariantMaterial
*returnValue
;
466 newAspectCopy(returnValue
,
467 dynamic_cast<const VariantMaterial
*>(pRefAspect
),
468 dynamic_cast<const VariantMaterial
*>(this));
474 void VariantMaterialBase::resolveLinks(void)
476 Inherited::resolveLinks();
478 static_cast<VariantMaterial
*>(this)->setFallbackMaterial(NULL
);