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"
66 #include "OSGMultiSwitchBase.h"
67 #include "OSGMultiSwitch.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::MultiSwitch
78 MultiSwitch allows the selective inclusion of zero or more of its children
79 from traversal. It supports three different modes (selected by
80 _sfSwitchMode), to include either ALL, NONE or CHOICES of its children.
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var UInt32 MultiSwitchBase::_mfChoices
88 Indices of children to be included in CHOICES mode. The indices are kept
89 sorted and any duplicates are removed.
92 /*! \var Int32 MultiSwitchBase::_sfSwitchMode
97 /***************************************************************************\
98 * FieldType/FieldTrait Instantiation *
99 \***************************************************************************/
101 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
102 PointerType FieldTraits
<MultiSwitch
*, nsOSG
>::_type(
105 MultiSwitch::getClassType(),
109 OSG_FIELDTRAITS_GETTYPE_NS(MultiSwitch
*, nsOSG
)
111 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
115 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
119 /***************************************************************************\
120 * Field Description *
121 \***************************************************************************/
123 void MultiSwitchBase::classDescInserter(TypeObject
&oType
)
125 FieldDescriptionBase
*pDesc
= NULL
;
128 pDesc
= new MFUInt32::Description(
129 MFUInt32::getClassType(),
131 "Indices of children to be included in CHOICES mode. The indices are kept\n"
132 "sorted and any duplicates are removed.\n",
133 ChoicesFieldId
, ChoicesFieldMask
,
135 (Field::MFDefaultFlags
| Field::FStdAccess
),
136 static_cast<FieldEditMethodSig
>(&MultiSwitch::editHandleChoices
),
137 static_cast<FieldGetMethodSig
>(&MultiSwitch::getHandleChoices
));
139 oType
.addInitialDesc(pDesc
);
141 pDesc
= new SFInt32::Description(
142 SFInt32::getClassType(),
144 "Mode of operation.\n",
145 SwitchModeFieldId
, SwitchModeFieldMask
,
147 (Field::SFDefaultFlags
| Field::FStdAccess
),
148 static_cast<FieldEditMethodSig
>(&MultiSwitch::editHandleSwitchMode
),
149 static_cast<FieldGetMethodSig
>(&MultiSwitch::getHandleSwitchMode
));
151 oType
.addInitialDesc(pDesc
);
155 MultiSwitchBase::TypeObject
MultiSwitchBase::_type(
156 MultiSwitchBase::getClassname(),
157 Inherited::getClassname(),
160 reinterpret_cast<PrototypeCreateF
>(&MultiSwitchBase::createEmptyLocal
),
161 reinterpret_cast<InitContainerF
>(&MultiSwitch::initMethod
),
162 reinterpret_cast<ExitContainerF
>(&MultiSwitch::exitMethod
),
163 reinterpret_cast<InitalInsertDescFunc
>(
164 reinterpret_cast<void *>(&MultiSwitch::classDescInserter
)),
167 "<?xml version=\"1.0\"?>\n"
170 " name=\"MultiSwitch\"\n"
171 " parent=\"Group\"\n"
172 " library=\"Group\"\n"
173 " pointerfieldtypes=\"both\"\n"
174 " structure=\"concrete\"\n"
175 " systemcomponent=\"true\"\n"
176 " parentsystemcomponent=\"true\"\n"
177 " decoratable=\"false\"\n"
178 " docGroupBase=\"GrpGroupMisc\"\n"
180 " MultiSwitch allows the selective inclusion of zero or more of its children\n"
181 " from traversal. It supports three different modes (selected by\n"
182 " _sfSwitchMode), to include either ALL, NONE or CHOICES of its children.\n"
184 "\t name=\"choices\"\n"
185 "\t type=\"UInt32\"\n"
186 "\t cardinality=\"multi\"\n"
187 "\t visibility=\"external\"\n"
188 "\t access=\"public\"\n"
190 " Indices of children to be included in CHOICES mode. The indices are kept\n"
191 " sorted and any duplicates are removed.\n"
194 "\t name=\"switchMode\"\n"
195 "\t type=\"Int32\"\n"
196 "\t cardinality=\"single\"\n"
197 "\t visibility=\"external\"\n"
198 "\t defaultValue=\"-1\"\n"
199 "\t access=\"public\"\n"
201 " Mode of operation.\n"
203 "</FieldContainer>\n",
204 "MultiSwitch allows the selective inclusion of zero or more of its children\n"
205 "from traversal. It supports three different modes (selected by\n"
206 "_sfSwitchMode), to include either ALL, NONE or CHOICES of its children.\n"
209 /*------------------------------ get -----------------------------------*/
211 FieldContainerType
&MultiSwitchBase::getType(void)
216 const FieldContainerType
&MultiSwitchBase::getType(void) const
221 UInt32
MultiSwitchBase::getContainerSize(void) const
223 return sizeof(MultiSwitch
);
226 /*------------------------- decorator get ------------------------------*/
229 MFUInt32
*MultiSwitchBase::editMFChoices(void)
231 editMField(ChoicesFieldMask
, _mfChoices
);
236 const MFUInt32
*MultiSwitchBase::getMFChoices(void) const
242 SFInt32
*MultiSwitchBase::editSFSwitchMode(void)
244 editSField(SwitchModeFieldMask
);
246 return &_sfSwitchMode
;
249 const SFInt32
*MultiSwitchBase::getSFSwitchMode(void) const
251 return &_sfSwitchMode
;
259 /*------------------------------ access -----------------------------------*/
261 SizeT
MultiSwitchBase::getBinSize(ConstFieldMaskArg whichField
)
263 SizeT returnValue
= Inherited::getBinSize(whichField
);
265 if(FieldBits::NoField
!= (ChoicesFieldMask
& whichField
))
267 returnValue
+= _mfChoices
.getBinSize();
269 if(FieldBits::NoField
!= (SwitchModeFieldMask
& whichField
))
271 returnValue
+= _sfSwitchMode
.getBinSize();
277 void MultiSwitchBase::copyToBin(BinaryDataHandler
&pMem
,
278 ConstFieldMaskArg whichField
)
280 Inherited::copyToBin(pMem
, whichField
);
282 if(FieldBits::NoField
!= (ChoicesFieldMask
& whichField
))
284 _mfChoices
.copyToBin(pMem
);
286 if(FieldBits::NoField
!= (SwitchModeFieldMask
& whichField
))
288 _sfSwitchMode
.copyToBin(pMem
);
292 void MultiSwitchBase::copyFromBin(BinaryDataHandler
&pMem
,
293 ConstFieldMaskArg whichField
)
295 Inherited::copyFromBin(pMem
, whichField
);
297 if(FieldBits::NoField
!= (ChoicesFieldMask
& whichField
))
299 editMField(ChoicesFieldMask
, _mfChoices
);
300 _mfChoices
.copyFromBin(pMem
);
302 if(FieldBits::NoField
!= (SwitchModeFieldMask
& whichField
))
304 editSField(SwitchModeFieldMask
);
305 _sfSwitchMode
.copyFromBin(pMem
);
309 //! create a new instance of the class
310 MultiSwitchTransitPtr
MultiSwitchBase::createLocal(BitVector bFlags
)
312 MultiSwitchTransitPtr fc
;
314 if(getClassType().getPrototype() != NULL
)
316 FieldContainerTransitPtr tmpPtr
=
317 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
319 fc
= dynamic_pointer_cast
<MultiSwitch
>(tmpPtr
);
325 //! create a new instance of the class, copy the container flags
326 MultiSwitchTransitPtr
MultiSwitchBase::createDependent(BitVector bFlags
)
328 MultiSwitchTransitPtr fc
;
330 if(getClassType().getPrototype() != NULL
)
332 FieldContainerTransitPtr tmpPtr
=
333 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
335 fc
= dynamic_pointer_cast
<MultiSwitch
>(tmpPtr
);
341 //! create a new instance of the class
342 MultiSwitchTransitPtr
MultiSwitchBase::create(void)
344 MultiSwitchTransitPtr fc
;
346 if(getClassType().getPrototype() != NULL
)
348 FieldContainerTransitPtr tmpPtr
=
349 getClassType().getPrototype()-> shallowCopy();
351 fc
= dynamic_pointer_cast
<MultiSwitch
>(tmpPtr
);
357 MultiSwitch
*MultiSwitchBase::createEmptyLocal(BitVector bFlags
)
359 MultiSwitch
*returnValue
;
361 newPtr
<MultiSwitch
>(returnValue
, bFlags
);
363 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
368 //! create an empty new instance of the class, do not copy the prototype
369 MultiSwitch
*MultiSwitchBase::createEmpty(void)
371 MultiSwitch
*returnValue
;
373 newPtr
<MultiSwitch
>(returnValue
, Thread::getCurrentLocalFlags());
375 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
376 ~Thread::getCurrentLocalFlags();
382 FieldContainerTransitPtr
MultiSwitchBase::shallowCopyLocal(
383 BitVector bFlags
) const
387 newPtr(tmpPtr
, dynamic_cast<const MultiSwitch
*>(this), bFlags
);
389 FieldContainerTransitPtr
returnValue(tmpPtr
);
391 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
396 FieldContainerTransitPtr
MultiSwitchBase::shallowCopyDependent(
397 BitVector bFlags
) const
401 newPtr(tmpPtr
, dynamic_cast<const MultiSwitch
*>(this), ~bFlags
);
403 FieldContainerTransitPtr
returnValue(tmpPtr
);
405 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
410 FieldContainerTransitPtr
MultiSwitchBase::shallowCopy(void) const
415 dynamic_cast<const MultiSwitch
*>(this),
416 Thread::getCurrentLocalFlags());
418 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
420 FieldContainerTransitPtr
returnValue(tmpPtr
);
428 /*------------------------- constructors ----------------------------------*/
430 MultiSwitchBase::MultiSwitchBase(void) :
433 _sfSwitchMode (Int32(-1))
437 MultiSwitchBase::MultiSwitchBase(const MultiSwitchBase
&source
) :
439 _mfChoices (source
._mfChoices
),
440 _sfSwitchMode (source
._sfSwitchMode
)
445 /*-------------------------- destructors ----------------------------------*/
447 MultiSwitchBase::~MultiSwitchBase(void)
452 GetFieldHandlePtr
MultiSwitchBase::getHandleChoices (void) const
454 MFUInt32::GetHandlePtr
returnValue(
455 new MFUInt32::GetHandle(
457 this->getType().getFieldDesc(ChoicesFieldId
),
458 const_cast<MultiSwitchBase
*>(this)));
463 EditFieldHandlePtr
MultiSwitchBase::editHandleChoices (void)
465 MFUInt32::EditHandlePtr
returnValue(
466 new MFUInt32::EditHandle(
468 this->getType().getFieldDesc(ChoicesFieldId
),
472 editMField(ChoicesFieldMask
, _mfChoices
);
477 GetFieldHandlePtr
MultiSwitchBase::getHandleSwitchMode (void) const
479 SFInt32::GetHandlePtr
returnValue(
480 new SFInt32::GetHandle(
482 this->getType().getFieldDesc(SwitchModeFieldId
),
483 const_cast<MultiSwitchBase
*>(this)));
488 EditFieldHandlePtr
MultiSwitchBase::editHandleSwitchMode (void)
490 SFInt32::EditHandlePtr
returnValue(
491 new SFInt32::EditHandle(
493 this->getType().getFieldDesc(SwitchModeFieldId
),
497 editSField(SwitchModeFieldMask
);
503 #ifdef OSG_MT_CPTR_ASPECT
504 void MultiSwitchBase::execSyncV( FieldContainer
&oFrom
,
505 ConstFieldMaskArg whichField
,
506 AspectOffsetStore
&oOffsets
,
507 ConstFieldMaskArg syncMode
,
508 const UInt32 uiSyncInfo
)
510 MultiSwitch
*pThis
= static_cast<MultiSwitch
*>(this);
512 pThis
->execSync(static_cast<MultiSwitch
*>(&oFrom
),
521 #ifdef OSG_MT_CPTR_ASPECT
522 FieldContainer
*MultiSwitchBase::createAspectCopy(
523 const FieldContainer
*pRefAspect
) const
525 MultiSwitch
*returnValue
;
527 newAspectCopy(returnValue
,
528 dynamic_cast<const MultiSwitch
*>(pRefAspect
),
529 dynamic_cast<const MultiSwitch
*>(this));
535 void MultiSwitchBase::resolveLinks(void)
537 Inherited::resolveLinks();
539 #ifdef OSG_MT_CPTR_ASPECT
540 AspectOffsetStore oOffsets
;
542 _pAspectStore
->fillOffsetArray(oOffsets
, this);
545 #ifdef OSG_MT_CPTR_ASPECT
546 _mfChoices
.terminateShare(Thread::getCurrentAspect(),