fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Material / Base / OSGVariantMaterialBase.cpp
blob8a114e15096c37915e6293d3e8e9e626c43c516b
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 VariantMaterial!
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 "OSGPrimeMaterial.h" // FallbackMaterial Class
67 #include "OSGVariantMaterialBase.h"
68 #include "OSGVariantMaterial.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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(
97 "VariantMaterialPtr",
98 "CompositeMaterialPtr",
99 VariantMaterial::getClassType(),
100 nsOSG);
101 #endif
103 OSG_FIELDTRAITS_GETTYPE_NS(VariantMaterial *, nsOSG)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
106 VariantMaterial *,
107 nsOSG)
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
110 VariantMaterial *,
111 nsOSG)
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void VariantMaterialBase::classDescInserter(TypeObject &oType)
119 FieldDescriptionBase *pDesc = NULL;
122 pDesc = new SFUnrecPrimeMaterialPtr::Description(
123 SFUnrecPrimeMaterialPtr::getClassType(),
124 "fallbackMaterial",
126 FallbackMaterialFieldId, FallbackMaterialFieldMask,
127 false,
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(),
139 "NULL",
140 nsOSG, //Namespace
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)),
146 false,
148 "<?xml version=\"1.0\"?>\n"
149 "\n"
150 "<FieldContainer\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"
159 " >\n"
160 " <Field\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"
166 "\t >\n"
167 " </Field>\n"
168 "</FieldContainer>\n",
172 /*------------------------------ get -----------------------------------*/
174 FieldContainerType &VariantMaterialBase::getType(void)
176 return _type;
179 const FieldContainerType &VariantMaterialBase::getType(void) const
181 return _type;
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();
235 return returnValue;
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);
274 return fc;
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);
290 return fc;
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);
306 return fc;
309 VariantMaterial *VariantMaterialBase::createEmptyLocal(BitVector bFlags)
311 VariantMaterial *returnValue;
313 newPtr<VariantMaterial>(returnValue, bFlags);
315 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
317 return returnValue;
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();
330 return returnValue;
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;
345 return returnValue;
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;
359 return returnValue;
362 FieldContainerTransitPtr VariantMaterialBase::shallowCopy(void) const
364 VariantMaterial *tmpPtr;
366 newPtr(tmpPtr,
367 dynamic_cast<const VariantMaterial *>(this),
368 Thread::getCurrentLocalFlags());
370 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
372 FieldContainerTransitPtr returnValue(tmpPtr);
374 return returnValue;
380 /*------------------------- constructors ----------------------------------*/
382 VariantMaterialBase::VariantMaterialBase(void) :
383 Inherited(),
384 _sfFallbackMaterial (NULL)
388 VariantMaterialBase::VariantMaterialBase(const VariantMaterialBase &source) :
389 Inherited(source),
390 _sfFallbackMaterial (NULL)
395 /*-------------------------- destructors ----------------------------------*/
397 VariantMaterialBase::~VariantMaterialBase(void)
401 void VariantMaterialBase::onCreate(const VariantMaterial *source)
403 Inherited::onCreate(source);
405 if(source != NULL)
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)));
421 return returnValue;
424 EditFieldHandlePtr VariantMaterialBase::editHandleFallbackMaterial(void)
426 SFUnrecPrimeMaterialPtr::EditHandlePtr returnValue(
427 new SFUnrecPrimeMaterialPtr::EditHandle(
428 &_sfFallbackMaterial,
429 this->getType().getFieldDesc(FallbackMaterialFieldId),
430 this));
432 returnValue->setSetMethod(
433 boost::bind(&VariantMaterial::setFallbackMaterial,
434 static_cast<VariantMaterial *>(this), _1));
436 editSField(FallbackMaterialFieldMask);
438 return returnValue;
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),
452 whichField,
453 oOffsets,
454 syncMode,
455 uiSyncInfo);
457 #endif
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));
470 return returnValue;
472 #endif
474 void VariantMaterialBase::resolveLinks(void)
476 Inherited::resolveLinks();
478 static_cast<VariantMaterial *>(this)->setFallbackMaterial(NULL);
484 OSG_END_NAMESPACE