fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Contrib / ComplexSceneManager / Sensor / OSGKeySensorBase.cpp
bloba934723b4c742835adc46b9e253b60ab72f6920c
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 KeySensor!
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 "OSGKeySensorBase.h"
67 #include "OSGKeySensor.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
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(
112 "KeySensorPtr",
113 "AttachmentContainerPtr",
114 KeySensor::getClassType(),
115 nsOSG);
116 #endif
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(),
131 "key",
133 KeyFieldId, KeyFieldMask,
134 true,
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(),
143 "stateRaw",
145 StateRawFieldId, StateRawFieldMask,
146 true,
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(),
155 "stateFlipFlop",
157 StateFlipFlopFieldId, StateFlipFlopFieldMask,
158 true,
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(),
167 "signalPressed",
169 SignalPressedFieldId, SignalPressedFieldMask,
170 true,
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(),
179 "signalReleased",
181 SignalReleasedFieldId, SignalReleasedFieldMask,
182 true,
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(),
194 "NULL",
195 nsOSG, //Namespace
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)),
201 false,
203 "<?xml version=\"1.0\"?>\n"
204 "\n"
205 "<FieldContainer\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"
218 " >\n"
219 " <Field\n"
220 " name=\"key\"\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"
227 " \t>\n"
228 " </Field>\n"
229 " <Field\n"
230 " name=\"stateRaw\"\n"
231 " type=\"bool\"\n"
232 " cardinality=\"single\"\n"
233 " visibility=\"internal\"\n"
234 " access=\"public\"\n"
235 " defaultValue=\"true\"\n"
236 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
237 " \t>\n"
238 " </Field>\n"
239 " <Field\n"
240 " name=\"stateFlipFlop\"\n"
241 " type=\"bool\"\n"
242 " cardinality=\"single\"\n"
243 " visibility=\"internal\"\n"
244 " access=\"public\"\n"
245 " defaultValue=\"false\"\n"
246 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
247 "\t>\n"
248 " </Field>\n"
249 " <Field\n"
250 " name=\"signalPressed\"\n"
251 " type=\"OSGAny\"\n"
252 " cardinality=\"single\"\n"
253 " visibility=\"internal\"\n"
254 " access=\"protected\"\n"
255 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
256 " \t>\n"
257 " </Field>\n"
258 " <Field\n"
259 " name=\"signalReleased\"\n"
260 " type=\"OSGAny\"\n"
261 " cardinality=\"single\"\n"
262 " visibility=\"internal\"\n"
263 " access=\"protected\"\n"
264 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
265 " \t>\n"
266 " </Field>\n"
267 "</FieldContainer>\n",
271 /*------------------------------ get -----------------------------------*/
273 FieldContainerType &KeySensorBase::getType(void)
275 return _type;
278 const FieldContainerType &KeySensorBase::getType(void) const
280 return _type;
283 UInt32 KeySensorBase::getContainerSize(void) const
285 return sizeof(KeySensor);
288 /*------------------------- decorator get ------------------------------*/
291 SFString *KeySensorBase::editSFKey(void)
293 editSField(KeyFieldMask);
295 return &_sfKey;
298 const SFString *KeySensorBase::getSFKey(void) const
300 return &_sfKey;
304 SFBool *KeySensorBase::editSFStateRaw(void)
306 editSField(StateRawFieldMask);
308 return &_sfStateRaw;
311 const SFBool *KeySensorBase::getSFStateRaw(void) const
313 return &_sfStateRaw;
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();
387 return returnValue;
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);
462 return fc;
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);
478 return fc;
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;
495 return returnValue;
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
508 KeySensor *tmpPtr;
510 newPtr(tmpPtr, dynamic_cast<const KeySensor *>(this), bFlags);
512 FieldContainerTransitPtr returnValue(tmpPtr);
514 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
516 return returnValue;
519 FieldContainerTransitPtr KeySensorBase::shallowCopyDependent(
520 BitVector bFlags) const
522 KeySensor *tmpPtr;
524 newPtr(tmpPtr, dynamic_cast<const KeySensor *>(this), ~bFlags);
526 FieldContainerTransitPtr returnValue(tmpPtr);
528 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
530 return returnValue;
533 FieldContainerTransitPtr KeySensorBase::shallowCopy(void) const
535 return shallowCopyLocal();
541 /*------------------------- constructors ----------------------------------*/
543 KeySensorBase::KeySensorBase(void) :
544 Inherited(),
545 _sfKey (),
546 _sfStateRaw (bool(true)),
547 _sfStateFlipFlop (bool(false)),
548 _sfSignalPressed (),
549 _sfSignalReleased ()
553 KeySensorBase::KeySensorBase(const KeySensorBase &source) :
554 Inherited(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(
575 &_sfKey,
576 this->getType().getFieldDesc(KeyFieldId),
577 const_cast<KeySensorBase *>(this)));
579 return returnValue;
582 EditFieldHandlePtr KeySensorBase::editHandleKey (void)
584 SFString::EditHandlePtr returnValue(
585 new SFString::EditHandle(
586 &_sfKey,
587 this->getType().getFieldDesc(KeyFieldId),
588 this));
591 editSField(KeyFieldMask);
593 return returnValue;
596 GetFieldHandlePtr KeySensorBase::getHandleStateRaw (void) const
598 SFBool::GetHandlePtr returnValue(
599 new SFBool::GetHandle(
600 &_sfStateRaw,
601 this->getType().getFieldDesc(StateRawFieldId),
602 const_cast<KeySensorBase *>(this)));
604 return returnValue;
607 EditFieldHandlePtr KeySensorBase::editHandleStateRaw (void)
609 SFBool::EditHandlePtr returnValue(
610 new SFBool::EditHandle(
611 &_sfStateRaw,
612 this->getType().getFieldDesc(StateRawFieldId),
613 this));
616 editSField(StateRawFieldMask);
618 return returnValue;
621 GetFieldHandlePtr KeySensorBase::getHandleStateFlipFlop (void) const
623 SFBool::GetHandlePtr returnValue(
624 new SFBool::GetHandle(
625 &_sfStateFlipFlop,
626 this->getType().getFieldDesc(StateFlipFlopFieldId),
627 const_cast<KeySensorBase *>(this)));
629 return returnValue;
632 EditFieldHandlePtr KeySensorBase::editHandleStateFlipFlop (void)
634 SFBool::EditHandlePtr returnValue(
635 new SFBool::EditHandle(
636 &_sfStateFlipFlop,
637 this->getType().getFieldDesc(StateFlipFlopFieldId),
638 this));
641 editSField(StateFlipFlopFieldMask);
643 return returnValue;
646 GetFieldHandlePtr KeySensorBase::getHandleSignalPressed (void) const
648 SFOSGAny::GetHandlePtr returnValue(
649 new SFOSGAny::GetHandle(
650 &_sfSignalPressed,
651 this->getType().getFieldDesc(SignalPressedFieldId),
652 const_cast<KeySensorBase *>(this)));
654 return returnValue;
657 EditFieldHandlePtr KeySensorBase::editHandleSignalPressed (void)
659 SFOSGAny::EditHandlePtr returnValue(
660 new SFOSGAny::EditHandle(
661 &_sfSignalPressed,
662 this->getType().getFieldDesc(SignalPressedFieldId),
663 this));
666 editSField(SignalPressedFieldMask);
668 return returnValue;
671 GetFieldHandlePtr KeySensorBase::getHandleSignalReleased (void) const
673 SFOSGAny::GetHandlePtr returnValue(
674 new SFOSGAny::GetHandle(
675 &_sfSignalReleased,
676 this->getType().getFieldDesc(SignalReleasedFieldId),
677 const_cast<KeySensorBase *>(this)));
679 return returnValue;
682 EditFieldHandlePtr KeySensorBase::editHandleSignalReleased (void)
684 SFOSGAny::EditHandlePtr returnValue(
685 new SFOSGAny::EditHandle(
686 &_sfSignalReleased,
687 this->getType().getFieldDesc(SignalReleasedFieldId),
688 this));
691 editSField(SignalReleasedFieldMask);
693 return returnValue;
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),
707 whichField,
708 oOffsets,
709 syncMode,
710 uiSyncInfo);
712 #endif
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));
725 return returnValue;
727 #endif
729 void KeySensorBase::resolveLinks(void)
731 Inherited::resolveLinks();
737 OSG_END_NAMESPACE