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 **
48 ** class InterfaceOptions!
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 "OSGDeviceInterfaceSensor.h" // Parent Class
67 #include "OSGInterfaceOptionsBase.h"
68 #include "OSGInterfaceOptions.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::InterfaceOptions
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var DeviceInterfaceSensor * InterfaceOptionsBase::_sfParent
90 /*! \var UInt32 InterfaceOptionsBase::_sfNapTime
94 /*! \var UInt32 InterfaceOptionsBase::_sfBufferSize
99 /***************************************************************************\
100 * FieldType/FieldTrait Instantiation *
101 \***************************************************************************/
103 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
104 PointerType FieldTraits
<InterfaceOptions
*, nsOSG
>::_type(
105 "InterfaceOptionsPtr",
107 InterfaceOptions::getClassType(),
111 OSG_FIELDTRAITS_GETTYPE_NS(InterfaceOptions
*, nsOSG
)
113 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
118 DataType
&FieldTraits
< InterfaceOptions
*, nsOSG
+ 1 >::getType(void)
120 return FieldTraits
<InterfaceOptions
*, nsOSG
>::getType();
124 OSG_EXPORT_PTR_SFIELD(ChildPointerSField
,
126 UnrecordedRefCountPolicy
,
130 /***************************************************************************\
131 * Field Description *
132 \***************************************************************************/
134 void InterfaceOptionsBase::classDescInserter(TypeObject
&oType
)
136 FieldDescriptionBase
*pDesc
= NULL
;
139 pDesc
= new SFParentDeviceInterfaceSensorPtr::Description(
140 SFParentDeviceInterfaceSensorPtr::getClassType(),
143 ParentFieldId
, ParentFieldMask
,
145 (Field::SFDefaultFlags
| Field::FStdAccess
),
146 static_cast <FieldEditMethodSig
>(&InterfaceOptions::invalidEditField
),
147 static_cast <FieldGetMethodSig
>(&InterfaceOptions::invalidGetField
));
149 oType
.addInitialDesc(pDesc
);
151 pDesc
= new SFUInt32::Description(
152 SFUInt32::getClassType(),
155 NapTimeFieldId
, NapTimeFieldMask
,
157 (Field::FStdAccess
| Field::FThreadLocal
),
158 static_cast<FieldEditMethodSig
>(&InterfaceOptions::editHandleNapTime
),
159 static_cast<FieldGetMethodSig
>(&InterfaceOptions::getHandleNapTime
));
161 oType
.addInitialDesc(pDesc
);
163 pDesc
= new SFUInt32::Description(
164 SFUInt32::getClassType(),
167 BufferSizeFieldId
, BufferSizeFieldMask
,
169 (Field::FStdAccess
| Field::FThreadLocal
),
170 static_cast<FieldEditMethodSig
>(&InterfaceOptions::editHandleBufferSize
),
171 static_cast<FieldGetMethodSig
>(&InterfaceOptions::getHandleBufferSize
));
173 oType
.addInitialDesc(pDesc
);
177 InterfaceOptionsBase::TypeObject
InterfaceOptionsBase::_type(
178 InterfaceOptionsBase::getClassname(),
179 Inherited::getClassname(),
182 reinterpret_cast<PrototypeCreateF
>(&InterfaceOptionsBase::createEmptyLocal
),
183 reinterpret_cast<InitContainerF
>(&InterfaceOptions::initMethod
),
184 reinterpret_cast<ExitContainerF
>(&InterfaceOptions::exitMethod
),
185 reinterpret_cast<InitalInsertDescFunc
>(
186 reinterpret_cast<void *>(&InterfaceOptions::classDescInserter
)),
189 "<?xml version=\"1.0\"?>\n"
192 " name=\"InterfaceOptions\"\n"
193 " parent=\"FieldContainer\"\n"
194 " library=\"ContribCSM\"\n"
195 " pointerfieldtypes=\"single\"\n"
196 " structure=\"concrete\"\n"
197 " systemcomponent=\"true\"\n"
198 " parentsystemcomponent=\"true\"\n"
199 " decoratable=\"false\"\n"
200 " useLocalIncludes=\"false\"\n"
201 " isNodeCore=\"false\"\n"
202 " isBundle=\"true\"\n"
203 " parentFields=\"none\"\n"
204 " childFields=\"single\"\n"
208 " type=\"DeviceInterfaceSensor\"\n"
209 " cardinality=\"single\"\n"
210 " visibility=\"internal\"\n"
212 " category=\"parentpointer\"\n"
217 " name=\"napTime\"\n"
219 " cardinality=\"single\"\n"
220 " visibility=\"internal\"\n"
221 " access=\"public\"\n"
222 " defaultValue=\"10\"\n"
223 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
228 " name=\"bufferSize\"\n"
230 " cardinality=\"single\"\n"
231 " visibility=\"internal\"\n"
232 " access=\"public\"\n"
233 " defaultValue=\"128\"\n"
234 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
237 "</FieldContainer>\n",
241 /*------------------------------ get -----------------------------------*/
243 FieldContainerType
&InterfaceOptionsBase::getType(void)
248 const FieldContainerType
&InterfaceOptionsBase::getType(void) const
253 UInt32
InterfaceOptionsBase::getContainerSize(void) const
255 return sizeof(InterfaceOptions
);
258 /*------------------------- decorator get ------------------------------*/
262 SFUInt32
*InterfaceOptionsBase::editSFNapTime(void)
264 editSField(NapTimeFieldMask
);
269 const SFUInt32
*InterfaceOptionsBase::getSFNapTime(void) const
275 SFUInt32
*InterfaceOptionsBase::editSFBufferSize(void)
277 editSField(BufferSizeFieldMask
);
279 return &_sfBufferSize
;
282 const SFUInt32
*InterfaceOptionsBase::getSFBufferSize(void) const
284 return &_sfBufferSize
;
292 /*------------------------------ access -----------------------------------*/
294 SizeT
InterfaceOptionsBase::getBinSize(ConstFieldMaskArg whichField
)
296 SizeT returnValue
= Inherited::getBinSize(whichField
);
298 if(FieldBits::NoField
!= (ParentFieldMask
& whichField
))
300 returnValue
+= _sfParent
.getBinSize();
302 if(FieldBits::NoField
!= (NapTimeFieldMask
& whichField
))
304 returnValue
+= _sfNapTime
.getBinSize();
306 if(FieldBits::NoField
!= (BufferSizeFieldMask
& whichField
))
308 returnValue
+= _sfBufferSize
.getBinSize();
314 void InterfaceOptionsBase::copyToBin(BinaryDataHandler
&pMem
,
315 ConstFieldMaskArg whichField
)
317 Inherited::copyToBin(pMem
, whichField
);
319 if(FieldBits::NoField
!= (ParentFieldMask
& whichField
))
321 _sfParent
.copyToBin(pMem
);
323 if(FieldBits::NoField
!= (NapTimeFieldMask
& whichField
))
325 _sfNapTime
.copyToBin(pMem
);
327 if(FieldBits::NoField
!= (BufferSizeFieldMask
& whichField
))
329 _sfBufferSize
.copyToBin(pMem
);
333 void InterfaceOptionsBase::copyFromBin(BinaryDataHandler
&pMem
,
334 ConstFieldMaskArg whichField
)
336 Inherited::copyFromBin(pMem
, whichField
);
338 if(FieldBits::NoField
!= (ParentFieldMask
& whichField
))
340 editSField(ParentFieldMask
);
341 _sfParent
.copyFromBin(pMem
);
343 if(FieldBits::NoField
!= (NapTimeFieldMask
& whichField
))
345 editSField(NapTimeFieldMask
);
346 _sfNapTime
.copyFromBin(pMem
);
348 if(FieldBits::NoField
!= (BufferSizeFieldMask
& whichField
))
350 editSField(BufferSizeFieldMask
);
351 _sfBufferSize
.copyFromBin(pMem
);
355 //! create a new instance of the class
356 InterfaceOptionsTransitPtr
InterfaceOptionsBase::createLocal(BitVector bFlags
)
358 InterfaceOptionsTransitPtr fc
;
360 if(getClassType().getPrototype() != NULL
)
362 FieldContainerTransitPtr tmpPtr
=
363 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
365 fc
= dynamic_pointer_cast
<InterfaceOptions
>(tmpPtr
);
371 //! create a new instance of the class, copy the container flags
372 InterfaceOptionsTransitPtr
InterfaceOptionsBase::createDependent(BitVector bFlags
)
374 InterfaceOptionsTransitPtr fc
;
376 if(getClassType().getPrototype() != NULL
)
378 FieldContainerTransitPtr tmpPtr
=
379 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
381 fc
= dynamic_pointer_cast
<InterfaceOptions
>(tmpPtr
);
387 //! create a new instance of the class
388 InterfaceOptionsTransitPtr
InterfaceOptionsBase::create(void)
390 return createLocal();
393 InterfaceOptions
*InterfaceOptionsBase::createEmptyLocal(BitVector bFlags
)
395 InterfaceOptions
*returnValue
;
397 newPtr
<InterfaceOptions
>(returnValue
, bFlags
);
399 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
404 //! create an empty new instance of the class, do not copy the prototype
405 InterfaceOptions
*InterfaceOptionsBase::createEmpty(void)
407 return createEmptyLocal();
411 FieldContainerTransitPtr
InterfaceOptionsBase::shallowCopyLocal(
412 BitVector bFlags
) const
414 InterfaceOptions
*tmpPtr
;
416 newPtr(tmpPtr
, dynamic_cast<const InterfaceOptions
*>(this), bFlags
);
418 FieldContainerTransitPtr
returnValue(tmpPtr
);
420 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
425 FieldContainerTransitPtr
InterfaceOptionsBase::shallowCopyDependent(
426 BitVector bFlags
) const
428 InterfaceOptions
*tmpPtr
;
430 newPtr(tmpPtr
, dynamic_cast<const InterfaceOptions
*>(this), ~bFlags
);
432 FieldContainerTransitPtr
returnValue(tmpPtr
);
434 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
439 FieldContainerTransitPtr
InterfaceOptionsBase::shallowCopy(void) const
441 return shallowCopyLocal();
447 /*------------------------- constructors ----------------------------------*/
449 InterfaceOptionsBase::InterfaceOptionsBase(void) :
452 _sfNapTime (UInt32(10)),
453 _sfBufferSize (UInt32(128))
457 InterfaceOptionsBase::InterfaceOptionsBase(const InterfaceOptionsBase
&source
) :
460 _sfNapTime (source
._sfNapTime
),
461 _sfBufferSize (source
._sfBufferSize
)
466 /*-------------------------- destructors ----------------------------------*/
468 InterfaceOptionsBase::~InterfaceOptionsBase(void)
471 /*-------------------------------------------------------------------------*/
474 bool InterfaceOptionsBase::linkParent(
475 FieldContainer
* const pParent
,
476 UInt16
const childFieldId
,
477 UInt16
const parentFieldId
)
479 if(parentFieldId
== ParentFieldId
)
481 DeviceInterfaceSensor
* pTypedParent
=
482 dynamic_cast< DeviceInterfaceSensor
* >(pParent
);
484 if(pTypedParent
!= NULL
)
486 FieldContainer
*pOldParent
=
487 _sfParent
.getValue ();
489 UInt16 oldChildFieldId
=
490 _sfParent
.getParentFieldPos();
492 if(pOldParent
!= NULL
)
494 pOldParent
->unlinkChild(this, oldChildFieldId
);
497 editSField(ParentFieldMask
);
499 _sfParent
.setValue(static_cast<DeviceInterfaceSensor
*>(pParent
), childFieldId
);
507 return Inherited::linkParent(pParent
, childFieldId
, parentFieldId
);
510 bool InterfaceOptionsBase::unlinkParent(
511 FieldContainer
* const pParent
,
512 UInt16
const parentFieldId
)
514 if(parentFieldId
== ParentFieldId
)
516 DeviceInterfaceSensor
* pTypedParent
=
517 dynamic_cast< DeviceInterfaceSensor
* >(pParent
);
519 if(pTypedParent
!= NULL
)
521 if(_sfParent
.getValue() == pTypedParent
)
523 editSField(ParentFieldMask
);
525 _sfParent
.setValue(NULL
, 0xFFFF);
530 SWARNING
<< "Child ([" << this
531 << "] id [" << this->getId()
532 << "] type [" << this->getType().getCName()
533 << "] parentFieldId [" << parentFieldId
534 << "]) - Parent ([" << pParent
535 << "] id [" << pParent
->getId()
536 << "] type [" << pParent
->getType().getCName()
537 << "]): link inconsistent!"
546 return Inherited::unlinkParent(pParent
, parentFieldId
);
551 GetFieldHandlePtr
InterfaceOptionsBase::getHandleParent (void) const
553 SFParentDeviceInterfaceSensorPtr::GetHandlePtr returnValue
;
558 EditFieldHandlePtr
InterfaceOptionsBase::editHandleParent (void)
560 EditFieldHandlePtr returnValue
;
565 GetFieldHandlePtr
InterfaceOptionsBase::getHandleNapTime (void) const
567 SFUInt32::GetHandlePtr
returnValue(
568 new SFUInt32::GetHandle(
570 this->getType().getFieldDesc(NapTimeFieldId
),
571 const_cast<InterfaceOptionsBase
*>(this)));
576 EditFieldHandlePtr
InterfaceOptionsBase::editHandleNapTime (void)
578 SFUInt32::EditHandlePtr
returnValue(
579 new SFUInt32::EditHandle(
581 this->getType().getFieldDesc(NapTimeFieldId
),
585 editSField(NapTimeFieldMask
);
590 GetFieldHandlePtr
InterfaceOptionsBase::getHandleBufferSize (void) const
592 SFUInt32::GetHandlePtr
returnValue(
593 new SFUInt32::GetHandle(
595 this->getType().getFieldDesc(BufferSizeFieldId
),
596 const_cast<InterfaceOptionsBase
*>(this)));
601 EditFieldHandlePtr
InterfaceOptionsBase::editHandleBufferSize (void)
603 SFUInt32::EditHandlePtr
returnValue(
604 new SFUInt32::EditHandle(
606 this->getType().getFieldDesc(BufferSizeFieldId
),
610 editSField(BufferSizeFieldMask
);
616 #ifdef OSG_MT_CPTR_ASPECT
617 void InterfaceOptionsBase::execSyncV( FieldContainer
&oFrom
,
618 ConstFieldMaskArg whichField
,
619 AspectOffsetStore
&oOffsets
,
620 ConstFieldMaskArg syncMode
,
621 const UInt32 uiSyncInfo
)
623 InterfaceOptions
*pThis
= static_cast<InterfaceOptions
*>(this);
625 pThis
->execSync(static_cast<InterfaceOptions
*>(&oFrom
),
634 #ifdef OSG_MT_CPTR_ASPECT
635 FieldContainer
*InterfaceOptionsBase::createAspectCopy(
636 const FieldContainer
*pRefAspect
) const
638 InterfaceOptions
*returnValue
;
640 newAspectCopy(returnValue
,
641 dynamic_cast<const InterfaceOptions
*>(pRefAspect
),
642 dynamic_cast<const InterfaceOptions
*>(this));
648 void InterfaceOptionsBase::resolveLinks(void)
650 Inherited::resolveLinks();