fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Shader / Variables / OSGShaderProcVariableBase.cpp
blob72543fe2ec6e604fb2de49473599583974bd9393
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 ShaderProcVariable!
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 "OSGFieldContainer.h" // Parents Class
67 #include "OSGShaderProcVariableBase.h"
68 #include "OSGShaderProcVariable.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::ShaderProcVariable
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var UInt32 ShaderProcVariableBase::_sfDependency
87 scope
90 /*! \var FieldContainer * ShaderProcVariableBase::_mfParents
95 /***************************************************************************\
96 * FieldType/FieldTrait Instantiation *
97 \***************************************************************************/
99 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
100 PointerType FieldTraits<ShaderProcVariable *, nsOSG>::_type(
101 "ShaderProcVariablePtr",
102 "ShaderVariablePtr",
103 ShaderProcVariable::getClassType(),
104 nsOSG);
105 #endif
107 OSG_FIELDTRAITS_GETTYPE_NS(ShaderProcVariable *, nsOSG)
109 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
110 ShaderProcVariable *,
111 nsOSG)
113 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
114 ShaderProcVariable *,
115 nsOSG)
117 DataType &FieldTraits< ShaderProcVariable *, nsOSG + 1 >::getType(void)
119 return FieldTraits<ShaderProcVariable *, nsOSG>::getType();
123 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
124 ShaderProcVariable *,
125 UnrecordedRefCountPolicy,
126 nsOSG + 1)
129 /***************************************************************************\
130 * Field Description *
131 \***************************************************************************/
133 void ShaderProcVariableBase::classDescInserter(TypeObject &oType)
135 FieldDescriptionBase *pDesc = NULL;
138 pDesc = new SFUInt32::Description(
139 SFUInt32::getClassType(),
140 "dependency",
141 "scope\n",
142 DependencyFieldId, DependencyFieldMask,
143 false,
144 (Field::SFDefaultFlags | Field::FStdAccess),
145 static_cast<FieldEditMethodSig>(&ShaderProcVariable::editHandleDependency),
146 static_cast<FieldGetMethodSig >(&ShaderProcVariable::getHandleDependency));
148 oType.addInitialDesc(pDesc);
150 pDesc = new MFParentFieldContainerPtr::Description(
151 MFParentFieldContainerPtr::getClassType(),
152 "parents",
154 ParentsFieldId, ParentsFieldMask,
155 true,
156 (Field::FStdAccess | Field::FClusterLocal),
157 static_cast <FieldEditMethodSig>(&ShaderProcVariable::invalidEditField),
158 static_cast <FieldGetMethodSig >(&ShaderProcVariable::invalidGetField));
160 oType.addInitialDesc(pDesc);
164 ShaderProcVariableBase::TypeObject ShaderProcVariableBase::_type(
165 ShaderProcVariableBase::getClassname(),
166 Inherited::getClassname(),
167 "NULL",
168 nsOSG, //Namespace
169 NULL,
170 reinterpret_cast<InitContainerF>(&ShaderProcVariable::initMethod),
171 reinterpret_cast<ExitContainerF>(&ShaderProcVariable::exitMethod),
172 reinterpret_cast<InitalInsertDescFunc>(
173 reinterpret_cast<void *>(&ShaderProcVariable::classDescInserter)),
174 false,
176 "<?xml version=\"1.0\"?>\n"
177 "\n"
178 "<FieldContainer\n"
179 " name=\"ShaderProcVariable\"\n"
180 " parent=\"ShaderVariable\"\n"
181 " library=\"System\"\n"
182 " pointerfieldtypes=\"both\"\n"
183 " structure=\"abstract\"\n"
184 " systemcomponent=\"true\"\n"
185 " parentsystemcomponent=\"true\"\n"
186 " decoratable=\"false\"\n"
187 " useLocalIncludes=\"false\"\n"
188 " childFields=\"multi\"\n"
189 " docGroupBase=\"GrpSystemShader\"\n"
190 " >\n"
191 " <Field\n"
192 "\t name=\"dependency\"\n"
193 "\t type=\"UInt32\"\n"
194 "\t cardinality=\"single\"\n"
195 "\t visibility=\"external\"\n"
196 "\t access=\"public\"\n"
197 " defaultValue=\"ShaderProcVariable::SHDObject\"\n"
198 "\t >\n"
199 "\tscope\n"
200 " </Field>\n"
201 " <Field\n"
202 " name=\"parents\"\n"
203 " type=\"FieldContainer\"\n"
204 " cardinality=\"multi\"\n"
205 " visibility=\"internal\"\n"
206 " access=\"none\"\n"
207 " category=\"parentpointer\"\n"
208 " fieldFlags=\"FStdAccess, FClusterLocal\"\n"
209 " >\n"
210 " </Field>\n"
211 "<!--- fieldFlags=\"FStdAccess, FClusterLocal\" -->\n"
212 "</FieldContainer>\n",
216 /*------------------------------ get -----------------------------------*/
218 FieldContainerType &ShaderProcVariableBase::getType(void)
220 return _type;
223 const FieldContainerType &ShaderProcVariableBase::getType(void) const
225 return _type;
228 UInt32 ShaderProcVariableBase::getContainerSize(void) const
230 return sizeof(ShaderProcVariable);
233 /*------------------------- decorator get ------------------------------*/
236 SFUInt32 *ShaderProcVariableBase::editSFDependency(void)
238 editSField(DependencyFieldMask);
240 return &_sfDependency;
243 const SFUInt32 *ShaderProcVariableBase::getSFDependency(void) const
245 return &_sfDependency;
254 /*------------------------------ access -----------------------------------*/
256 SizeT ShaderProcVariableBase::getBinSize(ConstFieldMaskArg whichField)
258 SizeT returnValue = Inherited::getBinSize(whichField);
260 if(FieldBits::NoField != (DependencyFieldMask & whichField))
262 returnValue += _sfDependency.getBinSize();
264 if(FieldBits::NoField != (ParentsFieldMask & whichField))
266 returnValue += _mfParents.getBinSize();
269 return returnValue;
272 void ShaderProcVariableBase::copyToBin(BinaryDataHandler &pMem,
273 ConstFieldMaskArg whichField)
275 Inherited::copyToBin(pMem, whichField);
277 if(FieldBits::NoField != (DependencyFieldMask & whichField))
279 _sfDependency.copyToBin(pMem);
281 if(FieldBits::NoField != (ParentsFieldMask & whichField))
283 _mfParents.copyToBin(pMem);
287 void ShaderProcVariableBase::copyFromBin(BinaryDataHandler &pMem,
288 ConstFieldMaskArg whichField)
290 Inherited::copyFromBin(pMem, whichField);
292 if(FieldBits::NoField != (DependencyFieldMask & whichField))
294 editSField(DependencyFieldMask);
295 _sfDependency.copyFromBin(pMem);
297 if(FieldBits::NoField != (ParentsFieldMask & whichField))
299 editMField(ParentsFieldMask, _mfParents);
300 _mfParents.copyFromBin(pMem);
307 /*------------------------- constructors ----------------------------------*/
309 ShaderProcVariableBase::ShaderProcVariableBase(void) :
310 Inherited(),
311 _sfDependency (UInt32(ShaderProcVariable::SHDObject)),
312 _mfParents ()
316 ShaderProcVariableBase::ShaderProcVariableBase(const ShaderProcVariableBase &source) :
317 Inherited(source),
318 _sfDependency (source._sfDependency ),
319 _mfParents ()
324 /*-------------------------- destructors ----------------------------------*/
326 ShaderProcVariableBase::~ShaderProcVariableBase(void)
329 /*-------------------------------------------------------------------------*/
330 /* Parent linking */
332 bool ShaderProcVariableBase::linkParent(
333 FieldContainer * const pParent,
334 UInt16 const childFieldId,
335 UInt16 const parentFieldId )
337 if(parentFieldId == ParentsFieldId)
339 FieldContainer * pTypedParent =
340 dynamic_cast< FieldContainer * >(pParent);
342 if(pTypedParent != NULL)
344 editMField(ParentsFieldMask, _mfParents);
346 _mfParents.push_back(pTypedParent, childFieldId);
348 return true;
351 return false;
354 return Inherited::linkParent(pParent, childFieldId, parentFieldId);
357 bool ShaderProcVariableBase::unlinkParent(
358 FieldContainer * const pParent,
359 UInt16 const parentFieldId)
361 if(parentFieldId == ParentsFieldId)
363 FieldContainer * pTypedParent =
364 dynamic_cast< FieldContainer * >(pParent);
366 if(pTypedParent != NULL)
368 Int32 iParentIdx = _mfParents.findIndex(pTypedParent);
370 if(iParentIdx != -1)
372 editMField(ParentsFieldMask, _mfParents);
374 _mfParents.erase(iParentIdx);
376 return true;
379 SWARNING << "Child ([" << this
380 << "] id [" << this->getId()
381 << "] type [" << this->getType().getCName()
382 << "] parentFieldId [" << parentFieldId
383 << "]) - Parent ([" << pParent
384 << "] id [" << pParent->getId()
385 << "] type [" << pParent->getType().getCName()
386 << "]): link inconsistent!"
387 << std::endl;
389 return false;
392 return false;
395 return Inherited::unlinkParent(pParent, parentFieldId);
400 GetFieldHandlePtr ShaderProcVariableBase::getHandleDependency (void) const
402 SFUInt32::GetHandlePtr returnValue(
403 new SFUInt32::GetHandle(
404 &_sfDependency,
405 this->getType().getFieldDesc(DependencyFieldId),
406 const_cast<ShaderProcVariableBase *>(this)));
408 return returnValue;
411 EditFieldHandlePtr ShaderProcVariableBase::editHandleDependency (void)
413 SFUInt32::EditHandlePtr returnValue(
414 new SFUInt32::EditHandle(
415 &_sfDependency,
416 this->getType().getFieldDesc(DependencyFieldId),
417 this));
420 editSField(DependencyFieldMask);
422 return returnValue;
425 GetFieldHandlePtr ShaderProcVariableBase::getHandleParents (void) const
427 MFParentFieldContainerPtr::GetHandlePtr returnValue;
429 return returnValue;
432 EditFieldHandlePtr ShaderProcVariableBase::editHandleParents (void)
434 EditFieldHandlePtr returnValue;
436 return returnValue;
440 #ifdef OSG_MT_CPTR_ASPECT
441 void ShaderProcVariableBase::execSyncV( FieldContainer &oFrom,
442 ConstFieldMaskArg whichField,
443 AspectOffsetStore &oOffsets,
444 ConstFieldMaskArg syncMode,
445 const UInt32 uiSyncInfo)
447 ShaderProcVariable *pThis = static_cast<ShaderProcVariable *>(this);
449 pThis->execSync(static_cast<ShaderProcVariable *>(&oFrom),
450 whichField,
451 oOffsets,
452 syncMode,
453 uiSyncInfo);
455 #endif
459 void ShaderProcVariableBase::resolveLinks(void)
461 Inherited::resolveLinks();
467 OSG_END_NAMESPACE