fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Contrib / ComplexSceneManager / Sensor / InterfaceSensors / OSGInterfaceOptionsBase.cpp
blob4cd3759b484aa9077e187b254beb96404127a0c5
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 InterfaceOptions!
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 "OSGDeviceInterfaceSensor.h" // Parent Class
67 #include "OSGInterfaceOptionsBase.h"
68 #include "OSGInterfaceOptions.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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",
106 "FieldContainerPtr",
107 InterfaceOptions::getClassType(),
108 nsOSG);
109 #endif
111 OSG_FIELDTRAITS_GETTYPE_NS(InterfaceOptions *, nsOSG)
113 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
114 InterfaceOptions *,
115 nsOSG)
118 DataType &FieldTraits< InterfaceOptions *, nsOSG + 1 >::getType(void)
120 return FieldTraits<InterfaceOptions *, nsOSG>::getType();
124 OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
125 InterfaceOptions *,
126 UnrecordedRefCountPolicy,
127 nsOSG + 1)
130 /***************************************************************************\
131 * Field Description *
132 \***************************************************************************/
134 void InterfaceOptionsBase::classDescInserter(TypeObject &oType)
136 FieldDescriptionBase *pDesc = NULL;
139 pDesc = new SFParentDeviceInterfaceSensorPtr::Description(
140 SFParentDeviceInterfaceSensorPtr::getClassType(),
141 "parent",
143 ParentFieldId, ParentFieldMask,
144 true,
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(),
153 "napTime",
155 NapTimeFieldId, NapTimeFieldMask,
156 true,
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(),
165 "bufferSize",
167 BufferSizeFieldId, BufferSizeFieldMask,
168 true,
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(),
180 "NULL",
181 nsOSG, //Namespace
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)),
187 false,
189 "<?xml version=\"1.0\"?>\n"
190 "\n"
191 "<FieldContainer\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"
205 " >\n"
206 " <Field\n"
207 " name=\"parent\"\n"
208 " type=\"DeviceInterfaceSensor\"\n"
209 " cardinality=\"single\"\n"
210 " visibility=\"internal\"\n"
211 " access=\"none\"\n"
212 " category=\"parentpointer\"\n"
213 "\t>\n"
214 " </Field>\n"
215 "\n"
216 " <Field\n"
217 " name=\"napTime\"\n"
218 " type=\"UInt32\"\n"
219 " cardinality=\"single\"\n"
220 " visibility=\"internal\"\n"
221 " access=\"public\"\n"
222 " defaultValue=\"10\"\n"
223 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
224 " >\n"
225 " </Field>\n"
226 "\n"
227 " <Field\n"
228 " name=\"bufferSize\"\n"
229 " type=\"UInt32\"\n"
230 " cardinality=\"single\"\n"
231 " visibility=\"internal\"\n"
232 " access=\"public\"\n"
233 " defaultValue=\"128\"\n"
234 " fieldFlags=\"FStdAccess, FThreadLocal\"\n"
235 " >\n"
236 " </Field>\n"
237 "</FieldContainer>\n",
241 /*------------------------------ get -----------------------------------*/
243 FieldContainerType &InterfaceOptionsBase::getType(void)
245 return _type;
248 const FieldContainerType &InterfaceOptionsBase::getType(void) const
250 return _type;
253 UInt32 InterfaceOptionsBase::getContainerSize(void) const
255 return sizeof(InterfaceOptions);
258 /*------------------------- decorator get ------------------------------*/
262 SFUInt32 *InterfaceOptionsBase::editSFNapTime(void)
264 editSField(NapTimeFieldMask);
266 return &_sfNapTime;
269 const SFUInt32 *InterfaceOptionsBase::getSFNapTime(void) const
271 return &_sfNapTime;
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();
311 return returnValue;
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);
368 return fc;
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);
384 return fc;
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;
401 return returnValue;
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;
422 return returnValue;
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;
436 return returnValue;
439 FieldContainerTransitPtr InterfaceOptionsBase::shallowCopy(void) const
441 return shallowCopyLocal();
447 /*------------------------- constructors ----------------------------------*/
449 InterfaceOptionsBase::InterfaceOptionsBase(void) :
450 Inherited(),
451 _sfParent (NULL),
452 _sfNapTime (UInt32(10)),
453 _sfBufferSize (UInt32(128))
457 InterfaceOptionsBase::InterfaceOptionsBase(const InterfaceOptionsBase &source) :
458 Inherited(source),
459 _sfParent (NULL),
460 _sfNapTime (source._sfNapTime ),
461 _sfBufferSize (source._sfBufferSize )
466 /*-------------------------- destructors ----------------------------------*/
468 InterfaceOptionsBase::~InterfaceOptionsBase(void)
471 /*-------------------------------------------------------------------------*/
472 /* Parent linking */
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);
501 return true;
504 return false;
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);
527 return true;
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!"
538 << std::endl;
540 return false;
543 return false;
546 return Inherited::unlinkParent(pParent, parentFieldId);
551 GetFieldHandlePtr InterfaceOptionsBase::getHandleParent (void) const
553 SFParentDeviceInterfaceSensorPtr::GetHandlePtr returnValue;
555 return returnValue;
558 EditFieldHandlePtr InterfaceOptionsBase::editHandleParent (void)
560 EditFieldHandlePtr returnValue;
562 return returnValue;
565 GetFieldHandlePtr InterfaceOptionsBase::getHandleNapTime (void) const
567 SFUInt32::GetHandlePtr returnValue(
568 new SFUInt32::GetHandle(
569 &_sfNapTime,
570 this->getType().getFieldDesc(NapTimeFieldId),
571 const_cast<InterfaceOptionsBase *>(this)));
573 return returnValue;
576 EditFieldHandlePtr InterfaceOptionsBase::editHandleNapTime (void)
578 SFUInt32::EditHandlePtr returnValue(
579 new SFUInt32::EditHandle(
580 &_sfNapTime,
581 this->getType().getFieldDesc(NapTimeFieldId),
582 this));
585 editSField(NapTimeFieldMask);
587 return returnValue;
590 GetFieldHandlePtr InterfaceOptionsBase::getHandleBufferSize (void) const
592 SFUInt32::GetHandlePtr returnValue(
593 new SFUInt32::GetHandle(
594 &_sfBufferSize,
595 this->getType().getFieldDesc(BufferSizeFieldId),
596 const_cast<InterfaceOptionsBase *>(this)));
598 return returnValue;
601 EditFieldHandlePtr InterfaceOptionsBase::editHandleBufferSize (void)
603 SFUInt32::EditHandlePtr returnValue(
604 new SFUInt32::EditHandle(
605 &_sfBufferSize,
606 this->getType().getFieldDesc(BufferSizeFieldId),
607 this));
610 editSField(BufferSizeFieldMask);
612 return returnValue;
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),
626 whichField,
627 oOffsets,
628 syncMode,
629 uiSyncInfo);
631 #endif
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));
644 return returnValue;
646 #endif
648 void InterfaceOptionsBase::resolveLinks(void)
650 Inherited::resolveLinks();
656 OSG_END_NAMESPACE