changed: gcc8 base update
[opensg.git] / Source / Contrib / ComplexSceneManager / Sensor / InterfaceSensors / OSGDeviceInterfaceSensorBase.cpp
blob00c691710532d729b4563e4b0eb1f9fcd1c291a6
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 DeviceInterfaceSensor!
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"
65 #include "OSGInterfaceOptions.h" // Options Class
67 #include "OSGDeviceInterfaceSensorBase.h"
68 #include "OSGDeviceInterfaceSensor.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::DeviceInterfaceSensor
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var std::string DeviceInterfaceSensorBase::_sfInterfaceName
90 /*! \var InterfaceOptions * DeviceInterfaceSensorBase::_sfOptions
95 /***************************************************************************\
96 * FieldType/FieldTrait Instantiation *
97 \***************************************************************************/
99 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
100 PointerType FieldTraits<DeviceInterfaceSensor *, nsOSG>::_type(
101 "DeviceInterfaceSensorPtr",
102 "NodeCorePtr",
103 DeviceInterfaceSensor::getClassType(),
104 nsOSG);
105 #endif
107 OSG_FIELDTRAITS_GETTYPE_NS(DeviceInterfaceSensor *, nsOSG)
109 DataType &FieldTraits<DeviceInterfaceSensor *, nsOSG + 1 >::getType(void)
111 return FieldTraits<DeviceInterfaceSensor *, nsOSG>::getType();
115 OSG_SFIELDTYPE_INST(ParentPointerSField,
116 DeviceInterfaceSensor *,
117 NoRefCountPolicy,
118 nsOSG + 1);
120 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField,
121 DeviceInterfaceSensor *,
122 NoRefCountPolicy,
123 nsOSG + 1)
126 /***************************************************************************\
127 * Field Description *
128 \***************************************************************************/
130 void DeviceInterfaceSensorBase::classDescInserter(TypeObject &oType)
132 Inherited::classDescInserter(oType);
134 FieldDescriptionBase *pDesc = NULL;
137 pDesc = new SFString::Description(
138 SFString::getClassType(),
139 "interfaceName",
141 InterfaceNameFieldId, InterfaceNameFieldMask,
142 true,
143 (Field::FStdAccess | Field::FThreadLocal),
144 static_cast<FieldEditMethodSig>(&DeviceInterfaceSensor::editHandleInterfaceName),
145 static_cast<FieldGetMethodSig >(&DeviceInterfaceSensor::getHandleInterfaceName));
147 oType.addInitialDesc(pDesc);
149 pDesc = new SFUnrecChildInterfaceOptionsPtr::Description(
150 SFUnrecChildInterfaceOptionsPtr::getClassType(),
151 "options",
153 OptionsFieldId, OptionsFieldMask,
154 false,
155 (Field::SFDefaultFlags | Field::FStdAccess),
156 static_cast<FieldEditMethodSig>(&DeviceInterfaceSensor::editHandleOptions),
157 static_cast<FieldGetMethodSig >(&DeviceInterfaceSensor::getHandleOptions));
159 oType.addInitialDesc(pDesc);
163 DeviceInterfaceSensorBase::TypeObject DeviceInterfaceSensorBase::_type(
164 DeviceInterfaceSensorBase::getClassname(),
165 Inherited::getClassname(),
166 "NULL",
167 nsOSG, //Namespace
168 NULL,
169 reinterpret_cast<InitContainerF>(&DeviceInterfaceSensor::initMethod),
170 reinterpret_cast<ExitContainerF>(&DeviceInterfaceSensor::exitMethod),
171 reinterpret_cast<InitalInsertDescFunc>(
172 reinterpret_cast<void *>(&DeviceInterfaceSensor::classDescInserter)),
173 false,
175 "<?xml version=\"1.0\"?>\n"
176 "\n"
177 "<FieldContainer\n"
178 " name=\"DeviceInterfaceSensor\"\n"
179 " parent=\"NodeCore\"\n"
180 " mixinparent=\"NodeCoreSensorParent\"\n"
181 " library=\"ContribCSM\"\n"
182 " pointerfieldtypes=\"none\"\n"
183 " structure=\"abstract\"\n"
184 " systemcomponent=\"true\"\n"
185 " parentsystemcomponent=\"true\"\n"
186 " decoratable=\"false\"\n"
187 " useLocalIncludes=\"false\"\n"
188 " isNodeCore=\"false\"\n"
189 " isBundle=\"false\"\n"
190 " parentFields=\"single\"\n"
191 " >\n"
192 " <Field\n"
193 " name=\"interfaceName\"\n"
194 " type=\"std::string\"\n"
195 " cardinality=\"single\"\n"
196 " visibility=\"internal\"\n"
197 " access=\"public\"\n"
198 " defaultValue=\"\"\n"
199 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
200 " >\n"
201 " </Field>\n"
202 " <Field\n"
203 " name=\"options\"\n"
204 " type=\"InterfaceOptions\"\n"
205 " cardinality=\"single\"\n"
206 " visibility=\"external\"\n"
207 " access=\"public\"\n"
208 " category=\"childpointer\"\n"
209 " childParentType=\"DeviceInterfaceSensor\"\n"
210 " linkParentField=\"Parent\"\n"
211 " >\n"
212 " </Field>\n"
213 "</FieldContainer>\n",
217 /*------------------------------ get -----------------------------------*/
219 FieldContainerType &DeviceInterfaceSensorBase::getType(void)
221 return _type;
224 const FieldContainerType &DeviceInterfaceSensorBase::getType(void) const
226 return _type;
229 UInt32 DeviceInterfaceSensorBase::getContainerSize(void) const
231 return sizeof(DeviceInterfaceSensor);
234 /*------------------------- decorator get ------------------------------*/
237 SFString *DeviceInterfaceSensorBase::editSFInterfaceName(void)
239 editSField(InterfaceNameFieldMask);
241 return &_sfInterfaceName;
244 const SFString *DeviceInterfaceSensorBase::getSFInterfaceName(void) const
246 return &_sfInterfaceName;
250 //! Get the DeviceInterfaceSensor::_sfOptions field.
251 const SFUnrecChildInterfaceOptionsPtr *DeviceInterfaceSensorBase::getSFOptions(void) const
253 return &_sfOptions;
256 SFUnrecChildInterfaceOptionsPtr *DeviceInterfaceSensorBase::editSFOptions (void)
258 editSField(OptionsFieldMask);
260 return &_sfOptions;
263 //! Get the value of the DeviceInterfaceSensor::_sfOptions field.
264 InterfaceOptions * DeviceInterfaceSensorBase::getOptions(void) const
266 return _sfOptions.getValue();
269 //! Set the value of the DeviceInterfaceSensor::_sfOptions field.
270 void DeviceInterfaceSensorBase::setOptions(InterfaceOptions * const value)
272 editSField(OptionsFieldMask);
274 _sfOptions.setValue(value);
282 /*------------------------------ access -----------------------------------*/
284 SizeT DeviceInterfaceSensorBase::getBinSize(ConstFieldMaskArg whichField)
286 SizeT returnValue = Inherited::getBinSize(whichField);
288 if(FieldBits::NoField != (InterfaceNameFieldMask & whichField))
290 returnValue += _sfInterfaceName.getBinSize();
292 if(FieldBits::NoField != (OptionsFieldMask & whichField))
294 returnValue += _sfOptions.getBinSize();
297 return returnValue;
300 void DeviceInterfaceSensorBase::copyToBin(BinaryDataHandler &pMem,
301 ConstFieldMaskArg whichField)
303 Inherited::copyToBin(pMem, whichField);
305 if(FieldBits::NoField != (InterfaceNameFieldMask & whichField))
307 _sfInterfaceName.copyToBin(pMem);
309 if(FieldBits::NoField != (OptionsFieldMask & whichField))
311 _sfOptions.copyToBin(pMem);
315 void DeviceInterfaceSensorBase::copyFromBin(BinaryDataHandler &pMem,
316 ConstFieldMaskArg whichField)
318 Inherited::copyFromBin(pMem, whichField);
320 if(FieldBits::NoField != (InterfaceNameFieldMask & whichField))
322 editSField(InterfaceNameFieldMask);
323 _sfInterfaceName.copyFromBin(pMem);
325 if(FieldBits::NoField != (OptionsFieldMask & whichField))
327 editSField(OptionsFieldMask);
328 _sfOptions.copyFromBin(pMem);
335 /*------------------------- constructors ----------------------------------*/
337 DeviceInterfaceSensorBase::DeviceInterfaceSensorBase(void) :
338 Inherited(),
339 _sfInterfaceName (),
340 _sfOptions (this,
341 OptionsFieldId,
342 InterfaceOptions::ParentFieldId)
346 DeviceInterfaceSensorBase::DeviceInterfaceSensorBase(const DeviceInterfaceSensorBase &source) :
347 Inherited(source),
348 _sfInterfaceName (source._sfInterfaceName ),
349 _sfOptions (this,
350 OptionsFieldId,
351 InterfaceOptions::ParentFieldId)
356 /*-------------------------- destructors ----------------------------------*/
358 DeviceInterfaceSensorBase::~DeviceInterfaceSensorBase(void)
362 /*-------------------------------------------------------------------------*/
363 /* Child linking */
365 bool DeviceInterfaceSensorBase::unlinkChild(
366 FieldContainer * const pChild,
367 UInt16 const childFieldId)
369 if(childFieldId == OptionsFieldId)
371 InterfaceOptions * pTypedChild =
372 dynamic_cast<InterfaceOptions *>(pChild);
374 if(pTypedChild != NULL)
376 if(_sfOptions.getValue() == pTypedChild)
378 editSField(OptionsFieldMask);
380 _sfOptions.setValue(NULL);
382 return true;
385 SWARNING << "Parent ([" << this
386 << "] id [" << this->getId()
387 << "] type [" << this->getType().getCName()
388 << "] childFieldId [" << childFieldId
389 << "]) - Child ([" << pChild
390 << "] id [" << pChild->getId()
391 << "] type [" << pChild->getType().getCName()
392 << "]): link inconsistent!"
393 << std::endl;
395 return false;
398 return false;
402 return Inherited::unlinkChild(pChild, childFieldId);
405 void DeviceInterfaceSensorBase::onCreate(const DeviceInterfaceSensor *source)
407 Inherited::onCreate(source);
409 if(source != NULL)
411 DeviceInterfaceSensor *pThis = static_cast<DeviceInterfaceSensor *>(this);
413 pThis->setOptions(source->getOptions());
417 GetFieldHandlePtr DeviceInterfaceSensorBase::getHandleInterfaceName (void) const
419 SFString::GetHandlePtr returnValue(
420 new SFString::GetHandle(
421 &_sfInterfaceName,
422 this->getType().getFieldDesc(InterfaceNameFieldId),
423 const_cast<DeviceInterfaceSensorBase *>(this)));
425 return returnValue;
428 EditFieldHandlePtr DeviceInterfaceSensorBase::editHandleInterfaceName (void)
430 SFString::EditHandlePtr returnValue(
431 new SFString::EditHandle(
432 &_sfInterfaceName,
433 this->getType().getFieldDesc(InterfaceNameFieldId),
434 this));
437 editSField(InterfaceNameFieldMask);
439 return returnValue;
442 GetFieldHandlePtr DeviceInterfaceSensorBase::getHandleOptions (void) const
444 SFUnrecChildInterfaceOptionsPtr::GetHandlePtr returnValue(
445 new SFUnrecChildInterfaceOptionsPtr::GetHandle(
446 &_sfOptions,
447 this->getType().getFieldDesc(OptionsFieldId),
448 const_cast<DeviceInterfaceSensorBase *>(this)));
450 return returnValue;
453 EditFieldHandlePtr DeviceInterfaceSensorBase::editHandleOptions (void)
455 SFUnrecChildInterfaceOptionsPtr::EditHandlePtr returnValue(
456 new SFUnrecChildInterfaceOptionsPtr::EditHandle(
457 &_sfOptions,
458 this->getType().getFieldDesc(OptionsFieldId),
459 this));
461 returnValue->setSetMethod(
462 boost::bind(&DeviceInterfaceSensor::setOptions,
463 static_cast<DeviceInterfaceSensor *>(this), _1));
465 editSField(OptionsFieldMask);
467 return returnValue;
471 #ifdef OSG_MT_CPTR_ASPECT
472 void DeviceInterfaceSensorBase::execSyncV( FieldContainer &oFrom,
473 ConstFieldMaskArg whichField,
474 AspectOffsetStore &oOffsets,
475 ConstFieldMaskArg syncMode,
476 const UInt32 uiSyncInfo)
478 DeviceInterfaceSensor *pThis = static_cast<DeviceInterfaceSensor *>(this);
480 pThis->execSync(static_cast<DeviceInterfaceSensor *>(&oFrom),
481 whichField,
482 oOffsets,
483 syncMode,
484 uiSyncInfo);
486 #endif
490 void DeviceInterfaceSensorBase::resolveLinks(void)
492 Inherited::resolveLinks();
494 static_cast<DeviceInterfaceSensor *>(this)->setOptions(NULL);
500 OSG_END_NAMESPACE