changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Groups / Misc / OSGMultiSwitchBase.cpp
blob9d14a77453d091ecd4bf7494beaf68553456b576
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 MultiSwitch!
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"
66 #include "OSGMultiSwitchBase.h"
67 #include "OSGMultiSwitch.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
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
93 Mode of operation.
97 /***************************************************************************\
98 * FieldType/FieldTrait Instantiation *
99 \***************************************************************************/
101 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
102 PointerType FieldTraits<MultiSwitch *, nsOSG>::_type(
103 "MultiSwitchPtr",
104 "GroupPtr",
105 MultiSwitch::getClassType(),
106 nsOSG);
107 #endif
109 OSG_FIELDTRAITS_GETTYPE_NS(MultiSwitch *, nsOSG)
111 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
112 MultiSwitch *,
113 nsOSG)
115 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
116 MultiSwitch *,
117 nsOSG)
119 /***************************************************************************\
120 * Field Description *
121 \***************************************************************************/
123 void MultiSwitchBase::classDescInserter(TypeObject &oType)
125 FieldDescriptionBase *pDesc = NULL;
128 pDesc = new MFUInt32::Description(
129 MFUInt32::getClassType(),
130 "choices",
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,
134 false,
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(),
143 "switchMode",
144 "Mode of operation.\n",
145 SwitchModeFieldId, SwitchModeFieldMask,
146 false,
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(),
158 "NULL",
159 nsOSG, //Namespace
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)),
165 false,
167 "<?xml version=\"1.0\"?>\n"
168 "\n"
169 "<FieldContainer\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"
179 " >\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"
183 " <Field\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"
189 "\t >\n"
190 " Indices of children to be included in CHOICES mode. The indices are kept\n"
191 " sorted and any duplicates are removed.\n"
192 " </Field>\n"
193 " <Field\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"
200 "\t >\n"
201 " Mode of operation.\n"
202 " </Field>\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)
213 return _type;
216 const FieldContainerType &MultiSwitchBase::getType(void) const
218 return _type;
221 UInt32 MultiSwitchBase::getContainerSize(void) const
223 return sizeof(MultiSwitch);
226 /*------------------------- decorator get ------------------------------*/
229 MFUInt32 *MultiSwitchBase::editMFChoices(void)
231 editMField(ChoicesFieldMask, _mfChoices);
233 return &_mfChoices;
236 const MFUInt32 *MultiSwitchBase::getMFChoices(void) const
238 return &_mfChoices;
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();
274 return returnValue;
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);
322 return fc;
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);
338 return fc;
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);
354 return fc;
357 MultiSwitch *MultiSwitchBase::createEmptyLocal(BitVector bFlags)
359 MultiSwitch *returnValue;
361 newPtr<MultiSwitch>(returnValue, bFlags);
363 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
365 return returnValue;
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();
378 return returnValue;
382 FieldContainerTransitPtr MultiSwitchBase::shallowCopyLocal(
383 BitVector bFlags) const
385 MultiSwitch *tmpPtr;
387 newPtr(tmpPtr, dynamic_cast<const MultiSwitch *>(this), bFlags);
389 FieldContainerTransitPtr returnValue(tmpPtr);
391 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
393 return returnValue;
396 FieldContainerTransitPtr MultiSwitchBase::shallowCopyDependent(
397 BitVector bFlags) const
399 MultiSwitch *tmpPtr;
401 newPtr(tmpPtr, dynamic_cast<const MultiSwitch *>(this), ~bFlags);
403 FieldContainerTransitPtr returnValue(tmpPtr);
405 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
407 return returnValue;
410 FieldContainerTransitPtr MultiSwitchBase::shallowCopy(void) const
412 MultiSwitch *tmpPtr;
414 newPtr(tmpPtr,
415 dynamic_cast<const MultiSwitch *>(this),
416 Thread::getCurrentLocalFlags());
418 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
420 FieldContainerTransitPtr returnValue(tmpPtr);
422 return returnValue;
428 /*------------------------- constructors ----------------------------------*/
430 MultiSwitchBase::MultiSwitchBase(void) :
431 Inherited(),
432 _mfChoices (),
433 _sfSwitchMode (Int32(-1))
437 MultiSwitchBase::MultiSwitchBase(const MultiSwitchBase &source) :
438 Inherited(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(
456 &_mfChoices,
457 this->getType().getFieldDesc(ChoicesFieldId),
458 const_cast<MultiSwitchBase *>(this)));
460 return returnValue;
463 EditFieldHandlePtr MultiSwitchBase::editHandleChoices (void)
465 MFUInt32::EditHandlePtr returnValue(
466 new MFUInt32::EditHandle(
467 &_mfChoices,
468 this->getType().getFieldDesc(ChoicesFieldId),
469 this));
472 editMField(ChoicesFieldMask, _mfChoices);
474 return returnValue;
477 GetFieldHandlePtr MultiSwitchBase::getHandleSwitchMode (void) const
479 SFInt32::GetHandlePtr returnValue(
480 new SFInt32::GetHandle(
481 &_sfSwitchMode,
482 this->getType().getFieldDesc(SwitchModeFieldId),
483 const_cast<MultiSwitchBase *>(this)));
485 return returnValue;
488 EditFieldHandlePtr MultiSwitchBase::editHandleSwitchMode (void)
490 SFInt32::EditHandlePtr returnValue(
491 new SFInt32::EditHandle(
492 &_sfSwitchMode,
493 this->getType().getFieldDesc(SwitchModeFieldId),
494 this));
497 editSField(SwitchModeFieldMask);
499 return returnValue;
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),
513 whichField,
514 oOffsets,
515 syncMode,
516 uiSyncInfo);
518 #endif
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));
531 return returnValue;
533 #endif
535 void MultiSwitchBase::resolveLinks(void)
537 Inherited::resolveLinks();
539 #ifdef OSG_MT_CPTR_ASPECT
540 AspectOffsetStore oOffsets;
542 _pAspectStore->fillOffsetArray(oOffsets, this);
543 #endif
545 #ifdef OSG_MT_CPTR_ASPECT
546 _mfChoices.terminateShare(Thread::getCurrentAspect(),
547 oOffsets);
548 #endif
552 OSG_END_NAMESPACE