fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Shader / Variables / OSGShaderVariableOSGBase.cpp
blob46581f1c268ccc2baa4bfad56121ad2ae87262b1
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 ShaderVariableOSG!
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"
66 #include "OSGShaderVariableOSGBase.h"
67 #include "OSGShaderVariableOSG.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::ShaderVariableOSG
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var UInt32 ShaderVariableOSGBase::_sfOsgVarType
86 parameter value
90 /***************************************************************************\
91 * FieldType/FieldTrait Instantiation *
92 \***************************************************************************/
94 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
95 PointerType FieldTraits<ShaderVariableOSG *, nsOSG>::_type(
96 "ShaderVariableOSGPtr",
97 "ShaderProcVariablePtr",
98 ShaderVariableOSG::getClassType(),
99 nsOSG);
100 #endif
102 OSG_FIELDTRAITS_GETTYPE_NS(ShaderVariableOSG *, nsOSG)
104 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
105 ShaderVariableOSG *,
106 nsOSG)
108 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
109 ShaderVariableOSG *,
110 nsOSG)
112 /***************************************************************************\
113 * Field Description *
114 \***************************************************************************/
116 void ShaderVariableOSGBase::classDescInserter(TypeObject &oType)
118 FieldDescriptionBase *pDesc = NULL;
121 pDesc = new SFUInt32::Description(
122 SFUInt32::getClassType(),
123 "osgVarType",
124 "parameter value\n",
125 OsgVarTypeFieldId, OsgVarTypeFieldMask,
126 false,
127 (Field::SFDefaultFlags | Field::FStdAccess),
128 static_cast<FieldEditMethodSig>(&ShaderVariableOSG::editHandleOsgVarType),
129 static_cast<FieldGetMethodSig >(&ShaderVariableOSG::getHandleOsgVarType));
131 oType.addInitialDesc(pDesc);
135 ShaderVariableOSGBase::TypeObject ShaderVariableOSGBase::_type(
136 ShaderVariableOSGBase::getClassname(),
137 Inherited::getClassname(),
138 "NULL",
139 nsOSG, //Namespace
140 reinterpret_cast<PrototypeCreateF>(&ShaderVariableOSGBase::createEmptyLocal),
141 reinterpret_cast<InitContainerF>(&ShaderVariableOSG::initMethod),
142 reinterpret_cast<ExitContainerF>(&ShaderVariableOSG::exitMethod),
143 reinterpret_cast<InitalInsertDescFunc>(
144 reinterpret_cast<void *>(&ShaderVariableOSG::classDescInserter)),
145 false,
147 "<?xml version=\"1.0\"?>\n"
148 "\n"
149 "<FieldContainer\n"
150 " name=\"ShaderVariableOSG\"\n"
151 " parent=\"ShaderProcVariable\"\n"
152 " library=\"System\"\n"
153 " pointerfieldtypes=\"both\"\n"
154 " structure=\"concrete\"\n"
155 " systemcomponent=\"true\"\n"
156 " parentsystemcomponent=\"true\"\n"
157 " decoratable=\"false\"\n"
158 " useLocalIncludes=\"false\"\n"
159 " docGroupBase=\"GrpSystemShader\"\n"
160 " >\n"
161 " <Field\n"
162 " name=\"osgVarType\"\n"
163 " type=\"UInt32\"\n"
164 " cardinality=\"single\"\n"
165 " visibility=\"external\"\n"
166 " access=\"protected\"\n"
167 " defaultValue=\"0\"\n"
168 " >\n"
169 " parameter value\n"
170 " </Field>\n"
171 "</FieldContainer>\n",
175 /*------------------------------ get -----------------------------------*/
177 FieldContainerType &ShaderVariableOSGBase::getType(void)
179 return _type;
182 const FieldContainerType &ShaderVariableOSGBase::getType(void) const
184 return _type;
187 UInt32 ShaderVariableOSGBase::getContainerSize(void) const
189 return sizeof(ShaderVariableOSG);
192 /*------------------------- decorator get ------------------------------*/
195 SFUInt32 *ShaderVariableOSGBase::editSFOsgVarType(void)
197 editSField(OsgVarTypeFieldMask);
199 return &_sfOsgVarType;
202 const SFUInt32 *ShaderVariableOSGBase::getSFOsgVarType(void) const
204 return &_sfOsgVarType;
212 /*------------------------------ access -----------------------------------*/
214 SizeT ShaderVariableOSGBase::getBinSize(ConstFieldMaskArg whichField)
216 SizeT returnValue = Inherited::getBinSize(whichField);
218 if(FieldBits::NoField != (OsgVarTypeFieldMask & whichField))
220 returnValue += _sfOsgVarType.getBinSize();
223 return returnValue;
226 void ShaderVariableOSGBase::copyToBin(BinaryDataHandler &pMem,
227 ConstFieldMaskArg whichField)
229 Inherited::copyToBin(pMem, whichField);
231 if(FieldBits::NoField != (OsgVarTypeFieldMask & whichField))
233 _sfOsgVarType.copyToBin(pMem);
237 void ShaderVariableOSGBase::copyFromBin(BinaryDataHandler &pMem,
238 ConstFieldMaskArg whichField)
240 Inherited::copyFromBin(pMem, whichField);
242 if(FieldBits::NoField != (OsgVarTypeFieldMask & whichField))
244 editSField(OsgVarTypeFieldMask);
245 _sfOsgVarType.copyFromBin(pMem);
249 //! create a new instance of the class
250 ShaderVariableOSGTransitPtr ShaderVariableOSGBase::createLocal(BitVector bFlags)
252 ShaderVariableOSGTransitPtr fc;
254 if(getClassType().getPrototype() != NULL)
256 FieldContainerTransitPtr tmpPtr =
257 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
259 fc = dynamic_pointer_cast<ShaderVariableOSG>(tmpPtr);
262 return fc;
265 //! create a new instance of the class, copy the container flags
266 ShaderVariableOSGTransitPtr ShaderVariableOSGBase::createDependent(BitVector bFlags)
268 ShaderVariableOSGTransitPtr fc;
270 if(getClassType().getPrototype() != NULL)
272 FieldContainerTransitPtr tmpPtr =
273 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
275 fc = dynamic_pointer_cast<ShaderVariableOSG>(tmpPtr);
278 return fc;
281 //! create a new instance of the class
282 ShaderVariableOSGTransitPtr ShaderVariableOSGBase::create(void)
284 ShaderVariableOSGTransitPtr fc;
286 if(getClassType().getPrototype() != NULL)
288 FieldContainerTransitPtr tmpPtr =
289 getClassType().getPrototype()-> shallowCopy();
291 fc = dynamic_pointer_cast<ShaderVariableOSG>(tmpPtr);
294 return fc;
297 ShaderVariableOSG *ShaderVariableOSGBase::createEmptyLocal(BitVector bFlags)
299 ShaderVariableOSG *returnValue;
301 newPtr<ShaderVariableOSG>(returnValue, bFlags);
303 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
305 return returnValue;
308 //! create an empty new instance of the class, do not copy the prototype
309 ShaderVariableOSG *ShaderVariableOSGBase::createEmpty(void)
311 ShaderVariableOSG *returnValue;
313 newPtr<ShaderVariableOSG>(returnValue, Thread::getCurrentLocalFlags());
315 returnValue->_pFieldFlags->_bNamespaceMask &=
316 ~Thread::getCurrentLocalFlags();
318 return returnValue;
322 FieldContainerTransitPtr ShaderVariableOSGBase::shallowCopyLocal(
323 BitVector bFlags) const
325 ShaderVariableOSG *tmpPtr;
327 newPtr(tmpPtr, dynamic_cast<const ShaderVariableOSG *>(this), bFlags);
329 FieldContainerTransitPtr returnValue(tmpPtr);
331 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
333 return returnValue;
336 FieldContainerTransitPtr ShaderVariableOSGBase::shallowCopyDependent(
337 BitVector bFlags) const
339 ShaderVariableOSG *tmpPtr;
341 newPtr(tmpPtr, dynamic_cast<const ShaderVariableOSG *>(this), ~bFlags);
343 FieldContainerTransitPtr returnValue(tmpPtr);
345 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
347 return returnValue;
350 FieldContainerTransitPtr ShaderVariableOSGBase::shallowCopy(void) const
352 ShaderVariableOSG *tmpPtr;
354 newPtr(tmpPtr,
355 dynamic_cast<const ShaderVariableOSG *>(this),
356 Thread::getCurrentLocalFlags());
358 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
360 FieldContainerTransitPtr returnValue(tmpPtr);
362 return returnValue;
368 /*------------------------- constructors ----------------------------------*/
370 ShaderVariableOSGBase::ShaderVariableOSGBase(void) :
371 Inherited(),
372 _sfOsgVarType (UInt32(0))
376 ShaderVariableOSGBase::ShaderVariableOSGBase(const ShaderVariableOSGBase &source) :
377 Inherited(source),
378 _sfOsgVarType (source._sfOsgVarType )
383 /*-------------------------- destructors ----------------------------------*/
385 ShaderVariableOSGBase::~ShaderVariableOSGBase(void)
390 GetFieldHandlePtr ShaderVariableOSGBase::getHandleOsgVarType (void) const
392 SFUInt32::GetHandlePtr returnValue(
393 new SFUInt32::GetHandle(
394 &_sfOsgVarType,
395 this->getType().getFieldDesc(OsgVarTypeFieldId),
396 const_cast<ShaderVariableOSGBase *>(this)));
398 return returnValue;
401 EditFieldHandlePtr ShaderVariableOSGBase::editHandleOsgVarType (void)
403 SFUInt32::EditHandlePtr returnValue(
404 new SFUInt32::EditHandle(
405 &_sfOsgVarType,
406 this->getType().getFieldDesc(OsgVarTypeFieldId),
407 this));
410 editSField(OsgVarTypeFieldMask);
412 return returnValue;
416 #ifdef OSG_MT_CPTR_ASPECT
417 void ShaderVariableOSGBase::execSyncV( FieldContainer &oFrom,
418 ConstFieldMaskArg whichField,
419 AspectOffsetStore &oOffsets,
420 ConstFieldMaskArg syncMode,
421 const UInt32 uiSyncInfo)
423 ShaderVariableOSG *pThis = static_cast<ShaderVariableOSG *>(this);
425 pThis->execSync(static_cast<ShaderVariableOSG *>(&oFrom),
426 whichField,
427 oOffsets,
428 syncMode,
429 uiSyncInfo);
431 #endif
434 #ifdef OSG_MT_CPTR_ASPECT
435 FieldContainer *ShaderVariableOSGBase::createAspectCopy(
436 const FieldContainer *pRefAspect) const
438 ShaderVariableOSG *returnValue;
440 newAspectCopy(returnValue,
441 dynamic_cast<const ShaderVariableOSG *>(pRefAspect),
442 dynamic_cast<const ShaderVariableOSG *>(this));
444 return returnValue;
446 #endif
448 void ShaderVariableOSGBase::resolveLinks(void)
450 Inherited::resolveLinks();
456 OSG_END_NAMESPACE