changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Groups / Misc / OSGSwitchBase.cpp
blob86b1f636472149121c5613eff518824d184bd5c6
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 Switch!
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 "OSGSwitchBase.h"
67 #include "OSGSwitch.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::Switch
78 This core allows selection of different subtrees with the \c choice field.
79 Depending on its value either all, none or only the specified child is
80 enabled.
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var Int32 SwitchBase::_sfChoice
92 /***************************************************************************\
93 * FieldType/FieldTrait Instantiation *
94 \***************************************************************************/
96 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
97 PointerType FieldTraits<Switch *, nsOSG>::_type(
98 "SwitchPtr",
99 "GroupPtr",
100 Switch::getClassType(),
101 nsOSG);
102 #endif
104 OSG_FIELDTRAITS_GETTYPE_NS(Switch *, nsOSG)
106 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
107 Switch *,
108 nsOSG)
110 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
111 Switch *,
112 nsOSG)
114 /***************************************************************************\
115 * Field Description *
116 \***************************************************************************/
118 void SwitchBase::classDescInserter(TypeObject &oType)
120 FieldDescriptionBase *pDesc = NULL;
123 pDesc = new SFInt32::Description(
124 SFInt32::getClassType(),
125 "choice",
127 ChoiceFieldId, ChoiceFieldMask,
128 false,
129 (Field::SFDefaultFlags | Field::FStdAccess),
130 static_cast<FieldEditMethodSig>(&Switch::editHandleChoice),
131 static_cast<FieldGetMethodSig >(&Switch::getHandleChoice));
133 oType.addInitialDesc(pDesc);
137 SwitchBase::TypeObject SwitchBase::_type(
138 SwitchBase::getClassname(),
139 Inherited::getClassname(),
140 "NULL",
141 nsOSG, //Namespace
142 reinterpret_cast<PrototypeCreateF>(&SwitchBase::createEmptyLocal),
143 reinterpret_cast<InitContainerF>(&Switch::initMethod),
144 reinterpret_cast<ExitContainerF>(&Switch::exitMethod),
145 reinterpret_cast<InitalInsertDescFunc>(
146 reinterpret_cast<void *>(&Switch::classDescInserter)),
147 false,
149 "<?xml version=\"1.0\"?>\n"
150 "\n"
151 "<FieldContainer\n"
152 " name=\"Switch\"\n"
153 " parent=\"Group\"\n"
154 " library=\"Group\"\n"
155 " pointerfieldtypes=\"both\"\n"
156 " structure=\"concrete\"\n"
157 " systemcomponent=\"true\"\n"
158 " parentsystemcomponent=\"true\"\n"
159 " decoratable=\"false\"\n"
160 " isNodeCore=\"true\"\n"
161 " docGroupBase=\"GrpGroupMisc\"\n"
162 " >\n"
163 " This core allows selection of different subtrees with the \\c choice field.\n"
164 " Depending on its value either all, none or only the specified child is\n"
165 " enabled.\n"
166 " <Field\n"
167 "\t name=\"choice\"\n"
168 "\t type=\"Int32\"\n"
169 "\t cardinality=\"single\"\n"
170 "\t visibility=\"external\"\n"
171 "\t defaultValue=\"-1\"\n"
172 "\t access=\"public\"\n"
173 "\t >\n"
174 " </Field>\n"
175 "</FieldContainer>\n",
176 "This core allows selection of different subtrees with the \\c choice field.\n"
177 "Depending on its value either all, none or only the specified child is\n"
178 "enabled.\n"
181 /*------------------------------ get -----------------------------------*/
183 FieldContainerType &SwitchBase::getType(void)
185 return _type;
188 const FieldContainerType &SwitchBase::getType(void) const
190 return _type;
193 UInt32 SwitchBase::getContainerSize(void) const
195 return sizeof(Switch);
198 /*------------------------- decorator get ------------------------------*/
201 SFInt32 *SwitchBase::editSFChoice(void)
203 editSField(ChoiceFieldMask);
205 return &_sfChoice;
208 const SFInt32 *SwitchBase::getSFChoice(void) const
210 return &_sfChoice;
218 /*------------------------------ access -----------------------------------*/
220 SizeT SwitchBase::getBinSize(ConstFieldMaskArg whichField)
222 SizeT returnValue = Inherited::getBinSize(whichField);
224 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
226 returnValue += _sfChoice.getBinSize();
229 return returnValue;
232 void SwitchBase::copyToBin(BinaryDataHandler &pMem,
233 ConstFieldMaskArg whichField)
235 Inherited::copyToBin(pMem, whichField);
237 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
239 _sfChoice.copyToBin(pMem);
243 void SwitchBase::copyFromBin(BinaryDataHandler &pMem,
244 ConstFieldMaskArg whichField)
246 Inherited::copyFromBin(pMem, whichField);
248 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
250 editSField(ChoiceFieldMask);
251 _sfChoice.copyFromBin(pMem);
255 //! create a new instance of the class
256 SwitchTransitPtr SwitchBase::createLocal(BitVector bFlags)
258 SwitchTransitPtr fc;
260 if(getClassType().getPrototype() != NULL)
262 FieldContainerTransitPtr tmpPtr =
263 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
265 fc = dynamic_pointer_cast<Switch>(tmpPtr);
268 return fc;
271 //! create a new instance of the class, copy the container flags
272 SwitchTransitPtr SwitchBase::createDependent(BitVector bFlags)
274 SwitchTransitPtr fc;
276 if(getClassType().getPrototype() != NULL)
278 FieldContainerTransitPtr tmpPtr =
279 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
281 fc = dynamic_pointer_cast<Switch>(tmpPtr);
284 return fc;
287 //! create a new instance of the class
288 SwitchTransitPtr SwitchBase::create(void)
290 SwitchTransitPtr fc;
292 if(getClassType().getPrototype() != NULL)
294 FieldContainerTransitPtr tmpPtr =
295 getClassType().getPrototype()-> shallowCopy();
297 fc = dynamic_pointer_cast<Switch>(tmpPtr);
300 return fc;
303 Switch *SwitchBase::createEmptyLocal(BitVector bFlags)
305 Switch *returnValue;
307 newPtr<Switch>(returnValue, bFlags);
309 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
311 return returnValue;
314 //! create an empty new instance of the class, do not copy the prototype
315 Switch *SwitchBase::createEmpty(void)
317 Switch *returnValue;
319 newPtr<Switch>(returnValue, Thread::getCurrentLocalFlags());
321 returnValue->_pFieldFlags->_bNamespaceMask &=
322 ~Thread::getCurrentLocalFlags();
324 return returnValue;
328 FieldContainerTransitPtr SwitchBase::shallowCopyLocal(
329 BitVector bFlags) const
331 Switch *tmpPtr;
333 newPtr(tmpPtr, dynamic_cast<const Switch *>(this), bFlags);
335 FieldContainerTransitPtr returnValue(tmpPtr);
337 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
339 return returnValue;
342 FieldContainerTransitPtr SwitchBase::shallowCopyDependent(
343 BitVector bFlags) const
345 Switch *tmpPtr;
347 newPtr(tmpPtr, dynamic_cast<const Switch *>(this), ~bFlags);
349 FieldContainerTransitPtr returnValue(tmpPtr);
351 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
353 return returnValue;
356 FieldContainerTransitPtr SwitchBase::shallowCopy(void) const
358 Switch *tmpPtr;
360 newPtr(tmpPtr,
361 dynamic_cast<const Switch *>(this),
362 Thread::getCurrentLocalFlags());
364 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
366 FieldContainerTransitPtr returnValue(tmpPtr);
368 return returnValue;
374 /*------------------------- constructors ----------------------------------*/
376 SwitchBase::SwitchBase(void) :
377 Inherited(),
378 _sfChoice (Int32(-1))
382 SwitchBase::SwitchBase(const SwitchBase &source) :
383 Inherited(source),
384 _sfChoice (source._sfChoice )
389 /*-------------------------- destructors ----------------------------------*/
391 SwitchBase::~SwitchBase(void)
396 GetFieldHandlePtr SwitchBase::getHandleChoice (void) const
398 SFInt32::GetHandlePtr returnValue(
399 new SFInt32::GetHandle(
400 &_sfChoice,
401 this->getType().getFieldDesc(ChoiceFieldId),
402 const_cast<SwitchBase *>(this)));
404 return returnValue;
407 EditFieldHandlePtr SwitchBase::editHandleChoice (void)
409 SFInt32::EditHandlePtr returnValue(
410 new SFInt32::EditHandle(
411 &_sfChoice,
412 this->getType().getFieldDesc(ChoiceFieldId),
413 this));
416 editSField(ChoiceFieldMask);
418 return returnValue;
422 #ifdef OSG_MT_CPTR_ASPECT
423 void SwitchBase::execSyncV( FieldContainer &oFrom,
424 ConstFieldMaskArg whichField,
425 AspectOffsetStore &oOffsets,
426 ConstFieldMaskArg syncMode,
427 const UInt32 uiSyncInfo)
429 Switch *pThis = static_cast<Switch *>(this);
431 pThis->execSync(static_cast<Switch *>(&oFrom),
432 whichField,
433 oOffsets,
434 syncMode,
435 uiSyncInfo);
437 #endif
440 #ifdef OSG_MT_CPTR_ASPECT
441 FieldContainer *SwitchBase::createAspectCopy(
442 const FieldContainer *pRefAspect) const
444 Switch *returnValue;
446 newAspectCopy(returnValue,
447 dynamic_cast<const Switch *>(pRefAspect),
448 dynamic_cast<const Switch *>(this));
450 return returnValue;
452 #endif
454 void SwitchBase::resolveLinks(void)
456 Inherited::resolveLinks();
462 OSG_END_NAMESPACE