changed: gcc8 base update
[opensg.git] / Source / System / Dynamics / Animation / OSGAnimChannelBase.cpp
bloba06871b0f67a90c3e19e6c06e4a110073e71e3fc
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 AnimChannel!
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 "OSGAnimation.h" // Animation Class
67 #include "OSGAnimChannelBase.h"
68 #include "OSGAnimChannel.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::AnimChannel
79 Base for animation data sinks.
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var Animation * AnimChannelBase::_sfAnimation
90 /*! \var Real32 AnimChannelBase::_sfWeight
94 /*! \var Real32 AnimChannelBase::_sfInValue
99 /***************************************************************************\
100 * FieldType/FieldTrait Instantiation *
101 \***************************************************************************/
103 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
104 PointerType FieldTraits<AnimChannel *, nsOSG>::_type(
105 "AnimChannelPtr",
106 "NodeCorePtr",
107 AnimChannel::getClassType(),
108 nsOSG);
109 #endif
111 OSG_FIELDTRAITS_GETTYPE_NS(AnimChannel *, nsOSG)
113 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
114 AnimChannel *,
115 nsOSG)
117 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
118 AnimChannel *,
119 nsOSG)
121 DataType &FieldTraits< AnimChannel *, nsOSG + 1 >::getType(void)
123 return FieldTraits<AnimChannel *, nsOSG>::getType();
127 OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
128 AnimChannel *,
129 UnrecordedRefCountPolicy,
130 nsOSG + 1)
133 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
134 AnimChannel *,
135 UnrecordedRefCountPolicy,
136 nsOSG + 1)
139 /***************************************************************************\
140 * Field Description *
141 \***************************************************************************/
143 void AnimChannelBase::classDescInserter(TypeObject &oType)
145 FieldDescriptionBase *pDesc = NULL;
148 pDesc = new SFParentAnimationPtr::Description(
149 SFParentAnimationPtr::getClassType(),
150 "animation",
152 AnimationFieldId, AnimationFieldMask,
153 false,
154 (Field::FClusterLocal),
155 static_cast <FieldEditMethodSig>(&AnimChannel::invalidEditField),
156 static_cast <FieldGetMethodSig >(&AnimChannel::invalidGetField));
158 oType.addInitialDesc(pDesc);
160 pDesc = new SFReal32::Description(
161 SFReal32::getClassType(),
162 "weight",
164 WeightFieldId, WeightFieldMask,
165 false,
166 (Field::FClusterLocal),
167 static_cast<FieldEditMethodSig>(&AnimChannel::editHandleWeight),
168 static_cast<FieldGetMethodSig >(&AnimChannel::getHandleWeight));
170 oType.addInitialDesc(pDesc);
172 pDesc = new SFReal32::Description(
173 SFReal32::getClassType(),
174 "inValue",
176 InValueFieldId, InValueFieldMask,
177 false,
178 (Field::FClusterLocal),
179 static_cast<FieldEditMethodSig>(&AnimChannel::editHandleInValue),
180 static_cast<FieldGetMethodSig >(&AnimChannel::getHandleInValue));
182 oType.addInitialDesc(pDesc);
186 AnimChannelBase::TypeObject AnimChannelBase::_type(
187 AnimChannelBase::getClassname(),
188 Inherited::getClassname(),
189 "NULL",
190 nsOSG, //Namespace
191 NULL,
192 reinterpret_cast<InitContainerF>(&AnimChannel::initMethod),
193 reinterpret_cast<ExitContainerF>(&AnimChannel::exitMethod),
194 reinterpret_cast<InitalInsertDescFunc>(
195 reinterpret_cast<void *>(&AnimChannel::classDescInserter)),
196 false,
198 "<?xml version=\"1.0\"?>\n"
199 "\n"
200 "<FieldContainer\n"
201 " name=\"AnimChannel\"\n"
202 " parent=\"NodeCore\"\n"
203 " library=\"Dynamics\"\n"
204 " pointerfieldtypes=\"both\"\n"
205 " structure=\"abstract\"\n"
206 " systemcomponent=\"true\"\n"
207 " parentsystemcomponent=\"true\"\n"
208 " decoratable=\"false\"\n"
209 " useLocalIncludes=\"false\"\n"
210 " isNodeCore=\"true\"\n"
211 " isBundle=\"false\"\n"
212 " childFields=\"both\"\n"
213 " parentFields=\"none\"\n"
214 ">\n"
215 " Base for animation data sinks.\n"
216 " \n"
217 " <Field\n"
218 " name=\"animation\"\n"
219 " category=\"parentpointer\"\n"
220 " type=\"Animation\"\n"
221 " cardinality=\"single\"\n"
222 " visibility=\"external\"\n"
223 " access=\"none\"\n"
224 " fieldFlags=\"FClusterLocal\"\n"
225 " >\n"
226 " </Field>\n"
227 " <Field\n"
228 " name=\"weight\"\n"
229 " category=\"data\"\n"
230 " type=\"Real32\"\n"
231 " cardinality=\"single\"\n"
232 " visibility=\"external\"\n"
233 " access=\"public\"\n"
234 " defaultValue=\"1.f\"\n"
235 " fieldFlags=\"FClusterLocal\"\n"
236 " >\n"
237 " </Field>\n"
238 " <Field\n"
239 " name=\"inValue\"\n"
240 " category=\"data\"\n"
241 " type=\"Real32\"\n"
242 " cardinality=\"single\"\n"
243 " visibility=\"external\"\n"
244 " access=\"public\"\n"
245 " defaultValue=\"0.0\"\n"
246 " fieldFlags=\"FClusterLocal\"\n"
247 " >\n"
248 " </Field>\n"
249 "</FieldContainer>\n",
250 "Base for animation data sinks.\n"
253 /*------------------------------ get -----------------------------------*/
255 FieldContainerType &AnimChannelBase::getType(void)
257 return _type;
260 const FieldContainerType &AnimChannelBase::getType(void) const
262 return _type;
265 UInt32 AnimChannelBase::getContainerSize(void) const
267 return sizeof(AnimChannel);
270 /*------------------------- decorator get ------------------------------*/
274 SFReal32 *AnimChannelBase::editSFWeight(void)
276 editSField(WeightFieldMask);
278 return &_sfWeight;
281 const SFReal32 *AnimChannelBase::getSFWeight(void) const
283 return &_sfWeight;
287 SFReal32 *AnimChannelBase::editSFInValue(void)
289 editSField(InValueFieldMask);
291 return &_sfInValue;
294 const SFReal32 *AnimChannelBase::getSFInValue(void) const
296 return &_sfInValue;
304 /*------------------------------ access -----------------------------------*/
306 SizeT AnimChannelBase::getBinSize(ConstFieldMaskArg whichField)
308 SizeT returnValue = Inherited::getBinSize(whichField);
310 if(FieldBits::NoField != (AnimationFieldMask & whichField))
312 returnValue += _sfAnimation.getBinSize();
314 if(FieldBits::NoField != (WeightFieldMask & whichField))
316 returnValue += _sfWeight.getBinSize();
318 if(FieldBits::NoField != (InValueFieldMask & whichField))
320 returnValue += _sfInValue.getBinSize();
323 return returnValue;
326 void AnimChannelBase::copyToBin(BinaryDataHandler &pMem,
327 ConstFieldMaskArg whichField)
329 Inherited::copyToBin(pMem, whichField);
331 if(FieldBits::NoField != (AnimationFieldMask & whichField))
333 _sfAnimation.copyToBin(pMem);
335 if(FieldBits::NoField != (WeightFieldMask & whichField))
337 _sfWeight.copyToBin(pMem);
339 if(FieldBits::NoField != (InValueFieldMask & whichField))
341 _sfInValue.copyToBin(pMem);
345 void AnimChannelBase::copyFromBin(BinaryDataHandler &pMem,
346 ConstFieldMaskArg whichField)
348 Inherited::copyFromBin(pMem, whichField);
350 if(FieldBits::NoField != (AnimationFieldMask & whichField))
352 editSField(AnimationFieldMask);
353 _sfAnimation.copyFromBin(pMem);
355 if(FieldBits::NoField != (WeightFieldMask & whichField))
357 editSField(WeightFieldMask);
358 _sfWeight.copyFromBin(pMem);
360 if(FieldBits::NoField != (InValueFieldMask & whichField))
362 editSField(InValueFieldMask);
363 _sfInValue.copyFromBin(pMem);
370 /*------------------------- constructors ----------------------------------*/
372 AnimChannelBase::AnimChannelBase(void) :
373 Inherited(),
374 _sfAnimation (NULL),
375 _sfWeight (Real32(1.f)),
376 _sfInValue (Real32(0.0))
380 AnimChannelBase::AnimChannelBase(const AnimChannelBase &source) :
381 Inherited(source),
382 _sfAnimation (NULL),
383 _sfWeight (source._sfWeight ),
384 _sfInValue (source._sfInValue )
389 /*-------------------------- destructors ----------------------------------*/
391 AnimChannelBase::~AnimChannelBase(void)
394 /*-------------------------------------------------------------------------*/
395 /* Parent linking */
397 bool AnimChannelBase::linkParent(
398 FieldContainer * const pParent,
399 UInt16 const childFieldId,
400 UInt16 const parentFieldId )
402 if(parentFieldId == AnimationFieldId)
404 Animation * pTypedParent =
405 dynamic_cast< Animation * >(pParent);
407 if(pTypedParent != NULL)
409 FieldContainer *pOldParent =
410 _sfAnimation.getValue ();
412 UInt16 oldChildFieldId =
413 _sfAnimation.getParentFieldPos();
415 if(pOldParent != NULL)
417 pOldParent->unlinkChild(this, oldChildFieldId);
420 editSField(AnimationFieldMask);
422 _sfAnimation.setValue(static_cast<Animation *>(pParent), childFieldId);
424 return true;
427 return false;
430 return Inherited::linkParent(pParent, childFieldId, parentFieldId);
433 bool AnimChannelBase::unlinkParent(
434 FieldContainer * const pParent,
435 UInt16 const parentFieldId)
437 if(parentFieldId == AnimationFieldId)
439 Animation * pTypedParent =
440 dynamic_cast< Animation * >(pParent);
442 if(pTypedParent != NULL)
444 if(_sfAnimation.getValue() == pTypedParent)
446 editSField(AnimationFieldMask);
448 _sfAnimation.setValue(NULL, 0xFFFF);
450 return true;
453 SWARNING << "Child ([" << this
454 << "] id [" << this->getId()
455 << "] type [" << this->getType().getCName()
456 << "] parentFieldId [" << parentFieldId
457 << "]) - Parent ([" << pParent
458 << "] id [" << pParent->getId()
459 << "] type [" << pParent->getType().getCName()
460 << "]): link inconsistent!"
461 << std::endl;
463 return false;
466 return false;
469 return Inherited::unlinkParent(pParent, parentFieldId);
474 GetFieldHandlePtr AnimChannelBase::getHandleAnimation (void) const
476 SFParentAnimationPtr::GetHandlePtr returnValue;
478 return returnValue;
481 EditFieldHandlePtr AnimChannelBase::editHandleAnimation (void)
483 EditFieldHandlePtr returnValue;
485 return returnValue;
488 GetFieldHandlePtr AnimChannelBase::getHandleWeight (void) const
490 SFReal32::GetHandlePtr returnValue(
491 new SFReal32::GetHandle(
492 &_sfWeight,
493 this->getType().getFieldDesc(WeightFieldId),
494 const_cast<AnimChannelBase *>(this)));
496 return returnValue;
499 EditFieldHandlePtr AnimChannelBase::editHandleWeight (void)
501 SFReal32::EditHandlePtr returnValue(
502 new SFReal32::EditHandle(
503 &_sfWeight,
504 this->getType().getFieldDesc(WeightFieldId),
505 this));
508 editSField(WeightFieldMask);
510 return returnValue;
513 GetFieldHandlePtr AnimChannelBase::getHandleInValue (void) const
515 SFReal32::GetHandlePtr returnValue(
516 new SFReal32::GetHandle(
517 &_sfInValue,
518 this->getType().getFieldDesc(InValueFieldId),
519 const_cast<AnimChannelBase *>(this)));
521 return returnValue;
524 EditFieldHandlePtr AnimChannelBase::editHandleInValue (void)
526 SFReal32::EditHandlePtr returnValue(
527 new SFReal32::EditHandle(
528 &_sfInValue,
529 this->getType().getFieldDesc(InValueFieldId),
530 this));
533 editSField(InValueFieldMask);
535 return returnValue;
539 #ifdef OSG_MT_CPTR_ASPECT
540 void AnimChannelBase::execSyncV( FieldContainer &oFrom,
541 ConstFieldMaskArg whichField,
542 AspectOffsetStore &oOffsets,
543 ConstFieldMaskArg syncMode,
544 const UInt32 uiSyncInfo)
546 AnimChannel *pThis = static_cast<AnimChannel *>(this);
548 pThis->execSync(static_cast<AnimChannel *>(&oFrom),
549 whichField,
550 oOffsets,
551 syncMode,
552 uiSyncInfo);
554 #endif
558 void AnimChannelBase::resolveLinks(void)
560 Inherited::resolveLinks();
566 OSG_END_NAMESPACE