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 "OSGSwitchBase.h"
67 #include "OSGSwitch.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
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
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(
100 Switch::getClassType(),
104 OSG_FIELDTRAITS_GETTYPE_NS(Switch
*, nsOSG
)
106 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
110 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
114 /***************************************************************************\
115 * Field Description *
116 \***************************************************************************/
118 void SwitchBase::classDescInserter(TypeObject
&oType
)
120 FieldDescriptionBase
*pDesc
= NULL
;
123 pDesc
= new SFInt32::Description(
124 SFInt32::getClassType(),
127 ChoiceFieldId
, ChoiceFieldMask
,
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(),
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
)),
149 "<?xml version=\"1.0\"?>\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"
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"
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"
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"
181 /*------------------------------ get -----------------------------------*/
183 FieldContainerType
&SwitchBase::getType(void)
188 const FieldContainerType
&SwitchBase::getType(void) const
193 UInt32
SwitchBase::getContainerSize(void) const
195 return sizeof(Switch
);
198 /*------------------------- decorator get ------------------------------*/
201 SFInt32
*SwitchBase::editSFChoice(void)
203 editSField(ChoiceFieldMask
);
208 const SFInt32
*SwitchBase::getSFChoice(void) const
218 /*------------------------------ access -----------------------------------*/
220 SizeT
SwitchBase::getBinSize(ConstFieldMaskArg whichField
)
222 SizeT returnValue
= Inherited::getBinSize(whichField
);
224 if(FieldBits::NoField
!= (ChoiceFieldMask
& whichField
))
226 returnValue
+= _sfChoice
.getBinSize();
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
)
260 if(getClassType().getPrototype() != NULL
)
262 FieldContainerTransitPtr tmpPtr
=
263 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
265 fc
= dynamic_pointer_cast
<Switch
>(tmpPtr
);
271 //! create a new instance of the class, copy the container flags
272 SwitchTransitPtr
SwitchBase::createDependent(BitVector bFlags
)
276 if(getClassType().getPrototype() != NULL
)
278 FieldContainerTransitPtr tmpPtr
=
279 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
281 fc
= dynamic_pointer_cast
<Switch
>(tmpPtr
);
287 //! create a new instance of the class
288 SwitchTransitPtr
SwitchBase::create(void)
292 if(getClassType().getPrototype() != NULL
)
294 FieldContainerTransitPtr tmpPtr
=
295 getClassType().getPrototype()-> shallowCopy();
297 fc
= dynamic_pointer_cast
<Switch
>(tmpPtr
);
303 Switch
*SwitchBase::createEmptyLocal(BitVector bFlags
)
307 newPtr
<Switch
>(returnValue
, bFlags
);
309 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
314 //! create an empty new instance of the class, do not copy the prototype
315 Switch
*SwitchBase::createEmpty(void)
319 newPtr
<Switch
>(returnValue
, Thread::getCurrentLocalFlags());
321 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
322 ~Thread::getCurrentLocalFlags();
328 FieldContainerTransitPtr
SwitchBase::shallowCopyLocal(
329 BitVector bFlags
) const
333 newPtr(tmpPtr
, dynamic_cast<const Switch
*>(this), bFlags
);
335 FieldContainerTransitPtr
returnValue(tmpPtr
);
337 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
342 FieldContainerTransitPtr
SwitchBase::shallowCopyDependent(
343 BitVector bFlags
) const
347 newPtr(tmpPtr
, dynamic_cast<const Switch
*>(this), ~bFlags
);
349 FieldContainerTransitPtr
returnValue(tmpPtr
);
351 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
356 FieldContainerTransitPtr
SwitchBase::shallowCopy(void) const
361 dynamic_cast<const Switch
*>(this),
362 Thread::getCurrentLocalFlags());
364 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
366 FieldContainerTransitPtr
returnValue(tmpPtr
);
374 /*------------------------- constructors ----------------------------------*/
376 SwitchBase::SwitchBase(void) :
378 _sfChoice (Int32(-1))
382 SwitchBase::SwitchBase(const SwitchBase
&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(
401 this->getType().getFieldDesc(ChoiceFieldId
),
402 const_cast<SwitchBase
*>(this)));
407 EditFieldHandlePtr
SwitchBase::editHandleChoice (void)
409 SFInt32::EditHandlePtr
returnValue(
410 new SFInt32::EditHandle(
412 this->getType().getFieldDesc(ChoiceFieldId
),
416 editSField(ChoiceFieldMask
);
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
),
440 #ifdef OSG_MT_CPTR_ASPECT
441 FieldContainer
*SwitchBase::createAspectCopy(
442 const FieldContainer
*pRefAspect
) const
446 newAspectCopy(returnValue
,
447 dynamic_cast<const Switch
*>(pRefAspect
),
448 dynamic_cast<const Switch
*>(this));
454 void SwitchBase::resolveLinks(void)
456 Inherited::resolveLinks();