1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
65 #include "OSGNodeCore.h" // Cores Class
67 #include "OSGMultiCoreBase.h"
68 #include "OSGMultiCore.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::MultiCore
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var NodeCore * MultiCoreBase::_mfCores
90 /*! \var bool MultiCoreBase::_sfExitOnSkip
95 /***************************************************************************\
96 * FieldType/FieldTrait Instantiation *
97 \***************************************************************************/
99 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
100 PointerType FieldTraits
<MultiCore
*, nsOSG
>::_type(
103 MultiCore::getClassType(),
107 OSG_FIELDTRAITS_GETTYPE_NS(MultiCore
*, nsOSG
)
109 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
113 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
117 /***************************************************************************\
118 * Field Description *
119 \***************************************************************************/
121 void MultiCoreBase::classDescInserter(TypeObject
&oType
)
123 FieldDescriptionBase
*pDesc
= NULL
;
126 pDesc
= new MFUnrecChildNodeCorePtr::Description(
127 MFUnrecChildNodeCorePtr::getClassType(),
130 CoresFieldId
, CoresFieldMask
,
132 (Field::MFDefaultFlags
| Field::FStdAccess
),
133 static_cast<FieldEditMethodSig
>(&MultiCore::editHandleCores
),
134 static_cast<FieldGetMethodSig
>(&MultiCore::getHandleCores
));
136 oType
.addInitialDesc(pDesc
);
138 pDesc
= new SFBool::Description(
139 SFBool::getClassType(),
142 ExitOnSkipFieldId
, ExitOnSkipFieldMask
,
144 (Field::SFDefaultFlags
| Field::FStdAccess
),
145 static_cast<FieldEditMethodSig
>(&MultiCore::editHandleExitOnSkip
),
146 static_cast<FieldGetMethodSig
>(&MultiCore::getHandleExitOnSkip
));
148 oType
.addInitialDesc(pDesc
);
152 MultiCoreBase::TypeObject
MultiCoreBase::_type(
153 MultiCoreBase::getClassname(),
154 Inherited::getClassname(),
157 reinterpret_cast<PrototypeCreateF
>(&MultiCoreBase::createEmptyLocal
),
158 reinterpret_cast<InitContainerF
>(&MultiCore::initMethod
),
159 reinterpret_cast<ExitContainerF
>(&MultiCore::exitMethod
),
160 reinterpret_cast<InitalInsertDescFunc
>(
161 reinterpret_cast<void *>(&MultiCore::classDescInserter
)),
164 "<?xml version=\"1.0\" ?>\n"
167 " name=\"MultiCore\"\n"
168 " parent=\"Group\"\n"
169 " library=\"System\"\n"
170 " structure=\"concrete\"\n"
171 " pointerfieldtypes=\"both\"\n"
172 " systemcomponent=\"true\"\n"
173 " parentsystemcomponent=\"true\"\n"
174 " docGroupBase=\"GrpSystemNodeCoreGroups\"\n"
178 " type=\"NodeCore\"\n"
179 " cardinality=\"multi\"\n"
180 " visibility=\"external\"\n"
181 " access=\"protected\"\n"
182 " category=\"childpointer\"\n"
183 " childParentType=\"FieldContainer\"\n"
184 " linkParentField=\"Parents\"\n"
186 " pushToFieldAs=\"addCore\"\n"
187 " assignMFieldAs=\"assignCoresFrom\"\n"
188 " insertIntoMFieldAs=\"insertCore\"\n"
189 " replaceInMFieldIndexAs=\"replaceCore\"\n"
190 " replaceInMFieldObjectAs=\"replaceCoreByObj\"\n"
191 " removeFromMFieldIndexAs=\"subCore\"\n"
192 " removeFromMFieldObjectAs=\"subCoreByObj\"\n"
193 " clearFieldAs=\"clearCores\"\n"
198 " name=\"exitOnSkip\"\n"
200 " cardinality=\"single\"\n"
201 " visibility=\"external\"\n"
202 " defaultValue=\"false\">\n"
204 "</FieldContainer>\n",
208 /*------------------------------ get -----------------------------------*/
210 FieldContainerType
&MultiCoreBase::getType(void)
215 const FieldContainerType
&MultiCoreBase::getType(void) const
220 UInt32
MultiCoreBase::getContainerSize(void) const
222 return sizeof(MultiCore
);
225 /*------------------------- decorator get ------------------------------*/
228 //! Get the MultiCore::_mfCores field.
229 const MFUnrecChildNodeCorePtr
*MultiCoreBase::getMFCores(void) const
234 MFUnrecChildNodeCorePtr
*MultiCoreBase::editMFCores (void)
236 editMField(CoresFieldMask
, _mfCores
);
240 NodeCore
* MultiCoreBase::getCores(const UInt32 index
) const
242 return _mfCores
[index
];
245 SFBool
*MultiCoreBase::editSFExitOnSkip(void)
247 editSField(ExitOnSkipFieldMask
);
249 return &_sfExitOnSkip
;
252 const SFBool
*MultiCoreBase::getSFExitOnSkip(void) const
254 return &_sfExitOnSkip
;
260 void MultiCoreBase::addCore(NodeCore
* const value
)
262 editMField(CoresFieldMask
, _mfCores
);
264 _mfCores
.push_back(value
);
267 void MultiCoreBase::assignCoresFrom(const MFUnrecChildNodeCorePtr
&value
)
269 MFUnrecChildNodeCorePtr::const_iterator elemIt
=
271 MFUnrecChildNodeCorePtr::const_iterator elemEnd
=
274 static_cast<MultiCore
*>(this)->clearCores();
276 while(elemIt
!= elemEnd
)
278 this->addCore(*elemIt
);
284 void MultiCoreBase::subCore(UInt32 uiIndex
)
286 if(uiIndex
< _mfCores
.size())
288 editMField(CoresFieldMask
, _mfCores
);
290 _mfCores
.erase(uiIndex
);
294 void MultiCoreBase::subCoreByObj(NodeCore
* const value
)
296 Int32 iElemIdx
= _mfCores
.findIndex(value
);
300 editMField(CoresFieldMask
, _mfCores
);
302 _mfCores
.erase(iElemIdx
);
305 void MultiCoreBase::clearCores(void)
307 editMField(CoresFieldMask
, _mfCores
);
315 /*------------------------------ access -----------------------------------*/
317 SizeT
MultiCoreBase::getBinSize(ConstFieldMaskArg whichField
)
319 SizeT returnValue
= Inherited::getBinSize(whichField
);
321 if(FieldBits::NoField
!= (CoresFieldMask
& whichField
))
323 returnValue
+= _mfCores
.getBinSize();
325 if(FieldBits::NoField
!= (ExitOnSkipFieldMask
& whichField
))
327 returnValue
+= _sfExitOnSkip
.getBinSize();
333 void MultiCoreBase::copyToBin(BinaryDataHandler
&pMem
,
334 ConstFieldMaskArg whichField
)
336 Inherited::copyToBin(pMem
, whichField
);
338 if(FieldBits::NoField
!= (CoresFieldMask
& whichField
))
340 _mfCores
.copyToBin(pMem
);
342 if(FieldBits::NoField
!= (ExitOnSkipFieldMask
& whichField
))
344 _sfExitOnSkip
.copyToBin(pMem
);
348 void MultiCoreBase::copyFromBin(BinaryDataHandler
&pMem
,
349 ConstFieldMaskArg whichField
)
351 Inherited::copyFromBin(pMem
, whichField
);
353 if(FieldBits::NoField
!= (CoresFieldMask
& whichField
))
355 editMField(CoresFieldMask
, _mfCores
);
356 _mfCores
.copyFromBin(pMem
);
358 if(FieldBits::NoField
!= (ExitOnSkipFieldMask
& whichField
))
360 editSField(ExitOnSkipFieldMask
);
361 _sfExitOnSkip
.copyFromBin(pMem
);
365 //! create a new instance of the class
366 MultiCoreTransitPtr
MultiCoreBase::createLocal(BitVector bFlags
)
368 MultiCoreTransitPtr fc
;
370 if(getClassType().getPrototype() != NULL
)
372 FieldContainerTransitPtr tmpPtr
=
373 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
375 fc
= dynamic_pointer_cast
<MultiCore
>(tmpPtr
);
381 //! create a new instance of the class, copy the container flags
382 MultiCoreTransitPtr
MultiCoreBase::createDependent(BitVector bFlags
)
384 MultiCoreTransitPtr fc
;
386 if(getClassType().getPrototype() != NULL
)
388 FieldContainerTransitPtr tmpPtr
=
389 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
391 fc
= dynamic_pointer_cast
<MultiCore
>(tmpPtr
);
397 //! create a new instance of the class
398 MultiCoreTransitPtr
MultiCoreBase::create(void)
400 MultiCoreTransitPtr fc
;
402 if(getClassType().getPrototype() != NULL
)
404 FieldContainerTransitPtr tmpPtr
=
405 getClassType().getPrototype()-> shallowCopy();
407 fc
= dynamic_pointer_cast
<MultiCore
>(tmpPtr
);
413 MultiCore
*MultiCoreBase::createEmptyLocal(BitVector bFlags
)
415 MultiCore
*returnValue
;
417 newPtr
<MultiCore
>(returnValue
, bFlags
);
419 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
424 //! create an empty new instance of the class, do not copy the prototype
425 MultiCore
*MultiCoreBase::createEmpty(void)
427 MultiCore
*returnValue
;
429 newPtr
<MultiCore
>(returnValue
, Thread::getCurrentLocalFlags());
431 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
432 ~Thread::getCurrentLocalFlags();
438 FieldContainerTransitPtr
MultiCoreBase::shallowCopyLocal(
439 BitVector bFlags
) const
443 newPtr(tmpPtr
, dynamic_cast<const MultiCore
*>(this), bFlags
);
445 FieldContainerTransitPtr
returnValue(tmpPtr
);
447 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
452 FieldContainerTransitPtr
MultiCoreBase::shallowCopyDependent(
453 BitVector bFlags
) const
457 newPtr(tmpPtr
, dynamic_cast<const MultiCore
*>(this), ~bFlags
);
459 FieldContainerTransitPtr
returnValue(tmpPtr
);
461 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
466 FieldContainerTransitPtr
MultiCoreBase::shallowCopy(void) const
471 dynamic_cast<const MultiCore
*>(this),
472 Thread::getCurrentLocalFlags());
474 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
476 FieldContainerTransitPtr
returnValue(tmpPtr
);
484 /*------------------------- constructors ----------------------------------*/
486 MultiCoreBase::MultiCoreBase(void) :
490 NodeCore::ParentsFieldId
),
491 _sfExitOnSkip (bool(false))
495 MultiCoreBase::MultiCoreBase(const MultiCoreBase
&source
) :
499 NodeCore::ParentsFieldId
),
500 _sfExitOnSkip (source
._sfExitOnSkip
)
505 /*-------------------------- destructors ----------------------------------*/
507 MultiCoreBase::~MultiCoreBase(void)
511 /*-------------------------------------------------------------------------*/
514 bool MultiCoreBase::unlinkChild(
515 FieldContainer
* const pChild
,
516 UInt16
const childFieldId
)
518 if(childFieldId
== CoresFieldId
)
520 NodeCore
* pTypedChild
=
521 dynamic_cast<NodeCore
*>(pChild
);
523 if(pTypedChild
!= NULL
)
525 Int32 iChildIdx
= _mfCores
.findIndex(pTypedChild
);
529 editMField(CoresFieldMask
, _mfCores
);
531 _mfCores
.erase(iChildIdx
);
536 SWARNING
<< "Parent ([" << this
537 << "] id [" << this->getId()
538 << "] type [" << this->getType().getCName()
539 << "] childFieldId [" << childFieldId
540 << "]) - Child ([" << pChild
541 << "] id [" << pChild
->getId()
542 << "] type [" << pChild
->getType().getCName()
543 << "]): link inconsistent!"
553 return Inherited::unlinkChild(pChild
, childFieldId
);
556 void MultiCoreBase::onCreate(const MultiCore
*source
)
558 Inherited::onCreate(source
);
562 MultiCore
*pThis
= static_cast<MultiCore
*>(this);
564 MFUnrecChildNodeCorePtr::const_iterator CoresIt
=
565 source
->_mfCores
.begin();
566 MFUnrecChildNodeCorePtr::const_iterator CoresEnd
=
567 source
->_mfCores
.end ();
569 while(CoresIt
!= CoresEnd
)
571 pThis
->addCore(*CoresIt
);
578 GetFieldHandlePtr
MultiCoreBase::getHandleCores (void) const
580 MFUnrecChildNodeCorePtr::GetHandlePtr
returnValue(
581 new MFUnrecChildNodeCorePtr::GetHandle(
583 this->getType().getFieldDesc(CoresFieldId
),
584 const_cast<MultiCoreBase
*>(this)));
589 EditFieldHandlePtr
MultiCoreBase::editHandleCores (void)
591 MFUnrecChildNodeCorePtr::EditHandlePtr
returnValue(
592 new MFUnrecChildNodeCorePtr::EditHandle(
594 this->getType().getFieldDesc(CoresFieldId
),
597 returnValue
->setAddMethod(
598 boost::bind(&MultiCore::addCore
,
599 static_cast<MultiCore
*>(this), _1
));
600 returnValue
->setRemoveMethod(
601 boost::bind(&MultiCore::subCore
,
602 static_cast<MultiCore
*>(this), _1
));
603 returnValue
->setRemoveObjMethod(
604 boost::bind(&MultiCore::subCoreByObj
,
605 static_cast<MultiCore
*>(this), _1
));
606 returnValue
->setClearMethod(
607 boost::bind(&MultiCore::clearCores
,
608 static_cast<MultiCore
*>(this)));
610 editMField(CoresFieldMask
, _mfCores
);
615 GetFieldHandlePtr
MultiCoreBase::getHandleExitOnSkip (void) const
617 SFBool::GetHandlePtr
returnValue(
618 new SFBool::GetHandle(
620 this->getType().getFieldDesc(ExitOnSkipFieldId
),
621 const_cast<MultiCoreBase
*>(this)));
626 EditFieldHandlePtr
MultiCoreBase::editHandleExitOnSkip (void)
628 SFBool::EditHandlePtr
returnValue(
629 new SFBool::EditHandle(
631 this->getType().getFieldDesc(ExitOnSkipFieldId
),
635 editSField(ExitOnSkipFieldMask
);
641 #ifdef OSG_MT_CPTR_ASPECT
642 void MultiCoreBase::execSyncV( FieldContainer
&oFrom
,
643 ConstFieldMaskArg whichField
,
644 AspectOffsetStore
&oOffsets
,
645 ConstFieldMaskArg syncMode
,
646 const UInt32 uiSyncInfo
)
648 MultiCore
*pThis
= static_cast<MultiCore
*>(this);
650 pThis
->execSync(static_cast<MultiCore
*>(&oFrom
),
659 #ifdef OSG_MT_CPTR_ASPECT
660 FieldContainer
*MultiCoreBase::createAspectCopy(
661 const FieldContainer
*pRefAspect
) const
663 MultiCore
*returnValue
;
665 newAspectCopy(returnValue
,
666 dynamic_cast<const MultiCore
*>(pRefAspect
),
667 dynamic_cast<const MultiCore
*>(this));
673 void MultiCoreBase::resolveLinks(void)
675 Inherited::resolveLinks();
677 static_cast<MultiCore
*>(this)->clearCores();