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 "OSGKeySensorBase.h"
67 #include "OSGKeySensor.h"
69 #include <boost/bind.hpp>
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::KeySensor
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var std::string KeySensorBase::_sfKey
89 /*! \var bool KeySensorBase::_sfStateRaw
93 /*! \var bool KeySensorBase::_sfStateFlipFlop
97 /*! \var OSGAny KeySensorBase::_sfSignalPressed
101 /*! \var OSGAny KeySensorBase::_sfSignalReleased
106 /***************************************************************************\
107 * FieldType/FieldTrait Instantiation *
108 \***************************************************************************/
110 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
111 PointerType FieldTraits
<KeySensor
*, nsOSG
>::_type(
113 "AttachmentContainerPtr",
114 KeySensor::getClassType(),
118 OSG_FIELDTRAITS_GETTYPE_NS(KeySensor
*, nsOSG
)
120 /***************************************************************************\
121 * Field Description *
122 \***************************************************************************/
124 void KeySensorBase::classDescInserter(TypeObject
&oType
)
126 FieldDescriptionBase
*pDesc
= NULL
;
129 pDesc
= new SFString::Description(
130 SFString::getClassType(),
133 KeyFieldId
, KeyFieldMask
,
135 (Field::FStdAccess
| Field::FThreadLocal
),
136 static_cast<FieldEditMethodSig
>(&KeySensor::editHandleKey
),
137 static_cast<FieldGetMethodSig
>(&KeySensor::getHandleKey
));
139 oType
.addInitialDesc(pDesc
);
141 pDesc
= new SFBool::Description(
142 SFBool::getClassType(),
145 StateRawFieldId
, StateRawFieldMask
,
147 (Field::FStdAccess
| Field::FThreadLocal
),
148 static_cast<FieldEditMethodSig
>(&KeySensor::editHandleStateRaw
),
149 static_cast<FieldGetMethodSig
>(&KeySensor::getHandleStateRaw
));
151 oType
.addInitialDesc(pDesc
);
153 pDesc
= new SFBool::Description(
154 SFBool::getClassType(),
157 StateFlipFlopFieldId
, StateFlipFlopFieldMask
,
159 (Field::FStdAccess
| Field::FThreadLocal
),
160 static_cast<FieldEditMethodSig
>(&KeySensor::editHandleStateFlipFlop
),
161 static_cast<FieldGetMethodSig
>(&KeySensor::getHandleStateFlipFlop
));
163 oType
.addInitialDesc(pDesc
);
165 pDesc
= new SFOSGAny::Description(
166 SFOSGAny::getClassType(),
169 SignalPressedFieldId
, SignalPressedFieldMask
,
171 (Field::FStdAccess
| Field::FThreadLocal
),
172 static_cast<FieldEditMethodSig
>(&KeySensor::editHandleSignalPressed
),
173 static_cast<FieldGetMethodSig
>(&KeySensor::getHandleSignalPressed
));
175 oType
.addInitialDesc(pDesc
);
177 pDesc
= new SFOSGAny::Description(
178 SFOSGAny::getClassType(),
181 SignalReleasedFieldId
, SignalReleasedFieldMask
,
183 (Field::FStdAccess
| Field::FThreadLocal
),
184 static_cast<FieldEditMethodSig
>(&KeySensor::editHandleSignalReleased
),
185 static_cast<FieldGetMethodSig
>(&KeySensor::getHandleSignalReleased
));
187 oType
.addInitialDesc(pDesc
);
191 KeySensorBase::TypeObject
KeySensorBase::_type(
192 KeySensorBase::getClassname(),
193 Inherited::getClassname(),
196 reinterpret_cast<PrototypeCreateF
>(&KeySensorBase::createEmptyLocal
),
197 reinterpret_cast<InitContainerF
>(&KeySensor::initMethod
),
198 reinterpret_cast<ExitContainerF
>(&KeySensor::exitMethod
),
199 reinterpret_cast<InitalInsertDescFunc
>(
200 reinterpret_cast<void *>(&KeySensor::classDescInserter
)),
203 "<?xml version=\"1.0\"?>\n"
206 " name=\"KeySensor\"\n"
207 " parent=\"AttachmentContainer\"\n"
208 " library=\"ContribCSM\"\n"
209 " pointerfieldtypes=\"none\"\n"
210 " structure=\"concrete\"\n"
211 " systemcomponent=\"true\"\n"
212 " parentsystemcomponent=\"true\"\n"
213 " decoratable=\"false\"\n"
214 " useLocalIncludes=\"false\"\n"
215 " isNodeCore=\"false\"\n"
216 " isBundle=\"true\"\n"
217 " parentFields=\"none\"\n"
221 " type=\"std::string\"\n"
222 " cardinality=\"single\"\n"
223 " visibility=\"internal\"\n"
224 " access=\"protected\"\n"
225 " defaultValue=\"\"\n"
226 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
230 " name=\"stateRaw\"\n"
232 " cardinality=\"single\"\n"
233 " visibility=\"internal\"\n"
234 " access=\"public\"\n"
235 " defaultValue=\"true\"\n"
236 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
240 " name=\"stateFlipFlop\"\n"
242 " cardinality=\"single\"\n"
243 " visibility=\"internal\"\n"
244 " access=\"public\"\n"
245 " defaultValue=\"false\"\n"
246 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
250 " name=\"signalPressed\"\n"
252 " cardinality=\"single\"\n"
253 " visibility=\"internal\"\n"
254 " access=\"protected\"\n"
255 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
259 " name=\"signalReleased\"\n"
261 " cardinality=\"single\"\n"
262 " visibility=\"internal\"\n"
263 " access=\"protected\"\n"
264 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
267 "</FieldContainer>\n",
271 /*------------------------------ get -----------------------------------*/
273 FieldContainerType
&KeySensorBase::getType(void)
278 const FieldContainerType
&KeySensorBase::getType(void) const
283 UInt32
KeySensorBase::getContainerSize(void) const
285 return sizeof(KeySensor
);
288 /*------------------------- decorator get ------------------------------*/
291 SFString
*KeySensorBase::editSFKey(void)
293 editSField(KeyFieldMask
);
298 const SFString
*KeySensorBase::getSFKey(void) const
304 SFBool
*KeySensorBase::editSFStateRaw(void)
306 editSField(StateRawFieldMask
);
311 const SFBool
*KeySensorBase::getSFStateRaw(void) const
317 SFBool
*KeySensorBase::editSFStateFlipFlop(void)
319 editSField(StateFlipFlopFieldMask
);
321 return &_sfStateFlipFlop
;
324 const SFBool
*KeySensorBase::getSFStateFlipFlop(void) const
326 return &_sfStateFlipFlop
;
330 SFOSGAny
*KeySensorBase::editSFSignalPressed(void)
332 editSField(SignalPressedFieldMask
);
334 return &_sfSignalPressed
;
337 const SFOSGAny
*KeySensorBase::getSFSignalPressed(void) const
339 return &_sfSignalPressed
;
343 SFOSGAny
*KeySensorBase::editSFSignalReleased(void)
345 editSField(SignalReleasedFieldMask
);
347 return &_sfSignalReleased
;
350 const SFOSGAny
*KeySensorBase::getSFSignalReleased(void) const
352 return &_sfSignalReleased
;
360 /*------------------------------ access -----------------------------------*/
362 SizeT
KeySensorBase::getBinSize(ConstFieldMaskArg whichField
)
364 SizeT returnValue
= Inherited::getBinSize(whichField
);
366 if(FieldBits::NoField
!= (KeyFieldMask
& whichField
))
368 returnValue
+= _sfKey
.getBinSize();
370 if(FieldBits::NoField
!= (StateRawFieldMask
& whichField
))
372 returnValue
+= _sfStateRaw
.getBinSize();
374 if(FieldBits::NoField
!= (StateFlipFlopFieldMask
& whichField
))
376 returnValue
+= _sfStateFlipFlop
.getBinSize();
378 if(FieldBits::NoField
!= (SignalPressedFieldMask
& whichField
))
380 returnValue
+= _sfSignalPressed
.getBinSize();
382 if(FieldBits::NoField
!= (SignalReleasedFieldMask
& whichField
))
384 returnValue
+= _sfSignalReleased
.getBinSize();
390 void KeySensorBase::copyToBin(BinaryDataHandler
&pMem
,
391 ConstFieldMaskArg whichField
)
393 Inherited::copyToBin(pMem
, whichField
);
395 if(FieldBits::NoField
!= (KeyFieldMask
& whichField
))
397 _sfKey
.copyToBin(pMem
);
399 if(FieldBits::NoField
!= (StateRawFieldMask
& whichField
))
401 _sfStateRaw
.copyToBin(pMem
);
403 if(FieldBits::NoField
!= (StateFlipFlopFieldMask
& whichField
))
405 _sfStateFlipFlop
.copyToBin(pMem
);
407 if(FieldBits::NoField
!= (SignalPressedFieldMask
& whichField
))
409 _sfSignalPressed
.copyToBin(pMem
);
411 if(FieldBits::NoField
!= (SignalReleasedFieldMask
& whichField
))
413 _sfSignalReleased
.copyToBin(pMem
);
417 void KeySensorBase::copyFromBin(BinaryDataHandler
&pMem
,
418 ConstFieldMaskArg whichField
)
420 Inherited::copyFromBin(pMem
, whichField
);
422 if(FieldBits::NoField
!= (KeyFieldMask
& whichField
))
424 editSField(KeyFieldMask
);
425 _sfKey
.copyFromBin(pMem
);
427 if(FieldBits::NoField
!= (StateRawFieldMask
& whichField
))
429 editSField(StateRawFieldMask
);
430 _sfStateRaw
.copyFromBin(pMem
);
432 if(FieldBits::NoField
!= (StateFlipFlopFieldMask
& whichField
))
434 editSField(StateFlipFlopFieldMask
);
435 _sfStateFlipFlop
.copyFromBin(pMem
);
437 if(FieldBits::NoField
!= (SignalPressedFieldMask
& whichField
))
439 editSField(SignalPressedFieldMask
);
440 _sfSignalPressed
.copyFromBin(pMem
);
442 if(FieldBits::NoField
!= (SignalReleasedFieldMask
& whichField
))
444 editSField(SignalReleasedFieldMask
);
445 _sfSignalReleased
.copyFromBin(pMem
);
449 //! create a new instance of the class
450 KeySensorTransitPtr
KeySensorBase::createLocal(BitVector bFlags
)
452 KeySensorTransitPtr fc
;
454 if(getClassType().getPrototype() != NULL
)
456 FieldContainerTransitPtr tmpPtr
=
457 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
459 fc
= dynamic_pointer_cast
<KeySensor
>(tmpPtr
);
465 //! create a new instance of the class, copy the container flags
466 KeySensorTransitPtr
KeySensorBase::createDependent(BitVector bFlags
)
468 KeySensorTransitPtr fc
;
470 if(getClassType().getPrototype() != NULL
)
472 FieldContainerTransitPtr tmpPtr
=
473 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
475 fc
= dynamic_pointer_cast
<KeySensor
>(tmpPtr
);
481 //! create a new instance of the class
482 KeySensorTransitPtr
KeySensorBase::create(void)
484 return createLocal();
487 KeySensor
*KeySensorBase::createEmptyLocal(BitVector bFlags
)
489 KeySensor
*returnValue
;
491 newPtr
<KeySensor
>(returnValue
, bFlags
);
493 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
498 //! create an empty new instance of the class, do not copy the prototype
499 KeySensor
*KeySensorBase::createEmpty(void)
501 return createEmptyLocal();
505 FieldContainerTransitPtr
KeySensorBase::shallowCopyLocal(
506 BitVector bFlags
) const
510 newPtr(tmpPtr
, dynamic_cast<const KeySensor
*>(this), bFlags
);
512 FieldContainerTransitPtr
returnValue(tmpPtr
);
514 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
519 FieldContainerTransitPtr
KeySensorBase::shallowCopyDependent(
520 BitVector bFlags
) const
524 newPtr(tmpPtr
, dynamic_cast<const KeySensor
*>(this), ~bFlags
);
526 FieldContainerTransitPtr
returnValue(tmpPtr
);
528 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
533 FieldContainerTransitPtr
KeySensorBase::shallowCopy(void) const
535 return shallowCopyLocal();
541 /*------------------------- constructors ----------------------------------*/
543 KeySensorBase::KeySensorBase(void) :
546 _sfStateRaw (bool(true)),
547 _sfStateFlipFlop (bool(false)),
553 KeySensorBase::KeySensorBase(const KeySensorBase
&source
) :
555 _sfKey (source
._sfKey
),
556 _sfStateRaw (source
._sfStateRaw
),
557 _sfStateFlipFlop (source
._sfStateFlipFlop
),
558 _sfSignalPressed (source
._sfSignalPressed
),
559 _sfSignalReleased (source
._sfSignalReleased
)
564 /*-------------------------- destructors ----------------------------------*/
566 KeySensorBase::~KeySensorBase(void)
571 GetFieldHandlePtr
KeySensorBase::getHandleKey (void) const
573 SFString::GetHandlePtr
returnValue(
574 new SFString::GetHandle(
576 this->getType().getFieldDesc(KeyFieldId
),
577 const_cast<KeySensorBase
*>(this)));
582 EditFieldHandlePtr
KeySensorBase::editHandleKey (void)
584 SFString::EditHandlePtr
returnValue(
585 new SFString::EditHandle(
587 this->getType().getFieldDesc(KeyFieldId
),
591 editSField(KeyFieldMask
);
596 GetFieldHandlePtr
KeySensorBase::getHandleStateRaw (void) const
598 SFBool::GetHandlePtr
returnValue(
599 new SFBool::GetHandle(
601 this->getType().getFieldDesc(StateRawFieldId
),
602 const_cast<KeySensorBase
*>(this)));
607 EditFieldHandlePtr
KeySensorBase::editHandleStateRaw (void)
609 SFBool::EditHandlePtr
returnValue(
610 new SFBool::EditHandle(
612 this->getType().getFieldDesc(StateRawFieldId
),
616 editSField(StateRawFieldMask
);
621 GetFieldHandlePtr
KeySensorBase::getHandleStateFlipFlop (void) const
623 SFBool::GetHandlePtr
returnValue(
624 new SFBool::GetHandle(
626 this->getType().getFieldDesc(StateFlipFlopFieldId
),
627 const_cast<KeySensorBase
*>(this)));
632 EditFieldHandlePtr
KeySensorBase::editHandleStateFlipFlop (void)
634 SFBool::EditHandlePtr
returnValue(
635 new SFBool::EditHandle(
637 this->getType().getFieldDesc(StateFlipFlopFieldId
),
641 editSField(StateFlipFlopFieldMask
);
646 GetFieldHandlePtr
KeySensorBase::getHandleSignalPressed (void) const
648 SFOSGAny::GetHandlePtr
returnValue(
649 new SFOSGAny::GetHandle(
651 this->getType().getFieldDesc(SignalPressedFieldId
),
652 const_cast<KeySensorBase
*>(this)));
657 EditFieldHandlePtr
KeySensorBase::editHandleSignalPressed (void)
659 SFOSGAny::EditHandlePtr
returnValue(
660 new SFOSGAny::EditHandle(
662 this->getType().getFieldDesc(SignalPressedFieldId
),
666 editSField(SignalPressedFieldMask
);
671 GetFieldHandlePtr
KeySensorBase::getHandleSignalReleased (void) const
673 SFOSGAny::GetHandlePtr
returnValue(
674 new SFOSGAny::GetHandle(
676 this->getType().getFieldDesc(SignalReleasedFieldId
),
677 const_cast<KeySensorBase
*>(this)));
682 EditFieldHandlePtr
KeySensorBase::editHandleSignalReleased (void)
684 SFOSGAny::EditHandlePtr
returnValue(
685 new SFOSGAny::EditHandle(
687 this->getType().getFieldDesc(SignalReleasedFieldId
),
691 editSField(SignalReleasedFieldMask
);
697 #ifdef OSG_MT_CPTR_ASPECT
698 void KeySensorBase::execSyncV( FieldContainer
&oFrom
,
699 ConstFieldMaskArg whichField
,
700 AspectOffsetStore
&oOffsets
,
701 ConstFieldMaskArg syncMode
,
702 const UInt32 uiSyncInfo
)
704 KeySensor
*pThis
= static_cast<KeySensor
*>(this);
706 pThis
->execSync(static_cast<KeySensor
*>(&oFrom
),
715 #ifdef OSG_MT_CPTR_ASPECT
716 FieldContainer
*KeySensorBase::createAspectCopy(
717 const FieldContainer
*pRefAspect
) const
719 KeySensor
*returnValue
;
721 newAspectCopy(returnValue
,
722 dynamic_cast<const KeySensor
*>(pRefAspect
),
723 dynamic_cast<const KeySensor
*>(this));
729 void KeySensorBase::resolveLinks(void)
731 Inherited::resolveLinks();