fixed: gcc8 compile issues
[opensg.git] / Source / Contrib / ComplexSceneManager / OSGCSMDrawerBase.cpp
blob79ce8f9f065b15140d4f35cf64d2e1f0efe2ad38
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 CSMDrawer!
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 "OSGCSMWindow.h" // Windows Class
67 #include "OSGCSMDrawerBase.h"
68 #include "OSGCSMDrawer.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::CSMDrawer
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var CSMWindow * CSMDrawerBase::_mfWindows
90 /*! \var std::string CSMDrawerBase::_sfDisplayString
94 /*! \var AspectId CSMDrawerBase::_sfAspect
99 /***************************************************************************\
100 * FieldType/FieldTrait Instantiation *
101 \***************************************************************************/
103 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
104 PointerType FieldTraits<CSMDrawer *, nsOSG>::_type(
105 "CSMDrawerPtr",
106 "AttachmentContainerPtr",
107 CSMDrawer::getClassType(),
108 nsOSG);
109 #endif
111 OSG_FIELDTRAITS_GETTYPE_NS(CSMDrawer *, nsOSG)
113 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
114 CSMDrawer *,
115 nsOSG)
117 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
118 CSMDrawer *,
119 nsOSG)
121 DataType &FieldTraits<CSMDrawer *, nsOSG + 1 >::getType(void)
123 return FieldTraits<CSMDrawer *, nsOSG>::getType();
127 OSG_SFIELDTYPE_INST(ParentPointerSField,
128 CSMDrawer *,
129 NoRefCountPolicy,
130 nsOSG + 1);
132 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField,
133 CSMDrawer *,
134 NoRefCountPolicy,
135 nsOSG + 1)
138 /***************************************************************************\
139 * Field Description *
140 \***************************************************************************/
142 void CSMDrawerBase::classDescInserter(TypeObject &oType)
144 FieldDescriptionBase *pDesc = NULL;
147 pDesc = new MFUnrecChildCSMWindowPtr::Description(
148 MFUnrecChildCSMWindowPtr::getClassType(),
149 "windows",
151 WindowsFieldId, WindowsFieldMask,
152 false,
153 (Field::MFDefaultFlags | Field::FStdAccess),
154 static_cast<FieldEditMethodSig>(&CSMDrawer::editHandleWindows),
155 static_cast<FieldGetMethodSig >(&CSMDrawer::getHandleWindows));
157 oType.addInitialDesc(pDesc);
159 pDesc = new SFString::Description(
160 SFString::getClassType(),
161 "displayString",
163 DisplayStringFieldId, DisplayStringFieldMask,
164 true,
165 (Field::SFDefaultFlags | Field::FStdAccess),
166 static_cast<FieldEditMethodSig>(&CSMDrawer::editHandleDisplayString),
167 static_cast<FieldGetMethodSig >(&CSMDrawer::getHandleDisplayString));
169 oType.addInitialDesc(pDesc);
171 pDesc = new SFAspectId::Description(
172 SFAspectId::getClassType(),
173 "aspect",
175 AspectFieldId, AspectFieldMask,
176 false,
177 (Field::SFDefaultFlags | Field::FStdAccess),
178 static_cast<FieldEditMethodSig>(&CSMDrawer::editHandleAspect),
179 static_cast<FieldGetMethodSig >(&CSMDrawer::getHandleAspect));
181 oType.addInitialDesc(pDesc);
185 CSMDrawerBase::TypeObject CSMDrawerBase::_type(
186 CSMDrawerBase::getClassname(),
187 Inherited::getClassname(),
188 "NULL",
189 nsOSG, //Namespace
190 reinterpret_cast<PrototypeCreateF>(&CSMDrawerBase::createEmptyLocal),
191 reinterpret_cast<InitContainerF>(&CSMDrawer::initMethod),
192 reinterpret_cast<ExitContainerF>(&CSMDrawer::exitMethod),
193 reinterpret_cast<InitalInsertDescFunc>(&CSMDrawer::classDescInserter),
194 false,
196 "<?xml version=\"1.0\"?>\n"
197 "\n"
198 "<FieldContainer\n"
199 " name=\"CSMDrawer\"\n"
200 " parent=\"AttachmentContainer\"\n"
201 " library=\"ContribCSM\"\n"
202 " pointerfieldtypes=\"both\"\n"
203 " structure=\"concrete\"\n"
204 " systemcomponent=\"true\"\n"
205 " parentsystemcomponent=\"true\"\n"
206 " decoratable=\"false\"\n"
207 " useLocalIncludes=\"false\"\n"
208 " isNodeCore=\"false\"\n"
209 " isBundle=\"true\"\n"
210 " parentFields=\"single\"\n"
211 ">\n"
212 "\t<Field\n"
213 "\t\tname=\"windows\"\n"
214 "\t\ttype=\"CSMWindow\"\n"
215 "\t\tcardinality=\"multi\"\n"
216 "\t\tvisibility=\"external\"\n"
217 "\t\taccess=\"public\"\n"
218 " category=\"childpointer\"\n"
219 " childParentType=\"CSMDrawer\"\n"
220 " linkParentField=\"Parent\"\n"
221 "\t>\n"
222 "\t</Field>\n"
223 "\t<Field\n"
224 "\t\tname=\"displayString\"\n"
225 "\t\ttype=\"std::string\"\n"
226 "\t\tcardinality=\"single\"\n"
227 "\t\tvisibility=\"internal\"\n"
228 "\t\taccess=\"public\"\n"
229 "\t>\n"
230 "\t</Field>\n"
231 " <Field\n"
232 " name=\"aspect\"\n"
233 " type=\"AspectId\"\n"
234 " cardinality=\"single\"\n"
235 " visibility=\"external\"\n"
236 " access=\"public\"\n"
237 " defaultValue=\"1\"\n"
238 " >\n"
239 " </Field>\n"
240 "</FieldContainer>\n",
244 /*------------------------------ get -----------------------------------*/
246 FieldContainerType &CSMDrawerBase::getType(void)
248 return _type;
251 const FieldContainerType &CSMDrawerBase::getType(void) const
253 return _type;
256 UInt32 CSMDrawerBase::getContainerSize(void) const
258 return sizeof(CSMDrawer);
261 /*------------------------- decorator get ------------------------------*/
264 //! Get the CSMDrawer::_mfWindows field.
265 const MFUnrecChildCSMWindowPtr *CSMDrawerBase::getMFWindows(void) const
267 return &_mfWindows;
270 MFUnrecChildCSMWindowPtr *CSMDrawerBase::editMFWindows (void)
272 editMField(WindowsFieldMask, _mfWindows);
274 return &_mfWindows;
276 CSMWindow * CSMDrawerBase::getWindows(const UInt32 index) const
278 return _mfWindows[index];
281 SFString *CSMDrawerBase::editSFDisplayString(void)
283 editSField(DisplayStringFieldMask);
285 return &_sfDisplayString;
288 const SFString *CSMDrawerBase::getSFDisplayString(void) const
290 return &_sfDisplayString;
294 SFAspectId *CSMDrawerBase::editSFAspect(void)
296 editSField(AspectFieldMask);
298 return &_sfAspect;
301 const SFAspectId *CSMDrawerBase::getSFAspect(void) const
303 return &_sfAspect;
309 void CSMDrawerBase::pushToWindows(CSMWindow * const value)
311 editMField(WindowsFieldMask, _mfWindows);
313 _mfWindows.push_back(value);
316 void CSMDrawerBase::assignWindows (const MFUnrecChildCSMWindowPtr &value)
318 MFUnrecChildCSMWindowPtr::const_iterator elemIt =
319 value.begin();
320 MFUnrecChildCSMWindowPtr::const_iterator elemEnd =
321 value.end ();
323 static_cast<CSMDrawer *>(this)->clearWindows();
325 while(elemIt != elemEnd)
327 this->pushToWindows(*elemIt);
329 ++elemIt;
333 void CSMDrawerBase::removeFromWindows(UInt32 uiIndex)
335 if(uiIndex < _mfWindows.size())
337 editMField(WindowsFieldMask, _mfWindows);
339 _mfWindows.erase(uiIndex);
343 void CSMDrawerBase::removeObjFromWindows(CSMWindow * const value)
345 Int32 iElemIdx = _mfWindows.findIndex(value);
347 if(iElemIdx != -1)
349 editMField(WindowsFieldMask, _mfWindows);
351 _mfWindows.erase(iElemIdx);
354 void CSMDrawerBase::clearWindows(void)
356 editMField(WindowsFieldMask, _mfWindows);
359 _mfWindows.clear();
364 /*------------------------------ access -----------------------------------*/
366 SizeT CSMDrawerBase::getBinSize(ConstFieldMaskArg whichField)
368 SizeT returnValue = Inherited::getBinSize(whichField);
370 if(FieldBits::NoField != (WindowsFieldMask & whichField))
372 returnValue += _mfWindows.getBinSize();
374 if(FieldBits::NoField != (DisplayStringFieldMask & whichField))
376 returnValue += _sfDisplayString.getBinSize();
378 if(FieldBits::NoField != (AspectFieldMask & whichField))
380 returnValue += _sfAspect.getBinSize();
383 return returnValue;
386 void CSMDrawerBase::copyToBin(BinaryDataHandler &pMem,
387 ConstFieldMaskArg whichField)
389 Inherited::copyToBin(pMem, whichField);
391 if(FieldBits::NoField != (WindowsFieldMask & whichField))
393 _mfWindows.copyToBin(pMem);
395 if(FieldBits::NoField != (DisplayStringFieldMask & whichField))
397 _sfDisplayString.copyToBin(pMem);
399 if(FieldBits::NoField != (AspectFieldMask & whichField))
401 _sfAspect.copyToBin(pMem);
405 void CSMDrawerBase::copyFromBin(BinaryDataHandler &pMem,
406 ConstFieldMaskArg whichField)
408 Inherited::copyFromBin(pMem, whichField);
410 if(FieldBits::NoField != (WindowsFieldMask & whichField))
412 editMField(WindowsFieldMask, _mfWindows);
413 _mfWindows.copyFromBin(pMem);
415 if(FieldBits::NoField != (DisplayStringFieldMask & whichField))
417 editSField(DisplayStringFieldMask);
418 _sfDisplayString.copyFromBin(pMem);
420 if(FieldBits::NoField != (AspectFieldMask & whichField))
422 editSField(AspectFieldMask);
423 _sfAspect.copyFromBin(pMem);
427 //! create a new instance of the class
428 CSMDrawerTransitPtr CSMDrawerBase::createLocal(BitVector bFlags)
430 CSMDrawerTransitPtr fc;
432 if(getClassType().getPrototype() != NULL)
434 FieldContainerTransitPtr tmpPtr =
435 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
437 fc = dynamic_pointer_cast<CSMDrawer>(tmpPtr);
440 return fc;
443 //! create a new instance of the class, copy the container flags
444 CSMDrawerTransitPtr CSMDrawerBase::createDependent(BitVector bFlags)
446 CSMDrawerTransitPtr fc;
448 if(getClassType().getPrototype() != NULL)
450 FieldContainerTransitPtr tmpPtr =
451 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
453 fc = dynamic_pointer_cast<CSMDrawer>(tmpPtr);
456 return fc;
459 //! create a new instance of the class
460 CSMDrawerTransitPtr CSMDrawerBase::create(void)
462 return createLocal();
465 CSMDrawer *CSMDrawerBase::createEmptyLocal(BitVector bFlags)
467 CSMDrawer *returnValue;
469 newPtr<CSMDrawer>(returnValue, bFlags);
471 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
473 return returnValue;
476 //! create an empty new instance of the class, do not copy the prototype
477 CSMDrawer *CSMDrawerBase::createEmpty(void)
479 return createEmptyLocal();
483 FieldContainerTransitPtr CSMDrawerBase::shallowCopyLocal(
484 BitVector bFlags) const
486 CSMDrawer *tmpPtr;
488 newPtr(tmpPtr, dynamic_cast<const CSMDrawer *>(this), bFlags);
490 FieldContainerTransitPtr returnValue(tmpPtr);
492 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
494 return returnValue;
497 FieldContainerTransitPtr CSMDrawerBase::shallowCopyDependent(
498 BitVector bFlags) const
500 CSMDrawer *tmpPtr;
502 newPtr(tmpPtr, dynamic_cast<const CSMDrawer *>(this), ~bFlags);
504 FieldContainerTransitPtr returnValue(tmpPtr);
506 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
508 return returnValue;
511 FieldContainerTransitPtr CSMDrawerBase::shallowCopy(void) const
513 return shallowCopyLocal();
519 /*------------------------- constructors ----------------------------------*/
521 CSMDrawerBase::CSMDrawerBase(void) :
522 Inherited(),
523 _mfWindows (this,
524 WindowsFieldId,
525 CSMWindow::ParentFieldId),
526 _sfDisplayString (),
527 _sfAspect (AspectId(1))
531 CSMDrawerBase::CSMDrawerBase(const CSMDrawerBase &source) :
532 Inherited(source),
533 _mfWindows (this,
534 WindowsFieldId,
535 CSMWindow::ParentFieldId),
536 _sfDisplayString (source._sfDisplayString ),
537 _sfAspect (source._sfAspect )
542 /*-------------------------- destructors ----------------------------------*/
544 CSMDrawerBase::~CSMDrawerBase(void)
548 /*-------------------------------------------------------------------------*/
549 /* Child linking */
551 bool CSMDrawerBase::unlinkChild(
552 FieldContainer * const pChild,
553 UInt16 const childFieldId)
555 if(childFieldId == WindowsFieldId)
557 CSMWindow * pTypedChild =
558 dynamic_cast<CSMWindow *>(pChild);
560 if(pTypedChild != NULL)
562 Int32 iChildIdx = _mfWindows.findIndex(pTypedChild);
564 if(iChildIdx != -1)
566 editMField(WindowsFieldMask, _mfWindows);
568 _mfWindows.erase(iChildIdx);
570 return true;
573 SWARNING << "Parent ([" << this
574 << "] id [" << this->getId()
575 << "] type [" << this->getType().getCName()
576 << "] childFieldId [" << childFieldId
577 << "]) - Child ([" << pChild
578 << "] id [" << pChild->getId()
579 << "] type [" << pChild->getType().getCName()
580 << "]): link inconsistent!"
581 << std::endl;
583 return false;
586 return false;
590 return Inherited::unlinkChild(pChild, childFieldId);
593 void CSMDrawerBase::onCreate(const CSMDrawer *source)
595 Inherited::onCreate(source);
597 if(source != NULL)
599 CSMDrawer *pThis = static_cast<CSMDrawer *>(this);
601 MFUnrecChildCSMWindowPtr::const_iterator WindowsIt =
602 source->_mfWindows.begin();
603 MFUnrecChildCSMWindowPtr::const_iterator WindowsEnd =
604 source->_mfWindows.end ();
606 while(WindowsIt != WindowsEnd)
608 pThis->pushToWindows(*WindowsIt);
610 ++WindowsIt;
615 GetFieldHandlePtr CSMDrawerBase::getHandleWindows (void) const
617 MFUnrecChildCSMWindowPtr::GetHandlePtr returnValue(
618 new MFUnrecChildCSMWindowPtr::GetHandle(
619 &_mfWindows,
620 this->getType().getFieldDesc(WindowsFieldId),
621 const_cast<CSMDrawerBase *>(this)));
623 return returnValue;
626 EditFieldHandlePtr CSMDrawerBase::editHandleWindows (void)
628 MFUnrecChildCSMWindowPtr::EditHandlePtr returnValue(
629 new MFUnrecChildCSMWindowPtr::EditHandle(
630 &_mfWindows,
631 this->getType().getFieldDesc(WindowsFieldId),
632 this));
634 returnValue->setAddMethod(
635 boost::bind(&CSMDrawer::pushToWindows,
636 static_cast<CSMDrawer *>(this), _1));
637 returnValue->setRemoveMethod(
638 boost::bind(&CSMDrawer::removeFromWindows,
639 static_cast<CSMDrawer *>(this), _1));
640 returnValue->setRemoveObjMethod(
641 boost::bind(&CSMDrawer::removeObjFromWindows,
642 static_cast<CSMDrawer *>(this), _1));
643 returnValue->setClearMethod(
644 boost::bind(&CSMDrawer::clearWindows,
645 static_cast<CSMDrawer *>(this)));
647 editMField(WindowsFieldMask, _mfWindows);
649 return returnValue;
652 GetFieldHandlePtr CSMDrawerBase::getHandleDisplayString (void) const
654 SFString::GetHandlePtr returnValue(
655 new SFString::GetHandle(
656 &_sfDisplayString,
657 this->getType().getFieldDesc(DisplayStringFieldId),
658 const_cast<CSMDrawerBase *>(this)));
660 return returnValue;
663 EditFieldHandlePtr CSMDrawerBase::editHandleDisplayString (void)
665 SFString::EditHandlePtr returnValue(
666 new SFString::EditHandle(
667 &_sfDisplayString,
668 this->getType().getFieldDesc(DisplayStringFieldId),
669 this));
672 editSField(DisplayStringFieldMask);
674 return returnValue;
677 GetFieldHandlePtr CSMDrawerBase::getHandleAspect (void) const
679 SFAspectId::GetHandlePtr returnValue(
680 new SFAspectId::GetHandle(
681 &_sfAspect,
682 this->getType().getFieldDesc(AspectFieldId),
683 const_cast<CSMDrawerBase *>(this)));
685 return returnValue;
688 EditFieldHandlePtr CSMDrawerBase::editHandleAspect (void)
690 SFAspectId::EditHandlePtr returnValue(
691 new SFAspectId::EditHandle(
692 &_sfAspect,
693 this->getType().getFieldDesc(AspectFieldId),
694 this));
697 editSField(AspectFieldMask);
699 return returnValue;
703 #ifdef OSG_MT_CPTR_ASPECT
704 void CSMDrawerBase::execSyncV( FieldContainer &oFrom,
705 ConstFieldMaskArg whichField,
706 AspectOffsetStore &oOffsets,
707 ConstFieldMaskArg syncMode,
708 const UInt32 uiSyncInfo)
710 CSMDrawer *pThis = static_cast<CSMDrawer *>(this);
712 pThis->execSync(static_cast<CSMDrawer *>(&oFrom),
713 whichField,
714 oOffsets,
715 syncMode,
716 uiSyncInfo);
718 #endif
721 #ifdef OSG_MT_CPTR_ASPECT
722 FieldContainer *CSMDrawerBase::createAspectCopy(
723 const FieldContainer *pRefAspect) const
725 CSMDrawer *returnValue;
727 newAspectCopy(returnValue,
728 dynamic_cast<const CSMDrawer *>(pRefAspect),
729 dynamic_cast<const CSMDrawer *>(this));
731 return returnValue;
733 #endif
735 void CSMDrawerBase::resolveLinks(void)
737 Inherited::resolveLinks();
739 static_cast<CSMDrawer *>(this)->clearWindows();
745 OSG_END_NAMESPACE