fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Misc / OSGStackedTransformBase.cpp
blob073c484b00622cc47919432bd9fe7bef37094594
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 StackedTransform!
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 "OSGTransformationElement.h" // TransformElements Class
67 #include "OSGStackedTransformBase.h"
68 #include "OSGStackedTransform.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::StackedTransform
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var TransformationElement * StackedTransformBase::_mfTransformElements
91 /***************************************************************************\
92 * FieldType/FieldTrait Instantiation *
93 \***************************************************************************/
95 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
96 PointerType FieldTraits<StackedTransform *, nsOSG>::_type(
97 "StackedTransformPtr",
98 "GroupPtr",
99 StackedTransform::getClassType(),
100 nsOSG);
101 #endif
103 OSG_FIELDTRAITS_GETTYPE_NS(StackedTransform *, nsOSG)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
106 StackedTransform *,
107 nsOSG)
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
110 StackedTransform *,
111 nsOSG)
113 /***************************************************************************\
114 * Field Description *
115 \***************************************************************************/
117 void StackedTransformBase::classDescInserter(TypeObject &oType)
119 FieldDescriptionBase *pDesc = NULL;
122 pDesc = new MFUnrecChildTransformationElementPtr::Description(
123 MFUnrecChildTransformationElementPtr::getClassType(),
124 "TransformElements",
126 TransformElementsFieldId, TransformElementsFieldMask,
127 false,
128 (Field::MFDefaultFlags | Field::FNullCheckAccess),
129 static_cast<FieldEditMethodSig>(&StackedTransform::editHandleTransformElements),
130 static_cast<FieldGetMethodSig >(&StackedTransform::getHandleTransformElements));
132 oType.addInitialDesc(pDesc);
136 StackedTransformBase::TypeObject StackedTransformBase::_type(
137 StackedTransformBase::getClassname(),
138 Inherited::getClassname(),
139 "NULL",
140 nsOSG, //Namespace
141 reinterpret_cast<PrototypeCreateF>(&StackedTransformBase::createEmptyLocal),
142 reinterpret_cast<InitContainerF>(&StackedTransform::initMethod),
143 reinterpret_cast<ExitContainerF>(&StackedTransform::exitMethod),
144 reinterpret_cast<InitalInsertDescFunc>(
145 reinterpret_cast<void *>(&StackedTransform::classDescInserter)),
146 false,
148 "<?xml version=\"1.0\" ?>\n"
149 "\n"
150 "<FieldContainer\n"
151 " name=\"StackedTransform\"\n"
152 " parent=\"Group\"\n"
153 " library=\"Group\"\n"
154 " structure=\"concrete\"\n"
155 " pointerfieldtypes=\"both\"\n"
156 " systemcomponent=\"true\"\n"
157 " parentsystemcomponent=\"true\"\n"
158 " isNodeCore=\"true\"\n"
159 " >\n"
160 " <Field\n"
161 " name=\"TransformElements\"\n"
162 " type=\"TransformationElement\"\n"
163 " category=\"childpointer\"\n"
164 " cardinality=\"multi\"\n"
165 " childParentType=\"FieldContainer\"\n"
166 " visibility=\"external\"\n"
167 " access=\"public\"\n"
168 " ptrFieldAccess = \"nullCheck\"\n"
169 " linkParentField=\"ParentStack\"\n"
170 " >\n"
171 " </Field>\n"
172 "</FieldContainer>\n",
176 /*------------------------------ get -----------------------------------*/
178 FieldContainerType &StackedTransformBase::getType(void)
180 return _type;
183 const FieldContainerType &StackedTransformBase::getType(void) const
185 return _type;
188 UInt32 StackedTransformBase::getContainerSize(void) const
190 return sizeof(StackedTransform);
193 /*------------------------- decorator get ------------------------------*/
196 //! Get the StackedTransform::_mfTransformElements field.
197 const MFUnrecChildTransformationElementPtr *StackedTransformBase::getMFTransformElements(void) const
199 return &_mfTransformElements;
201 TransformationElement * StackedTransformBase::getTransformElements(const UInt32 index) const
203 return _mfTransformElements[index];
208 void StackedTransformBase::pushToTransformElements(TransformationElement * const value)
210 if(value == NULL)
211 return;
213 editMField(TransformElementsFieldMask, _mfTransformElements);
215 _mfTransformElements.push_back(value);
218 void StackedTransformBase::assignTransformElements(const MFUnrecChildTransformationElementPtr &value)
220 MFUnrecChildTransformationElementPtr::const_iterator elemIt =
221 value.begin();
222 MFUnrecChildTransformationElementPtr::const_iterator elemEnd =
223 value.end ();
225 static_cast<StackedTransform *>(this)->clearTransformElements();
227 while(elemIt != elemEnd)
229 this->pushToTransformElements(*elemIt);
231 ++elemIt;
235 void StackedTransformBase::insertIntoTransformElements(UInt32 uiIndex,
236 TransformationElement * const value )
238 if(value == NULL)
239 return;
241 editMField(TransformElementsFieldMask, _mfTransformElements);
243 MFUnrecChildTransformationElementPtr::iterator fieldIt = _mfTransformElements.begin_nc();
245 fieldIt += uiIndex;
247 _mfTransformElements.insert(fieldIt, value);
250 void StackedTransformBase::replaceInTransformElements(UInt32 uiIndex,
251 TransformationElement * const value )
253 if(value == NULL)
254 return;
256 if(uiIndex >= _mfTransformElements.size())
257 return;
259 editMField(TransformElementsFieldMask, _mfTransformElements);
261 _mfTransformElements.replace(uiIndex, value);
264 void StackedTransformBase::replaceObjInTransformElements(TransformationElement * const pOldElem,
265 TransformationElement * const pNewElem)
267 if(pNewElem == NULL)
268 return;
270 Int32 elemIdx = _mfTransformElements.findIndex(pOldElem);
272 if(elemIdx != -1)
274 editMField(TransformElementsFieldMask, _mfTransformElements);
276 _mfTransformElements.replace(elemIdx, pNewElem);
280 void StackedTransformBase::removeFromTransformElements(UInt32 uiIndex)
282 if(uiIndex < _mfTransformElements.size())
284 editMField(TransformElementsFieldMask, _mfTransformElements);
286 _mfTransformElements.erase(uiIndex);
290 void StackedTransformBase::removeObjFromTransformElements(TransformationElement * const value)
292 Int32 iElemIdx = _mfTransformElements.findIndex(value);
294 if(iElemIdx != -1)
296 editMField(TransformElementsFieldMask, _mfTransformElements);
298 _mfTransformElements.erase(iElemIdx);
301 void StackedTransformBase::clearTransformElements(void)
303 editMField(TransformElementsFieldMask, _mfTransformElements);
306 _mfTransformElements.clear();
311 /*------------------------------ access -----------------------------------*/
313 SizeT StackedTransformBase::getBinSize(ConstFieldMaskArg whichField)
315 SizeT returnValue = Inherited::getBinSize(whichField);
317 if(FieldBits::NoField != (TransformElementsFieldMask & whichField))
319 returnValue += _mfTransformElements.getBinSize();
322 return returnValue;
325 void StackedTransformBase::copyToBin(BinaryDataHandler &pMem,
326 ConstFieldMaskArg whichField)
328 Inherited::copyToBin(pMem, whichField);
330 if(FieldBits::NoField != (TransformElementsFieldMask & whichField))
332 _mfTransformElements.copyToBin(pMem);
336 void StackedTransformBase::copyFromBin(BinaryDataHandler &pMem,
337 ConstFieldMaskArg whichField)
339 Inherited::copyFromBin(pMem, whichField);
341 if(FieldBits::NoField != (TransformElementsFieldMask & whichField))
343 editMField(TransformElementsFieldMask, _mfTransformElements);
344 _mfTransformElements.copyFromBin(pMem);
348 //! create a new instance of the class
349 StackedTransformTransitPtr StackedTransformBase::createLocal(BitVector bFlags)
351 StackedTransformTransitPtr fc;
353 if(getClassType().getPrototype() != NULL)
355 FieldContainerTransitPtr tmpPtr =
356 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
358 fc = dynamic_pointer_cast<StackedTransform>(tmpPtr);
361 return fc;
364 //! create a new instance of the class, copy the container flags
365 StackedTransformTransitPtr StackedTransformBase::createDependent(BitVector bFlags)
367 StackedTransformTransitPtr fc;
369 if(getClassType().getPrototype() != NULL)
371 FieldContainerTransitPtr tmpPtr =
372 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
374 fc = dynamic_pointer_cast<StackedTransform>(tmpPtr);
377 return fc;
380 //! create a new instance of the class
381 StackedTransformTransitPtr StackedTransformBase::create(void)
383 StackedTransformTransitPtr fc;
385 if(getClassType().getPrototype() != NULL)
387 FieldContainerTransitPtr tmpPtr =
388 getClassType().getPrototype()-> shallowCopy();
390 fc = dynamic_pointer_cast<StackedTransform>(tmpPtr);
393 return fc;
396 StackedTransform *StackedTransformBase::createEmptyLocal(BitVector bFlags)
398 StackedTransform *returnValue;
400 newPtr<StackedTransform>(returnValue, bFlags);
402 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
404 return returnValue;
407 //! create an empty new instance of the class, do not copy the prototype
408 StackedTransform *StackedTransformBase::createEmpty(void)
410 StackedTransform *returnValue;
412 newPtr<StackedTransform>(returnValue, Thread::getCurrentLocalFlags());
414 returnValue->_pFieldFlags->_bNamespaceMask &=
415 ~Thread::getCurrentLocalFlags();
417 return returnValue;
421 FieldContainerTransitPtr StackedTransformBase::shallowCopyLocal(
422 BitVector bFlags) const
424 StackedTransform *tmpPtr;
426 newPtr(tmpPtr, dynamic_cast<const StackedTransform *>(this), bFlags);
428 FieldContainerTransitPtr returnValue(tmpPtr);
430 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
432 return returnValue;
435 FieldContainerTransitPtr StackedTransformBase::shallowCopyDependent(
436 BitVector bFlags) const
438 StackedTransform *tmpPtr;
440 newPtr(tmpPtr, dynamic_cast<const StackedTransform *>(this), ~bFlags);
442 FieldContainerTransitPtr returnValue(tmpPtr);
444 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
446 return returnValue;
449 FieldContainerTransitPtr StackedTransformBase::shallowCopy(void) const
451 StackedTransform *tmpPtr;
453 newPtr(tmpPtr,
454 dynamic_cast<const StackedTransform *>(this),
455 Thread::getCurrentLocalFlags());
457 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
459 FieldContainerTransitPtr returnValue(tmpPtr);
461 return returnValue;
467 /*------------------------- constructors ----------------------------------*/
469 StackedTransformBase::StackedTransformBase(void) :
470 Inherited(),
471 _mfTransformElements (this,
472 TransformElementsFieldId,
473 TransformationElement::ParentStackFieldId)
477 StackedTransformBase::StackedTransformBase(const StackedTransformBase &source) :
478 Inherited(source),
479 _mfTransformElements (this,
480 TransformElementsFieldId,
481 TransformationElement::ParentStackFieldId)
486 /*-------------------------- destructors ----------------------------------*/
488 StackedTransformBase::~StackedTransformBase(void)
492 /*-------------------------------------------------------------------------*/
493 /* Child linking */
495 bool StackedTransformBase::unlinkChild(
496 FieldContainer * const pChild,
497 UInt16 const childFieldId)
499 if(childFieldId == TransformElementsFieldId)
501 TransformationElement * pTypedChild =
502 dynamic_cast<TransformationElement *>(pChild);
504 if(pTypedChild != NULL)
506 Int32 iChildIdx = _mfTransformElements.findIndex(pTypedChild);
508 if(iChildIdx != -1)
510 editMField(TransformElementsFieldMask, _mfTransformElements);
512 _mfTransformElements.erase(iChildIdx);
514 return true;
517 SWARNING << "Parent ([" << this
518 << "] id [" << this->getId()
519 << "] type [" << this->getType().getCName()
520 << "] childFieldId [" << childFieldId
521 << "]) - Child ([" << pChild
522 << "] id [" << pChild->getId()
523 << "] type [" << pChild->getType().getCName()
524 << "]): link inconsistent!"
525 << std::endl;
527 return false;
530 return false;
534 return Inherited::unlinkChild(pChild, childFieldId);
537 void StackedTransformBase::onCreate(const StackedTransform *source)
539 Inherited::onCreate(source);
541 if(source != NULL)
543 StackedTransform *pThis = static_cast<StackedTransform *>(this);
545 MFUnrecChildTransformationElementPtr::const_iterator TransformElementsIt =
546 source->_mfTransformElements.begin();
547 MFUnrecChildTransformationElementPtr::const_iterator TransformElementsEnd =
548 source->_mfTransformElements.end ();
550 while(TransformElementsIt != TransformElementsEnd)
552 pThis->pushToTransformElements(*TransformElementsIt);
554 ++TransformElementsIt;
559 GetFieldHandlePtr StackedTransformBase::getHandleTransformElements (void) const
561 MFUnrecChildTransformationElementPtr::GetHandlePtr returnValue(
562 new MFUnrecChildTransformationElementPtr::GetHandle(
563 &_mfTransformElements,
564 this->getType().getFieldDesc(TransformElementsFieldId),
565 const_cast<StackedTransformBase *>(this)));
567 return returnValue;
570 EditFieldHandlePtr StackedTransformBase::editHandleTransformElements(void)
572 MFUnrecChildTransformationElementPtr::EditHandlePtr returnValue(
573 new MFUnrecChildTransformationElementPtr::EditHandle(
574 &_mfTransformElements,
575 this->getType().getFieldDesc(TransformElementsFieldId),
576 this));
578 returnValue->setAddMethod(
579 boost::bind(&StackedTransform::pushToTransformElements,
580 static_cast<StackedTransform *>(this), _1));
581 returnValue->setInsertMethod(
582 boost::bind(&StackedTransform::insertIntoTransformElements,
583 static_cast<StackedTransform *>(this), _1, _2));
584 returnValue->setReplaceMethod(
585 boost::bind(&StackedTransform::replaceInTransformElements,
586 static_cast<StackedTransform *>(this), _1, _2));
587 returnValue->setReplaceObjMethod(
588 boost::bind(&StackedTransform::replaceObjInTransformElements,
589 static_cast<StackedTransform *>(this), _1, _2));
590 returnValue->setRemoveMethod(
591 boost::bind(&StackedTransform::removeFromTransformElements,
592 static_cast<StackedTransform *>(this), _1));
593 returnValue->setRemoveObjMethod(
594 boost::bind(&StackedTransform::removeObjFromTransformElements,
595 static_cast<StackedTransform *>(this), _1));
596 returnValue->setClearMethod(
597 boost::bind(&StackedTransform::clearTransformElements,
598 static_cast<StackedTransform *>(this)));
600 editMField(TransformElementsFieldMask, _mfTransformElements);
602 return returnValue;
606 #ifdef OSG_MT_CPTR_ASPECT
607 void StackedTransformBase::execSyncV( FieldContainer &oFrom,
608 ConstFieldMaskArg whichField,
609 AspectOffsetStore &oOffsets,
610 ConstFieldMaskArg syncMode,
611 const UInt32 uiSyncInfo)
613 StackedTransform *pThis = static_cast<StackedTransform *>(this);
615 pThis->execSync(static_cast<StackedTransform *>(&oFrom),
616 whichField,
617 oOffsets,
618 syncMode,
619 uiSyncInfo);
621 #endif
624 #ifdef OSG_MT_CPTR_ASPECT
625 FieldContainer *StackedTransformBase::createAspectCopy(
626 const FieldContainer *pRefAspect) const
628 StackedTransform *returnValue;
630 newAspectCopy(returnValue,
631 dynamic_cast<const StackedTransform *>(pRefAspect),
632 dynamic_cast<const StackedTransform *>(this));
634 return returnValue;
636 #endif
638 void StackedTransformBase::resolveLinks(void)
640 Inherited::resolveLinks();
642 static_cast<StackedTransform *>(this)->clearTransformElements();
648 OSG_END_NAMESPACE