fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Dynamics / Animation / OSGAnimTargetAttachmentBase.cpp
blob958e0049729389469ae9dbfa2ccd299a04207d05
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 AnimTargetAttachment!
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 "OSGAnimBlender.h" // Blenders Class
67 #include "OSGAnimTargetAttachmentBase.h"
68 #include "OSGAnimTargetAttachment.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::AnimTargetAttachment
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var std::string AnimTargetAttachmentBase::_sfTargetId
90 /*! \var AnimBlender * AnimTargetAttachmentBase::_mfBlenders
95 /***************************************************************************\
96 * FieldType/FieldTrait Instantiation *
97 \***************************************************************************/
99 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
100 PointerType FieldTraits<AnimTargetAttachment *, nsOSG>::_type(
101 "AnimTargetAttachmentPtr",
102 "AttachmentPtr",
103 AnimTargetAttachment::getClassType(),
104 nsOSG);
105 #endif
107 OSG_FIELDTRAITS_GETTYPE_NS(AnimTargetAttachment *, nsOSG)
109 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
110 AnimTargetAttachment *,
111 nsOSG)
113 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
114 AnimTargetAttachment *,
115 nsOSG)
117 /***************************************************************************\
118 * Field Description *
119 \***************************************************************************/
121 void AnimTargetAttachmentBase::classDescInserter(TypeObject &oType)
123 FieldDescriptionBase *pDesc = NULL;
126 pDesc = new SFString::Description(
127 SFString::getClassType(),
128 "targetId",
130 TargetIdFieldId, TargetIdFieldMask,
131 false,
132 (Field::FClusterLocal),
133 static_cast<FieldEditMethodSig>(&AnimTargetAttachment::editHandleTargetId),
134 static_cast<FieldGetMethodSig >(&AnimTargetAttachment::getHandleTargetId));
136 oType.addInitialDesc(pDesc);
138 pDesc = new MFUnrecAnimBlenderPtr::Description(
139 MFUnrecAnimBlenderPtr::getClassType(),
140 "blenders",
142 BlendersFieldId, BlendersFieldMask,
143 true,
144 (Field::FStdAccess | Field::FClusterLocal),
145 static_cast<FieldEditMethodSig>(&AnimTargetAttachment::editHandleBlenders),
146 static_cast<FieldGetMethodSig >(&AnimTargetAttachment::getHandleBlenders));
148 oType.addInitialDesc(pDesc);
152 AnimTargetAttachmentBase::TypeObject AnimTargetAttachmentBase::_type(
153 AnimTargetAttachmentBase::getClassname(),
154 Inherited::getClassname(),
155 "AnimTargetAttachment",
156 nsOSG, //Namespace
157 reinterpret_cast<PrototypeCreateF>(&AnimTargetAttachmentBase::createEmptyLocal),
158 reinterpret_cast<InitContainerF>(&AnimTargetAttachment::initMethod),
159 reinterpret_cast<ExitContainerF>(&AnimTargetAttachment::exitMethod),
160 reinterpret_cast<InitalInsertDescFunc>(
161 reinterpret_cast<void *>(&AnimTargetAttachment::classDescInserter)),
162 false,
164 "<?xml version=\"1.0\"?>\n"
165 "\n"
166 "<FieldContainer\n"
167 " name=\"AnimTargetAttachment\"\n"
168 " parent=\"Attachment\"\n"
169 " library=\"Dynamics\"\n"
170 " pointerfieldtypes=\"both\"\n"
171 " structure=\"concrete\"\n"
172 " systemcomponent=\"true\"\n"
173 " parentsystemcomponent=\"true\"\n"
174 ">\n"
175 " <Field\n"
176 " name=\"targetId\"\n"
177 " type=\"std::string\"\n"
178 " category=\"data\"\n"
179 " cardinality=\"single\"\n"
180 " visibility=\"external\"\n"
181 " access=\"public\"\n"
182 " defaultValue=\"\"\n"
183 " fieldFlags=\"FClusterLocal\"\n"
184 " >\n"
185 " </Field>\n"
186 " <Field\n"
187 " name=\"blenders\"\n"
188 " type=\"AnimBlender\"\n"
189 " category=\"pointer\"\n"
190 " cardinality=\"multi\"\n"
191 " visibility=\"internal\"\n"
192 " access=\"public\"\n"
193 " fieldFlags=\"FStdAccess, FClusterLocal\"\n"
194 " >\n"
195 " </Field>\n"
196 "</FieldContainer>\n",
200 /*------------------------------ get -----------------------------------*/
202 FieldContainerType &AnimTargetAttachmentBase::getType(void)
204 return _type;
207 const FieldContainerType &AnimTargetAttachmentBase::getType(void) const
209 return _type;
212 UInt32 AnimTargetAttachmentBase::getContainerSize(void) const
214 return sizeof(AnimTargetAttachment);
217 /*------------------------- decorator get ------------------------------*/
220 SFString *AnimTargetAttachmentBase::editSFTargetId(void)
222 editSField(TargetIdFieldMask);
224 return &_sfTargetId;
227 const SFString *AnimTargetAttachmentBase::getSFTargetId(void) const
229 return &_sfTargetId;
233 //! Get the AnimTargetAttachment::_mfBlenders field.
234 const MFUnrecAnimBlenderPtr *AnimTargetAttachmentBase::getMFBlenders(void) const
236 return &_mfBlenders;
239 MFUnrecAnimBlenderPtr *AnimTargetAttachmentBase::editMFBlenders (void)
241 editMField(BlendersFieldMask, _mfBlenders);
243 return &_mfBlenders;
245 AnimBlender * AnimTargetAttachmentBase::getBlenders(const UInt32 index) const
247 return _mfBlenders[index];
252 void AnimTargetAttachmentBase::pushToBlenders(AnimBlender * const value)
254 editMField(BlendersFieldMask, _mfBlenders);
256 _mfBlenders.push_back(value);
259 void AnimTargetAttachmentBase::assignBlenders (const MFUnrecAnimBlenderPtr &value)
261 MFUnrecAnimBlenderPtr::const_iterator elemIt =
262 value.begin();
263 MFUnrecAnimBlenderPtr::const_iterator elemEnd =
264 value.end ();
266 static_cast<AnimTargetAttachment *>(this)->clearBlenders();
268 while(elemIt != elemEnd)
270 this->pushToBlenders(*elemIt);
272 ++elemIt;
276 void AnimTargetAttachmentBase::removeFromBlenders(UInt32 uiIndex)
278 if(uiIndex < _mfBlenders.size())
280 editMField(BlendersFieldMask, _mfBlenders);
282 _mfBlenders.erase(uiIndex);
286 void AnimTargetAttachmentBase::removeObjFromBlenders(AnimBlender * const value)
288 Int32 iElemIdx = _mfBlenders.findIndex(value);
290 if(iElemIdx != -1)
292 editMField(BlendersFieldMask, _mfBlenders);
294 _mfBlenders.erase(iElemIdx);
297 void AnimTargetAttachmentBase::clearBlenders(void)
299 editMField(BlendersFieldMask, _mfBlenders);
302 _mfBlenders.clear();
307 /*------------------------------ access -----------------------------------*/
309 SizeT AnimTargetAttachmentBase::getBinSize(ConstFieldMaskArg whichField)
311 SizeT returnValue = Inherited::getBinSize(whichField);
313 if(FieldBits::NoField != (TargetIdFieldMask & whichField))
315 returnValue += _sfTargetId.getBinSize();
317 if(FieldBits::NoField != (BlendersFieldMask & whichField))
319 returnValue += _mfBlenders.getBinSize();
322 return returnValue;
325 void AnimTargetAttachmentBase::copyToBin(BinaryDataHandler &pMem,
326 ConstFieldMaskArg whichField)
328 Inherited::copyToBin(pMem, whichField);
330 if(FieldBits::NoField != (TargetIdFieldMask & whichField))
332 _sfTargetId.copyToBin(pMem);
334 if(FieldBits::NoField != (BlendersFieldMask & whichField))
336 _mfBlenders.copyToBin(pMem);
340 void AnimTargetAttachmentBase::copyFromBin(BinaryDataHandler &pMem,
341 ConstFieldMaskArg whichField)
343 Inherited::copyFromBin(pMem, whichField);
345 if(FieldBits::NoField != (TargetIdFieldMask & whichField))
347 editSField(TargetIdFieldMask);
348 _sfTargetId.copyFromBin(pMem);
350 if(FieldBits::NoField != (BlendersFieldMask & whichField))
352 editMField(BlendersFieldMask, _mfBlenders);
353 _mfBlenders.copyFromBin(pMem);
357 //! create a new instance of the class
358 AnimTargetAttachmentTransitPtr AnimTargetAttachmentBase::createLocal(BitVector bFlags)
360 AnimTargetAttachmentTransitPtr fc;
362 if(getClassType().getPrototype() != NULL)
364 FieldContainerTransitPtr tmpPtr =
365 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
367 fc = dynamic_pointer_cast<AnimTargetAttachment>(tmpPtr);
370 return fc;
373 //! create a new instance of the class, copy the container flags
374 AnimTargetAttachmentTransitPtr AnimTargetAttachmentBase::createDependent(BitVector bFlags)
376 AnimTargetAttachmentTransitPtr fc;
378 if(getClassType().getPrototype() != NULL)
380 FieldContainerTransitPtr tmpPtr =
381 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
383 fc = dynamic_pointer_cast<AnimTargetAttachment>(tmpPtr);
386 return fc;
389 //! create a new instance of the class
390 AnimTargetAttachmentTransitPtr AnimTargetAttachmentBase::create(void)
392 AnimTargetAttachmentTransitPtr fc;
394 if(getClassType().getPrototype() != NULL)
396 FieldContainerTransitPtr tmpPtr =
397 getClassType().getPrototype()-> shallowCopy();
399 fc = dynamic_pointer_cast<AnimTargetAttachment>(tmpPtr);
402 return fc;
405 AnimTargetAttachment *AnimTargetAttachmentBase::createEmptyLocal(BitVector bFlags)
407 AnimTargetAttachment *returnValue;
409 newPtr<AnimTargetAttachment>(returnValue, bFlags);
411 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
413 return returnValue;
416 //! create an empty new instance of the class, do not copy the prototype
417 AnimTargetAttachment *AnimTargetAttachmentBase::createEmpty(void)
419 AnimTargetAttachment *returnValue;
421 newPtr<AnimTargetAttachment>(returnValue, Thread::getCurrentLocalFlags());
423 returnValue->_pFieldFlags->_bNamespaceMask &=
424 ~Thread::getCurrentLocalFlags();
426 return returnValue;
430 FieldContainerTransitPtr AnimTargetAttachmentBase::shallowCopyLocal(
431 BitVector bFlags) const
433 AnimTargetAttachment *tmpPtr;
435 newPtr(tmpPtr, dynamic_cast<const AnimTargetAttachment *>(this), bFlags);
437 FieldContainerTransitPtr returnValue(tmpPtr);
439 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
441 return returnValue;
444 FieldContainerTransitPtr AnimTargetAttachmentBase::shallowCopyDependent(
445 BitVector bFlags) const
447 AnimTargetAttachment *tmpPtr;
449 newPtr(tmpPtr, dynamic_cast<const AnimTargetAttachment *>(this), ~bFlags);
451 FieldContainerTransitPtr returnValue(tmpPtr);
453 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
455 return returnValue;
458 FieldContainerTransitPtr AnimTargetAttachmentBase::shallowCopy(void) const
460 AnimTargetAttachment *tmpPtr;
462 newPtr(tmpPtr,
463 dynamic_cast<const AnimTargetAttachment *>(this),
464 Thread::getCurrentLocalFlags());
466 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
468 FieldContainerTransitPtr returnValue(tmpPtr);
470 return returnValue;
476 /*------------------------- constructors ----------------------------------*/
478 AnimTargetAttachmentBase::AnimTargetAttachmentBase(void) :
479 Inherited(),
480 _sfTargetId (),
481 _mfBlenders ()
485 AnimTargetAttachmentBase::AnimTargetAttachmentBase(const AnimTargetAttachmentBase &source) :
486 Inherited(source),
487 _sfTargetId (source._sfTargetId ),
488 _mfBlenders ()
493 /*-------------------------- destructors ----------------------------------*/
495 AnimTargetAttachmentBase::~AnimTargetAttachmentBase(void)
499 void AnimTargetAttachmentBase::onCreate(const AnimTargetAttachment *source)
501 Inherited::onCreate(source);
503 if(source != NULL)
505 AnimTargetAttachment *pThis = static_cast<AnimTargetAttachment *>(this);
507 MFUnrecAnimBlenderPtr::const_iterator BlendersIt =
508 source->_mfBlenders.begin();
509 MFUnrecAnimBlenderPtr::const_iterator BlendersEnd =
510 source->_mfBlenders.end ();
512 while(BlendersIt != BlendersEnd)
514 pThis->pushToBlenders(*BlendersIt);
516 ++BlendersIt;
521 GetFieldHandlePtr AnimTargetAttachmentBase::getHandleTargetId (void) const
523 SFString::GetHandlePtr returnValue(
524 new SFString::GetHandle(
525 &_sfTargetId,
526 this->getType().getFieldDesc(TargetIdFieldId),
527 const_cast<AnimTargetAttachmentBase *>(this)));
529 return returnValue;
532 EditFieldHandlePtr AnimTargetAttachmentBase::editHandleTargetId (void)
534 SFString::EditHandlePtr returnValue(
535 new SFString::EditHandle(
536 &_sfTargetId,
537 this->getType().getFieldDesc(TargetIdFieldId),
538 this));
541 editSField(TargetIdFieldMask);
543 return returnValue;
546 GetFieldHandlePtr AnimTargetAttachmentBase::getHandleBlenders (void) const
548 MFUnrecAnimBlenderPtr::GetHandlePtr returnValue(
549 new MFUnrecAnimBlenderPtr::GetHandle(
550 &_mfBlenders,
551 this->getType().getFieldDesc(BlendersFieldId),
552 const_cast<AnimTargetAttachmentBase *>(this)));
554 return returnValue;
557 EditFieldHandlePtr AnimTargetAttachmentBase::editHandleBlenders (void)
559 MFUnrecAnimBlenderPtr::EditHandlePtr returnValue(
560 new MFUnrecAnimBlenderPtr::EditHandle(
561 &_mfBlenders,
562 this->getType().getFieldDesc(BlendersFieldId),
563 this));
565 returnValue->setAddMethod(
566 boost::bind(&AnimTargetAttachment::pushToBlenders,
567 static_cast<AnimTargetAttachment *>(this), _1));
568 returnValue->setRemoveMethod(
569 boost::bind(&AnimTargetAttachment::removeFromBlenders,
570 static_cast<AnimTargetAttachment *>(this), _1));
571 returnValue->setRemoveObjMethod(
572 boost::bind(&AnimTargetAttachment::removeObjFromBlenders,
573 static_cast<AnimTargetAttachment *>(this), _1));
574 returnValue->setClearMethod(
575 boost::bind(&AnimTargetAttachment::clearBlenders,
576 static_cast<AnimTargetAttachment *>(this)));
578 editMField(BlendersFieldMask, _mfBlenders);
580 return returnValue;
584 #ifdef OSG_MT_CPTR_ASPECT
585 void AnimTargetAttachmentBase::execSyncV( FieldContainer &oFrom,
586 ConstFieldMaskArg whichField,
587 AspectOffsetStore &oOffsets,
588 ConstFieldMaskArg syncMode,
589 const UInt32 uiSyncInfo)
591 AnimTargetAttachment *pThis = static_cast<AnimTargetAttachment *>(this);
593 pThis->execSync(static_cast<AnimTargetAttachment *>(&oFrom),
594 whichField,
595 oOffsets,
596 syncMode,
597 uiSyncInfo);
599 #endif
602 #ifdef OSG_MT_CPTR_ASPECT
603 FieldContainer *AnimTargetAttachmentBase::createAspectCopy(
604 const FieldContainer *pRefAspect) const
606 AnimTargetAttachment *returnValue;
608 newAspectCopy(returnValue,
609 dynamic_cast<const AnimTargetAttachment *>(pRefAspect),
610 dynamic_cast<const AnimTargetAttachment *>(this));
612 return returnValue;
614 #endif
616 void AnimTargetAttachmentBase::resolveLinks(void)
618 Inherited::resolveLinks();
620 static_cast<AnimTargetAttachment *>(this)->clearBlenders();
626 OSG_END_NAMESPACE