fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Dynamics / VRMLAnimation / OSGVRMLInterpolatorBase.cpp
blob650dfea0d6ae7a2c4b49d470edd78f0e293a5760
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 VRMLInterpolator!
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 "OSGVRMLInterpolatorBase.h"
67 #include "OSGVRMLInterpolator.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::VRMLInterpolator
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var Real32 VRMLInterpolatorBase::_sfInValue
86 This is VRML's fraction field.
89 /*! \var Real32 VRMLInterpolatorBase::_mfKey
93 /*! \var UInt32 VRMLInterpolatorBase::_mfResortIndex
98 /***************************************************************************\
99 * FieldType/FieldTrait Instantiation *
100 \***************************************************************************/
102 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
103 PointerType FieldTraits<VRMLInterpolator *, nsOSG>::_type(
104 "VRMLInterpolatorPtr",
105 "NodeCorePtr",
106 VRMLInterpolator::getClassType(),
107 nsOSG);
108 #endif
110 OSG_FIELDTRAITS_GETTYPE_NS(VRMLInterpolator *, nsOSG)
112 /***************************************************************************\
113 * Field Description *
114 \***************************************************************************/
116 void VRMLInterpolatorBase::classDescInserter(TypeObject &oType)
118 FieldDescriptionBase *pDesc = NULL;
121 pDesc = new SFReal32::Description(
122 SFReal32::getClassType(),
123 "inValue",
124 "This is VRML's fraction field.\n",
125 InValueFieldId, InValueFieldMask,
126 true,
127 (Field::FStdAccess | Field::FThreadLocal),
128 static_cast<FieldEditMethodSig>(&VRMLInterpolator::editHandleInValue),
129 static_cast<FieldGetMethodSig >(&VRMLInterpolator::getHandleInValue));
131 oType.addInitialDesc(pDesc);
133 pDesc = new MFReal32::Description(
134 MFReal32::getClassType(),
135 "key",
137 KeyFieldId, KeyFieldMask,
138 false,
139 (Field::FStdAccess | Field::FThreadLocal),
140 static_cast<FieldEditMethodSig>(&VRMLInterpolator::editHandleKey),
141 static_cast<FieldGetMethodSig >(&VRMLInterpolator::getHandleKey));
143 oType.addInitialDesc(pDesc);
145 pDesc = new MFUInt32::Description(
146 MFUInt32::getClassType(),
147 "resortIndex",
149 ResortIndexFieldId, ResortIndexFieldMask,
150 false,
151 (Field::FStdAccess | Field::FThreadLocal),
152 static_cast<FieldEditMethodSig>(&VRMLInterpolator::editHandleResortIndex),
153 static_cast<FieldGetMethodSig >(&VRMLInterpolator::getHandleResortIndex));
155 oType.addInitialDesc(pDesc);
159 VRMLInterpolatorBase::TypeObject VRMLInterpolatorBase::_type(
160 VRMLInterpolatorBase::getClassname(),
161 Inherited::getClassname(),
162 "NULL",
163 nsOSG, //Namespace
164 reinterpret_cast<PrototypeCreateF>(&VRMLInterpolatorBase::createEmptyLocal),
165 reinterpret_cast<InitContainerF>(&VRMLInterpolator::initMethod),
166 reinterpret_cast<ExitContainerF>(&VRMLInterpolator::exitMethod),
167 reinterpret_cast<InitalInsertDescFunc>(
168 reinterpret_cast<void *>(&VRMLInterpolator::classDescInserter)),
169 false,
170 ResortIndexFieldMask,
171 "<?xml version=\"1.0\"?>\n"
172 "\n"
173 "<FieldContainer\n"
174 " name=\"VRMLInterpolator\"\n"
175 " parent=\"NodeCore\"\n"
176 " library=\"Dynamics\"\n"
177 " pointerfieldtypes=\"none\"\n"
178 " structure=\"concrete\"\n"
179 " systemcomponent=\"true\"\n"
180 " parentsystemcomponent=\"true\"\n"
181 " decoratable=\"false\"\n"
182 " useLocalIncludes=\"false\"\n"
183 " isNodeCore=\"true\"\n"
184 " isBundle=\"false\"\n"
185 " parentFields=\"none\"\n"
186 " fieldsUnmarkedOnCreate=\"ResortIndexFieldMask\"\n"
187 " docGroupBase=\"GrpDynamicsVRMLAnimation\"\n"
188 " >\n"
189 " <Field\n"
190 " name=\"inValue\"\n"
191 " type=\"Real32\"\n"
192 " cardinality=\"single\"\n"
193 " visibility=\"internal\"\n"
194 " access=\"public\"\n"
195 " defaultValue=\"0.f\"\n"
196 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
197 " >\n"
198 " This is VRML's fraction field.\n"
199 " </Field>\n"
200 " <Field\n"
201 " name=\"key\"\n"
202 " type=\"Real32\"\n"
203 " cardinality=\"multi\"\n"
204 " visibility=\"external\"\n"
205 " access=\"public\"\n"
206 " defaultValue=\"\"\n"
207 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
208 " >\n"
209 " </Field>\n"
210 " <Field\n"
211 " name=\"resortIndex\"\n"
212 " type=\"UInt32\"\n"
213 " cardinality=\"multi\"\n"
214 " visibility=\"external\"\n"
215 " access=\"public\"\n"
216 " defaultValue=\"\"\n"
217 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
218 " >\n"
219 " </Field>\n"
220 "</FieldContainer>\n",
224 /*------------------------------ get -----------------------------------*/
226 FieldContainerType &VRMLInterpolatorBase::getType(void)
228 return _type;
231 const FieldContainerType &VRMLInterpolatorBase::getType(void) const
233 return _type;
236 UInt32 VRMLInterpolatorBase::getContainerSize(void) const
238 return sizeof(VRMLInterpolator);
241 /*------------------------- decorator get ------------------------------*/
244 SFReal32 *VRMLInterpolatorBase::editSFInValue(void)
246 editSField(InValueFieldMask);
248 return &_sfInValue;
251 const SFReal32 *VRMLInterpolatorBase::getSFInValue(void) const
253 return &_sfInValue;
257 MFReal32 *VRMLInterpolatorBase::editMFKey(void)
259 editMField(KeyFieldMask, _mfKey);
261 return &_mfKey;
264 const MFReal32 *VRMLInterpolatorBase::getMFKey(void) const
266 return &_mfKey;
270 MFUInt32 *VRMLInterpolatorBase::editMFResortIndex(void)
272 editMField(ResortIndexFieldMask, _mfResortIndex);
274 return &_mfResortIndex;
277 const MFUInt32 *VRMLInterpolatorBase::getMFResortIndex(void) const
279 return &_mfResortIndex;
287 /*------------------------------ access -----------------------------------*/
289 SizeT VRMLInterpolatorBase::getBinSize(ConstFieldMaskArg whichField)
291 SizeT returnValue = Inherited::getBinSize(whichField);
293 if(FieldBits::NoField != (InValueFieldMask & whichField))
295 returnValue += _sfInValue.getBinSize();
297 if(FieldBits::NoField != (KeyFieldMask & whichField))
299 returnValue += _mfKey.getBinSize();
301 if(FieldBits::NoField != (ResortIndexFieldMask & whichField))
303 returnValue += _mfResortIndex.getBinSize();
306 return returnValue;
309 void VRMLInterpolatorBase::copyToBin(BinaryDataHandler &pMem,
310 ConstFieldMaskArg whichField)
312 Inherited::copyToBin(pMem, whichField);
314 if(FieldBits::NoField != (InValueFieldMask & whichField))
316 _sfInValue.copyToBin(pMem);
318 if(FieldBits::NoField != (KeyFieldMask & whichField))
320 _mfKey.copyToBin(pMem);
322 if(FieldBits::NoField != (ResortIndexFieldMask & whichField))
324 _mfResortIndex.copyToBin(pMem);
328 void VRMLInterpolatorBase::copyFromBin(BinaryDataHandler &pMem,
329 ConstFieldMaskArg whichField)
331 Inherited::copyFromBin(pMem, whichField);
333 if(FieldBits::NoField != (InValueFieldMask & whichField))
335 editSField(InValueFieldMask);
336 _sfInValue.copyFromBin(pMem);
338 if(FieldBits::NoField != (KeyFieldMask & whichField))
340 editMField(KeyFieldMask, _mfKey);
341 _mfKey.copyFromBin(pMem);
343 if(FieldBits::NoField != (ResortIndexFieldMask & whichField))
345 editMField(ResortIndexFieldMask, _mfResortIndex);
346 _mfResortIndex.copyFromBin(pMem);
350 //! create a new instance of the class
351 VRMLInterpolatorTransitPtr VRMLInterpolatorBase::createLocal(BitVector bFlags)
353 VRMLInterpolatorTransitPtr fc;
355 if(getClassType().getPrototype() != NULL)
357 FieldContainerTransitPtr tmpPtr =
358 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
360 fc = dynamic_pointer_cast<VRMLInterpolator>(tmpPtr);
363 return fc;
366 //! create a new instance of the class, copy the container flags
367 VRMLInterpolatorTransitPtr VRMLInterpolatorBase::createDependent(BitVector bFlags)
369 VRMLInterpolatorTransitPtr fc;
371 if(getClassType().getPrototype() != NULL)
373 FieldContainerTransitPtr tmpPtr =
374 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
376 fc = dynamic_pointer_cast<VRMLInterpolator>(tmpPtr);
379 return fc;
382 //! create a new instance of the class
383 VRMLInterpolatorTransitPtr VRMLInterpolatorBase::create(void)
385 VRMLInterpolatorTransitPtr fc;
387 if(getClassType().getPrototype() != NULL)
389 FieldContainerTransitPtr tmpPtr =
390 getClassType().getPrototype()-> shallowCopy();
392 fc = dynamic_pointer_cast<VRMLInterpolator>(tmpPtr);
395 return fc;
398 VRMLInterpolator *VRMLInterpolatorBase::createEmptyLocal(BitVector bFlags)
400 VRMLInterpolator *returnValue;
402 newPtr<VRMLInterpolator>(returnValue, bFlags);
404 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
406 return returnValue;
409 //! create an empty new instance of the class, do not copy the prototype
410 VRMLInterpolator *VRMLInterpolatorBase::createEmpty(void)
412 VRMLInterpolator *returnValue;
414 newPtr<VRMLInterpolator>(returnValue, Thread::getCurrentLocalFlags());
416 returnValue->_pFieldFlags->_bNamespaceMask &=
417 ~Thread::getCurrentLocalFlags();
419 return returnValue;
423 FieldContainerTransitPtr VRMLInterpolatorBase::shallowCopyLocal(
424 BitVector bFlags) const
426 VRMLInterpolator *tmpPtr;
428 newPtr(tmpPtr, dynamic_cast<const VRMLInterpolator *>(this), bFlags);
430 FieldContainerTransitPtr returnValue(tmpPtr);
432 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
434 return returnValue;
437 FieldContainerTransitPtr VRMLInterpolatorBase::shallowCopyDependent(
438 BitVector bFlags) const
440 VRMLInterpolator *tmpPtr;
442 newPtr(tmpPtr, dynamic_cast<const VRMLInterpolator *>(this), ~bFlags);
444 FieldContainerTransitPtr returnValue(tmpPtr);
446 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
448 return returnValue;
451 FieldContainerTransitPtr VRMLInterpolatorBase::shallowCopy(void) const
453 VRMLInterpolator *tmpPtr;
455 newPtr(tmpPtr,
456 dynamic_cast<const VRMLInterpolator *>(this),
457 Thread::getCurrentLocalFlags());
459 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
461 FieldContainerTransitPtr returnValue(tmpPtr);
463 return returnValue;
469 /*------------------------- constructors ----------------------------------*/
471 VRMLInterpolatorBase::VRMLInterpolatorBase(void) :
472 Inherited(),
473 _sfInValue (Real32(0.f)),
474 _mfKey (),
475 _mfResortIndex ()
479 VRMLInterpolatorBase::VRMLInterpolatorBase(const VRMLInterpolatorBase &source) :
480 Inherited(source),
481 _sfInValue (source._sfInValue ),
482 _mfKey (source._mfKey ),
483 _mfResortIndex (source._mfResortIndex )
488 /*-------------------------- destructors ----------------------------------*/
490 VRMLInterpolatorBase::~VRMLInterpolatorBase(void)
495 GetFieldHandlePtr VRMLInterpolatorBase::getHandleInValue (void) const
497 SFReal32::GetHandlePtr returnValue(
498 new SFReal32::GetHandle(
499 &_sfInValue,
500 this->getType().getFieldDesc(InValueFieldId),
501 const_cast<VRMLInterpolatorBase *>(this)));
503 return returnValue;
506 EditFieldHandlePtr VRMLInterpolatorBase::editHandleInValue (void)
508 SFReal32::EditHandlePtr returnValue(
509 new SFReal32::EditHandle(
510 &_sfInValue,
511 this->getType().getFieldDesc(InValueFieldId),
512 this));
515 editSField(InValueFieldMask);
517 return returnValue;
520 GetFieldHandlePtr VRMLInterpolatorBase::getHandleKey (void) const
522 MFReal32::GetHandlePtr returnValue(
523 new MFReal32::GetHandle(
524 &_mfKey,
525 this->getType().getFieldDesc(KeyFieldId),
526 const_cast<VRMLInterpolatorBase *>(this)));
528 return returnValue;
531 EditFieldHandlePtr VRMLInterpolatorBase::editHandleKey (void)
533 MFReal32::EditHandlePtr returnValue(
534 new MFReal32::EditHandle(
535 &_mfKey,
536 this->getType().getFieldDesc(KeyFieldId),
537 this));
540 editMField(KeyFieldMask, _mfKey);
542 return returnValue;
545 GetFieldHandlePtr VRMLInterpolatorBase::getHandleResortIndex (void) const
547 MFUInt32::GetHandlePtr returnValue(
548 new MFUInt32::GetHandle(
549 &_mfResortIndex,
550 this->getType().getFieldDesc(ResortIndexFieldId),
551 const_cast<VRMLInterpolatorBase *>(this)));
553 return returnValue;
556 EditFieldHandlePtr VRMLInterpolatorBase::editHandleResortIndex (void)
558 MFUInt32::EditHandlePtr returnValue(
559 new MFUInt32::EditHandle(
560 &_mfResortIndex,
561 this->getType().getFieldDesc(ResortIndexFieldId),
562 this));
565 editMField(ResortIndexFieldMask, _mfResortIndex);
567 return returnValue;
571 #ifdef OSG_MT_CPTR_ASPECT
572 void VRMLInterpolatorBase::execSyncV( FieldContainer &oFrom,
573 ConstFieldMaskArg whichField,
574 AspectOffsetStore &oOffsets,
575 ConstFieldMaskArg syncMode,
576 const UInt32 uiSyncInfo)
578 VRMLInterpolator *pThis = static_cast<VRMLInterpolator *>(this);
580 pThis->execSync(static_cast<VRMLInterpolator *>(&oFrom),
581 whichField,
582 oOffsets,
583 syncMode,
584 uiSyncInfo);
586 #endif
589 #ifdef OSG_MT_CPTR_ASPECT
590 FieldContainer *VRMLInterpolatorBase::createAspectCopy(
591 const FieldContainer *pRefAspect) const
593 VRMLInterpolator *returnValue;
595 newAspectCopy(returnValue,
596 dynamic_cast<const VRMLInterpolator *>(pRefAspect),
597 dynamic_cast<const VRMLInterpolator *>(this));
599 return returnValue;
601 #endif
603 void VRMLInterpolatorBase::resolveLinks(void)
605 Inherited::resolveLinks();
607 #ifdef OSG_MT_CPTR_ASPECT
608 AspectOffsetStore oOffsets;
610 _pAspectStore->fillOffsetArray(oOffsets, this);
611 #endif
613 #ifdef OSG_MT_CPTR_ASPECT
614 _mfKey.terminateShare(Thread::getCurrentAspect(),
615 oOffsets);
616 #endif
617 #ifdef OSG_MT_CPTR_ASPECT
618 _mfResortIndex.terminateShare(Thread::getCurrentAspect(),
619 oOffsets);
620 #endif
624 OSG_END_NAMESPACE