changed: gcc8 base update
[opensg.git] / Source / System / Dynamics / Animation / OSGAnimMatrixBlenderBase.cpp
blobfe2901b5bdbd176c45651c2bb87a611fda2b1be7
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 AnimMatrixBlender!
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 "OSGAnimMatrixChannel.h" // Channels Class
67 #include "OSGAnimMatrixBlenderBase.h"
68 #include "OSGAnimMatrixBlender.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::AnimMatrixBlender
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var AnimMatrixChannel * AnimMatrixBlenderBase::_mfChannels
90 /*! \var Matrix AnimMatrixBlenderBase::_sfOutValue
95 /***************************************************************************\
96 * FieldType/FieldTrait Instantiation *
97 \***************************************************************************/
99 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
100 PointerType FieldTraits<AnimMatrixBlender *, nsOSG>::_type(
101 "AnimMatrixBlenderPtr",
102 "AnimBlenderPtr",
103 AnimMatrixBlender::getClassType(),
104 nsOSG);
105 #endif
107 OSG_FIELDTRAITS_GETTYPE_NS(AnimMatrixBlender *, nsOSG)
109 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
110 AnimMatrixBlender *,
111 nsOSG)
113 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
114 AnimMatrixBlender *,
115 nsOSG)
117 /***************************************************************************\
118 * Field Description *
119 \***************************************************************************/
121 void AnimMatrixBlenderBase::classDescInserter(TypeObject &oType)
123 FieldDescriptionBase *pDesc = NULL;
126 pDesc = new MFUnrecAnimMatrixChannelPtr::Description(
127 MFUnrecAnimMatrixChannelPtr::getClassType(),
128 "channels",
130 ChannelsFieldId, ChannelsFieldMask,
131 false,
132 (Field::FStdAccess | Field::FClusterLocal),
133 static_cast<FieldEditMethodSig>(&AnimMatrixBlender::editHandleChannels),
134 static_cast<FieldGetMethodSig >(&AnimMatrixBlender::getHandleChannels));
136 oType.addInitialDesc(pDesc);
138 pDesc = new SFMatrix::Description(
139 SFMatrix::getClassType(),
140 "outValue",
142 OutValueFieldId, OutValueFieldMask,
143 false,
144 (Field::FClusterLocal),
145 static_cast<FieldEditMethodSig>(&AnimMatrixBlender::editHandleOutValue),
146 static_cast<FieldGetMethodSig >(&AnimMatrixBlender::getHandleOutValue));
148 oType.addInitialDesc(pDesc);
152 AnimMatrixBlenderBase::TypeObject AnimMatrixBlenderBase::_type(
153 AnimMatrixBlenderBase::getClassname(),
154 Inherited::getClassname(),
155 "NULL",
156 nsOSG, //Namespace
157 reinterpret_cast<PrototypeCreateF>(&AnimMatrixBlenderBase::createEmptyLocal),
158 reinterpret_cast<InitContainerF>(&AnimMatrixBlender::initMethod),
159 reinterpret_cast<ExitContainerF>(&AnimMatrixBlender::exitMethod),
160 reinterpret_cast<InitalInsertDescFunc>(
161 reinterpret_cast<void *>(&AnimMatrixBlender::classDescInserter)),
162 false,
164 "<?xml version=\"1.0\"?>\n"
165 "\n"
166 "<FieldContainer\n"
167 " name=\"AnimMatrixBlender\"\n"
168 " parent=\"AnimBlender\"\n"
169 " library=\"Dynamics\"\n"
170 " pointerfieldtypes=\"both\"\n"
171 " structure=\"concrete\"\n"
172 " systemcomponent=\"true\"\n"
173 " parentsystemcomponent=\"true\"\n"
174 " decoratable=\"false\"\n"
175 " useLocalIncludes=\"false\"\n"
176 " isNodeCore=\"true\"\n"
177 " isBundle=\"false\"\n"
178 " parentFields=\"none\"\n"
179 " >\n"
180 " <Field\n"
181 " name=\"channels\"\n"
182 " category=\"pointer\"\n"
183 " type=\"AnimMatrixChannel\"\n"
184 " cardinality=\"multi\"\n"
185 " visibility=\"external\"\n"
186 " access=\"public\"\n"
187 " fieldFlags=\"FStdAccess, FClusterLocal\"\n"
188 " >\n"
189 " </Field>\n"
190 " <Field\n"
191 " name=\"outValue\"\n"
192 " category=\"data\"\n"
193 " type=\"Matrix\"\n"
194 " cardinality=\"single\"\n"
195 " visibility=\"external\"\n"
196 " access=\"public\"\n"
197 " fieldFlags=\"FClusterLocal\"\n"
198 " >\n"
199 " </Field>\n"
200 "</FieldContainer>\n",
204 /*------------------------------ get -----------------------------------*/
206 FieldContainerType &AnimMatrixBlenderBase::getType(void)
208 return _type;
211 const FieldContainerType &AnimMatrixBlenderBase::getType(void) const
213 return _type;
216 UInt32 AnimMatrixBlenderBase::getContainerSize(void) const
218 return sizeof(AnimMatrixBlender);
221 /*------------------------- decorator get ------------------------------*/
224 //! Get the AnimMatrixBlender::_mfChannels field.
225 const MFUnrecAnimMatrixChannelPtr *AnimMatrixBlenderBase::getMFChannels(void) const
227 return &_mfChannels;
230 MFUnrecAnimMatrixChannelPtr *AnimMatrixBlenderBase::editMFChannels (void)
232 editMField(ChannelsFieldMask, _mfChannels);
234 return &_mfChannels;
236 AnimMatrixChannel * AnimMatrixBlenderBase::getChannels(const UInt32 index) const
238 return _mfChannels[index];
241 SFMatrix *AnimMatrixBlenderBase::editSFOutValue(void)
243 editSField(OutValueFieldMask);
245 return &_sfOutValue;
248 const SFMatrix *AnimMatrixBlenderBase::getSFOutValue(void) const
250 return &_sfOutValue;
256 void AnimMatrixBlenderBase::pushToChannels(AnimMatrixChannel * const value)
258 editMField(ChannelsFieldMask, _mfChannels);
260 _mfChannels.push_back(value);
263 void AnimMatrixBlenderBase::assignChannels (const MFUnrecAnimMatrixChannelPtr &value)
265 MFUnrecAnimMatrixChannelPtr::const_iterator elemIt =
266 value.begin();
267 MFUnrecAnimMatrixChannelPtr::const_iterator elemEnd =
268 value.end ();
270 static_cast<AnimMatrixBlender *>(this)->clearChannels();
272 while(elemIt != elemEnd)
274 this->pushToChannels(*elemIt);
276 ++elemIt;
280 void AnimMatrixBlenderBase::removeFromChannels(UInt32 uiIndex)
282 if(uiIndex < _mfChannels.size())
284 editMField(ChannelsFieldMask, _mfChannels);
286 _mfChannels.erase(uiIndex);
290 void AnimMatrixBlenderBase::removeObjFromChannels(AnimMatrixChannel * const value)
292 Int32 iElemIdx = _mfChannels.findIndex(value);
294 if(iElemIdx != -1)
296 editMField(ChannelsFieldMask, _mfChannels);
298 _mfChannels.erase(iElemIdx);
301 void AnimMatrixBlenderBase::clearChannels(void)
303 editMField(ChannelsFieldMask, _mfChannels);
306 _mfChannels.clear();
311 /*------------------------------ access -----------------------------------*/
313 SizeT AnimMatrixBlenderBase::getBinSize(ConstFieldMaskArg whichField)
315 SizeT returnValue = Inherited::getBinSize(whichField);
317 if(FieldBits::NoField != (ChannelsFieldMask & whichField))
319 returnValue += _mfChannels.getBinSize();
321 if(FieldBits::NoField != (OutValueFieldMask & whichField))
323 returnValue += _sfOutValue.getBinSize();
326 return returnValue;
329 void AnimMatrixBlenderBase::copyToBin(BinaryDataHandler &pMem,
330 ConstFieldMaskArg whichField)
332 Inherited::copyToBin(pMem, whichField);
334 if(FieldBits::NoField != (ChannelsFieldMask & whichField))
336 _mfChannels.copyToBin(pMem);
338 if(FieldBits::NoField != (OutValueFieldMask & whichField))
340 _sfOutValue.copyToBin(pMem);
344 void AnimMatrixBlenderBase::copyFromBin(BinaryDataHandler &pMem,
345 ConstFieldMaskArg whichField)
347 Inherited::copyFromBin(pMem, whichField);
349 if(FieldBits::NoField != (ChannelsFieldMask & whichField))
351 editMField(ChannelsFieldMask, _mfChannels);
352 _mfChannels.copyFromBin(pMem);
354 if(FieldBits::NoField != (OutValueFieldMask & whichField))
356 editSField(OutValueFieldMask);
357 _sfOutValue.copyFromBin(pMem);
361 //! create a new instance of the class
362 AnimMatrixBlenderTransitPtr AnimMatrixBlenderBase::createLocal(BitVector bFlags)
364 AnimMatrixBlenderTransitPtr fc;
366 if(getClassType().getPrototype() != NULL)
368 FieldContainerTransitPtr tmpPtr =
369 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
371 fc = dynamic_pointer_cast<AnimMatrixBlender>(tmpPtr);
374 return fc;
377 //! create a new instance of the class, copy the container flags
378 AnimMatrixBlenderTransitPtr AnimMatrixBlenderBase::createDependent(BitVector bFlags)
380 AnimMatrixBlenderTransitPtr fc;
382 if(getClassType().getPrototype() != NULL)
384 FieldContainerTransitPtr tmpPtr =
385 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
387 fc = dynamic_pointer_cast<AnimMatrixBlender>(tmpPtr);
390 return fc;
393 //! create a new instance of the class
394 AnimMatrixBlenderTransitPtr AnimMatrixBlenderBase::create(void)
396 AnimMatrixBlenderTransitPtr fc;
398 if(getClassType().getPrototype() != NULL)
400 FieldContainerTransitPtr tmpPtr =
401 getClassType().getPrototype()-> shallowCopy();
403 fc = dynamic_pointer_cast<AnimMatrixBlender>(tmpPtr);
406 return fc;
409 AnimMatrixBlender *AnimMatrixBlenderBase::createEmptyLocal(BitVector bFlags)
411 AnimMatrixBlender *returnValue;
413 newPtr<AnimMatrixBlender>(returnValue, bFlags);
415 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
417 return returnValue;
420 //! create an empty new instance of the class, do not copy the prototype
421 AnimMatrixBlender *AnimMatrixBlenderBase::createEmpty(void)
423 AnimMatrixBlender *returnValue;
425 newPtr<AnimMatrixBlender>(returnValue, Thread::getCurrentLocalFlags());
427 returnValue->_pFieldFlags->_bNamespaceMask &=
428 ~Thread::getCurrentLocalFlags();
430 return returnValue;
434 FieldContainerTransitPtr AnimMatrixBlenderBase::shallowCopyLocal(
435 BitVector bFlags) const
437 AnimMatrixBlender *tmpPtr;
439 newPtr(tmpPtr, dynamic_cast<const AnimMatrixBlender *>(this), bFlags);
441 FieldContainerTransitPtr returnValue(tmpPtr);
443 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
445 return returnValue;
448 FieldContainerTransitPtr AnimMatrixBlenderBase::shallowCopyDependent(
449 BitVector bFlags) const
451 AnimMatrixBlender *tmpPtr;
453 newPtr(tmpPtr, dynamic_cast<const AnimMatrixBlender *>(this), ~bFlags);
455 FieldContainerTransitPtr returnValue(tmpPtr);
457 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
459 return returnValue;
462 FieldContainerTransitPtr AnimMatrixBlenderBase::shallowCopy(void) const
464 AnimMatrixBlender *tmpPtr;
466 newPtr(tmpPtr,
467 dynamic_cast<const AnimMatrixBlender *>(this),
468 Thread::getCurrentLocalFlags());
470 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
472 FieldContainerTransitPtr returnValue(tmpPtr);
474 return returnValue;
480 /*------------------------- constructors ----------------------------------*/
482 AnimMatrixBlenderBase::AnimMatrixBlenderBase(void) :
483 Inherited(),
484 _mfChannels (),
485 _sfOutValue ()
489 AnimMatrixBlenderBase::AnimMatrixBlenderBase(const AnimMatrixBlenderBase &source) :
490 Inherited(source),
491 _mfChannels (),
492 _sfOutValue (source._sfOutValue )
497 /*-------------------------- destructors ----------------------------------*/
499 AnimMatrixBlenderBase::~AnimMatrixBlenderBase(void)
503 void AnimMatrixBlenderBase::onCreate(const AnimMatrixBlender *source)
505 Inherited::onCreate(source);
507 if(source != NULL)
509 AnimMatrixBlender *pThis = static_cast<AnimMatrixBlender *>(this);
511 MFUnrecAnimMatrixChannelPtr::const_iterator ChannelsIt =
512 source->_mfChannels.begin();
513 MFUnrecAnimMatrixChannelPtr::const_iterator ChannelsEnd =
514 source->_mfChannels.end ();
516 while(ChannelsIt != ChannelsEnd)
518 pThis->pushToChannels(*ChannelsIt);
520 ++ChannelsIt;
525 GetFieldHandlePtr AnimMatrixBlenderBase::getHandleChannels (void) const
527 MFUnrecAnimMatrixChannelPtr::GetHandlePtr returnValue(
528 new MFUnrecAnimMatrixChannelPtr::GetHandle(
529 &_mfChannels,
530 this->getType().getFieldDesc(ChannelsFieldId),
531 const_cast<AnimMatrixBlenderBase *>(this)));
533 return returnValue;
536 EditFieldHandlePtr AnimMatrixBlenderBase::editHandleChannels (void)
538 MFUnrecAnimMatrixChannelPtr::EditHandlePtr returnValue(
539 new MFUnrecAnimMatrixChannelPtr::EditHandle(
540 &_mfChannels,
541 this->getType().getFieldDesc(ChannelsFieldId),
542 this));
544 returnValue->setAddMethod(
545 boost::bind(&AnimMatrixBlender::pushToChannels,
546 static_cast<AnimMatrixBlender *>(this), _1));
547 returnValue->setRemoveMethod(
548 boost::bind(&AnimMatrixBlender::removeFromChannels,
549 static_cast<AnimMatrixBlender *>(this), _1));
550 returnValue->setRemoveObjMethod(
551 boost::bind(&AnimMatrixBlender::removeObjFromChannels,
552 static_cast<AnimMatrixBlender *>(this), _1));
553 returnValue->setClearMethod(
554 boost::bind(&AnimMatrixBlender::clearChannels,
555 static_cast<AnimMatrixBlender *>(this)));
557 editMField(ChannelsFieldMask, _mfChannels);
559 return returnValue;
562 GetFieldHandlePtr AnimMatrixBlenderBase::getHandleOutValue (void) const
564 SFMatrix::GetHandlePtr returnValue(
565 new SFMatrix::GetHandle(
566 &_sfOutValue,
567 this->getType().getFieldDesc(OutValueFieldId),
568 const_cast<AnimMatrixBlenderBase *>(this)));
570 return returnValue;
573 EditFieldHandlePtr AnimMatrixBlenderBase::editHandleOutValue (void)
575 SFMatrix::EditHandlePtr returnValue(
576 new SFMatrix::EditHandle(
577 &_sfOutValue,
578 this->getType().getFieldDesc(OutValueFieldId),
579 this));
582 editSField(OutValueFieldMask);
584 return returnValue;
588 #ifdef OSG_MT_CPTR_ASPECT
589 void AnimMatrixBlenderBase::execSyncV( FieldContainer &oFrom,
590 ConstFieldMaskArg whichField,
591 AspectOffsetStore &oOffsets,
592 ConstFieldMaskArg syncMode,
593 const UInt32 uiSyncInfo)
595 AnimMatrixBlender *pThis = static_cast<AnimMatrixBlender *>(this);
597 pThis->execSync(static_cast<AnimMatrixBlender *>(&oFrom),
598 whichField,
599 oOffsets,
600 syncMode,
601 uiSyncInfo);
603 #endif
606 #ifdef OSG_MT_CPTR_ASPECT
607 FieldContainer *AnimMatrixBlenderBase::createAspectCopy(
608 const FieldContainer *pRefAspect) const
610 AnimMatrixBlender *returnValue;
612 newAspectCopy(returnValue,
613 dynamic_cast<const AnimMatrixBlender *>(pRefAspect),
614 dynamic_cast<const AnimMatrixBlender *>(this));
616 return returnValue;
618 #endif
620 void AnimMatrixBlenderBase::resolveLinks(void)
622 Inherited::resolveLinks();
624 static_cast<AnimMatrixBlender *>(this)->clearChannels();
630 OSG_END_NAMESPACE