fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Contrib / ComplexSceneManager / OSGCSMDrawerBase.cpp
blobdccfe7efb32bf5e97839ed19929b3b6f73f9fbca
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>(
194 reinterpret_cast<void *>(&CSMDrawer::classDescInserter)),
195 false,
197 "<?xml version=\"1.0\"?>\n"
198 "\n"
199 "<FieldContainer\n"
200 " name=\"CSMDrawer\"\n"
201 " parent=\"AttachmentContainer\"\n"
202 " library=\"ContribCSM\"\n"
203 " pointerfieldtypes=\"both\"\n"
204 " structure=\"concrete\"\n"
205 " systemcomponent=\"true\"\n"
206 " parentsystemcomponent=\"true\"\n"
207 " decoratable=\"false\"\n"
208 " useLocalIncludes=\"false\"\n"
209 " isNodeCore=\"false\"\n"
210 " isBundle=\"true\"\n"
211 " parentFields=\"single\"\n"
212 ">\n"
213 "\t<Field\n"
214 "\t\tname=\"windows\"\n"
215 "\t\ttype=\"CSMWindow\"\n"
216 "\t\tcardinality=\"multi\"\n"
217 "\t\tvisibility=\"external\"\n"
218 "\t\taccess=\"public\"\n"
219 " category=\"childpointer\"\n"
220 " childParentType=\"CSMDrawer\"\n"
221 " linkParentField=\"Parent\"\n"
222 "\t>\n"
223 "\t</Field>\n"
224 "\t<Field\n"
225 "\t\tname=\"displayString\"\n"
226 "\t\ttype=\"std::string\"\n"
227 "\t\tcardinality=\"single\"\n"
228 "\t\tvisibility=\"internal\"\n"
229 "\t\taccess=\"public\"\n"
230 "\t>\n"
231 "\t</Field>\n"
232 " <Field\n"
233 " name=\"aspect\"\n"
234 " type=\"AspectId\"\n"
235 " cardinality=\"single\"\n"
236 " visibility=\"external\"\n"
237 " access=\"public\"\n"
238 " defaultValue=\"1\"\n"
239 " >\n"
240 " </Field>\n"
241 "</FieldContainer>\n",
245 /*------------------------------ get -----------------------------------*/
247 FieldContainerType &CSMDrawerBase::getType(void)
249 return _type;
252 const FieldContainerType &CSMDrawerBase::getType(void) const
254 return _type;
257 UInt32 CSMDrawerBase::getContainerSize(void) const
259 return sizeof(CSMDrawer);
262 /*------------------------- decorator get ------------------------------*/
265 //! Get the CSMDrawer::_mfWindows field.
266 const MFUnrecChildCSMWindowPtr *CSMDrawerBase::getMFWindows(void) const
268 return &_mfWindows;
271 MFUnrecChildCSMWindowPtr *CSMDrawerBase::editMFWindows (void)
273 editMField(WindowsFieldMask, _mfWindows);
275 return &_mfWindows;
277 CSMWindow * CSMDrawerBase::getWindows(const UInt32 index) const
279 return _mfWindows[index];
282 SFString *CSMDrawerBase::editSFDisplayString(void)
284 editSField(DisplayStringFieldMask);
286 return &_sfDisplayString;
289 const SFString *CSMDrawerBase::getSFDisplayString(void) const
291 return &_sfDisplayString;
295 SFAspectId *CSMDrawerBase::editSFAspect(void)
297 editSField(AspectFieldMask);
299 return &_sfAspect;
302 const SFAspectId *CSMDrawerBase::getSFAspect(void) const
304 return &_sfAspect;
310 void CSMDrawerBase::pushToWindows(CSMWindow * const value)
312 editMField(WindowsFieldMask, _mfWindows);
314 _mfWindows.push_back(value);
317 void CSMDrawerBase::assignWindows (const MFUnrecChildCSMWindowPtr &value)
319 MFUnrecChildCSMWindowPtr::const_iterator elemIt =
320 value.begin();
321 MFUnrecChildCSMWindowPtr::const_iterator elemEnd =
322 value.end ();
324 static_cast<CSMDrawer *>(this)->clearWindows();
326 while(elemIt != elemEnd)
328 this->pushToWindows(*elemIt);
330 ++elemIt;
334 void CSMDrawerBase::removeFromWindows(UInt32 uiIndex)
336 if(uiIndex < _mfWindows.size())
338 editMField(WindowsFieldMask, _mfWindows);
340 _mfWindows.erase(uiIndex);
344 void CSMDrawerBase::removeObjFromWindows(CSMWindow * const value)
346 Int32 iElemIdx = _mfWindows.findIndex(value);
348 if(iElemIdx != -1)
350 editMField(WindowsFieldMask, _mfWindows);
352 _mfWindows.erase(iElemIdx);
355 void CSMDrawerBase::clearWindows(void)
357 editMField(WindowsFieldMask, _mfWindows);
360 _mfWindows.clear();
365 /*------------------------------ access -----------------------------------*/
367 SizeT CSMDrawerBase::getBinSize(ConstFieldMaskArg whichField)
369 SizeT returnValue = Inherited::getBinSize(whichField);
371 if(FieldBits::NoField != (WindowsFieldMask & whichField))
373 returnValue += _mfWindows.getBinSize();
375 if(FieldBits::NoField != (DisplayStringFieldMask & whichField))
377 returnValue += _sfDisplayString.getBinSize();
379 if(FieldBits::NoField != (AspectFieldMask & whichField))
381 returnValue += _sfAspect.getBinSize();
384 return returnValue;
387 void CSMDrawerBase::copyToBin(BinaryDataHandler &pMem,
388 ConstFieldMaskArg whichField)
390 Inherited::copyToBin(pMem, whichField);
392 if(FieldBits::NoField != (WindowsFieldMask & whichField))
394 _mfWindows.copyToBin(pMem);
396 if(FieldBits::NoField != (DisplayStringFieldMask & whichField))
398 _sfDisplayString.copyToBin(pMem);
400 if(FieldBits::NoField != (AspectFieldMask & whichField))
402 _sfAspect.copyToBin(pMem);
406 void CSMDrawerBase::copyFromBin(BinaryDataHandler &pMem,
407 ConstFieldMaskArg whichField)
409 Inherited::copyFromBin(pMem, whichField);
411 if(FieldBits::NoField != (WindowsFieldMask & whichField))
413 editMField(WindowsFieldMask, _mfWindows);
414 _mfWindows.copyFromBin(pMem);
416 if(FieldBits::NoField != (DisplayStringFieldMask & whichField))
418 editSField(DisplayStringFieldMask);
419 _sfDisplayString.copyFromBin(pMem);
421 if(FieldBits::NoField != (AspectFieldMask & whichField))
423 editSField(AspectFieldMask);
424 _sfAspect.copyFromBin(pMem);
428 //! create a new instance of the class
429 CSMDrawerTransitPtr CSMDrawerBase::createLocal(BitVector bFlags)
431 CSMDrawerTransitPtr fc;
433 if(getClassType().getPrototype() != NULL)
435 FieldContainerTransitPtr tmpPtr =
436 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
438 fc = dynamic_pointer_cast<CSMDrawer>(tmpPtr);
441 return fc;
444 //! create a new instance of the class, copy the container flags
445 CSMDrawerTransitPtr CSMDrawerBase::createDependent(BitVector bFlags)
447 CSMDrawerTransitPtr fc;
449 if(getClassType().getPrototype() != NULL)
451 FieldContainerTransitPtr tmpPtr =
452 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
454 fc = dynamic_pointer_cast<CSMDrawer>(tmpPtr);
457 return fc;
460 //! create a new instance of the class
461 CSMDrawerTransitPtr CSMDrawerBase::create(void)
463 return createLocal();
466 CSMDrawer *CSMDrawerBase::createEmptyLocal(BitVector bFlags)
468 CSMDrawer *returnValue;
470 newPtr<CSMDrawer>(returnValue, bFlags);
472 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
474 return returnValue;
477 //! create an empty new instance of the class, do not copy the prototype
478 CSMDrawer *CSMDrawerBase::createEmpty(void)
480 return createEmptyLocal();
484 FieldContainerTransitPtr CSMDrawerBase::shallowCopyLocal(
485 BitVector bFlags) const
487 CSMDrawer *tmpPtr;
489 newPtr(tmpPtr, dynamic_cast<const CSMDrawer *>(this), bFlags);
491 FieldContainerTransitPtr returnValue(tmpPtr);
493 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
495 return returnValue;
498 FieldContainerTransitPtr CSMDrawerBase::shallowCopyDependent(
499 BitVector bFlags) const
501 CSMDrawer *tmpPtr;
503 newPtr(tmpPtr, dynamic_cast<const CSMDrawer *>(this), ~bFlags);
505 FieldContainerTransitPtr returnValue(tmpPtr);
507 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
509 return returnValue;
512 FieldContainerTransitPtr CSMDrawerBase::shallowCopy(void) const
514 return shallowCopyLocal();
520 /*------------------------- constructors ----------------------------------*/
522 CSMDrawerBase::CSMDrawerBase(void) :
523 Inherited(),
524 _mfWindows (this,
525 WindowsFieldId,
526 CSMWindow::ParentFieldId),
527 _sfDisplayString (),
528 _sfAspect (AspectId(1))
532 CSMDrawerBase::CSMDrawerBase(const CSMDrawerBase &source) :
533 Inherited(source),
534 _mfWindows (this,
535 WindowsFieldId,
536 CSMWindow::ParentFieldId),
537 _sfDisplayString (source._sfDisplayString ),
538 _sfAspect (source._sfAspect )
543 /*-------------------------- destructors ----------------------------------*/
545 CSMDrawerBase::~CSMDrawerBase(void)
549 /*-------------------------------------------------------------------------*/
550 /* Child linking */
552 bool CSMDrawerBase::unlinkChild(
553 FieldContainer * const pChild,
554 UInt16 const childFieldId)
556 if(childFieldId == WindowsFieldId)
558 CSMWindow * pTypedChild =
559 dynamic_cast<CSMWindow *>(pChild);
561 if(pTypedChild != NULL)
563 Int32 iChildIdx = _mfWindows.findIndex(pTypedChild);
565 if(iChildIdx != -1)
567 editMField(WindowsFieldMask, _mfWindows);
569 _mfWindows.erase(iChildIdx);
571 return true;
574 SWARNING << "Parent ([" << this
575 << "] id [" << this->getId()
576 << "] type [" << this->getType().getCName()
577 << "] childFieldId [" << childFieldId
578 << "]) - Child ([" << pChild
579 << "] id [" << pChild->getId()
580 << "] type [" << pChild->getType().getCName()
581 << "]): link inconsistent!"
582 << std::endl;
584 return false;
587 return false;
591 return Inherited::unlinkChild(pChild, childFieldId);
594 void CSMDrawerBase::onCreate(const CSMDrawer *source)
596 Inherited::onCreate(source);
598 if(source != NULL)
600 CSMDrawer *pThis = static_cast<CSMDrawer *>(this);
602 MFUnrecChildCSMWindowPtr::const_iterator WindowsIt =
603 source->_mfWindows.begin();
604 MFUnrecChildCSMWindowPtr::const_iterator WindowsEnd =
605 source->_mfWindows.end ();
607 while(WindowsIt != WindowsEnd)
609 pThis->pushToWindows(*WindowsIt);
611 ++WindowsIt;
616 GetFieldHandlePtr CSMDrawerBase::getHandleWindows (void) const
618 MFUnrecChildCSMWindowPtr::GetHandlePtr returnValue(
619 new MFUnrecChildCSMWindowPtr::GetHandle(
620 &_mfWindows,
621 this->getType().getFieldDesc(WindowsFieldId),
622 const_cast<CSMDrawerBase *>(this)));
624 return returnValue;
627 EditFieldHandlePtr CSMDrawerBase::editHandleWindows (void)
629 MFUnrecChildCSMWindowPtr::EditHandlePtr returnValue(
630 new MFUnrecChildCSMWindowPtr::EditHandle(
631 &_mfWindows,
632 this->getType().getFieldDesc(WindowsFieldId),
633 this));
635 returnValue->setAddMethod(
636 boost::bind(&CSMDrawer::pushToWindows,
637 static_cast<CSMDrawer *>(this), _1));
638 returnValue->setRemoveMethod(
639 boost::bind(&CSMDrawer::removeFromWindows,
640 static_cast<CSMDrawer *>(this), _1));
641 returnValue->setRemoveObjMethod(
642 boost::bind(&CSMDrawer::removeObjFromWindows,
643 static_cast<CSMDrawer *>(this), _1));
644 returnValue->setClearMethod(
645 boost::bind(&CSMDrawer::clearWindows,
646 static_cast<CSMDrawer *>(this)));
648 editMField(WindowsFieldMask, _mfWindows);
650 return returnValue;
653 GetFieldHandlePtr CSMDrawerBase::getHandleDisplayString (void) const
655 SFString::GetHandlePtr returnValue(
656 new SFString::GetHandle(
657 &_sfDisplayString,
658 this->getType().getFieldDesc(DisplayStringFieldId),
659 const_cast<CSMDrawerBase *>(this)));
661 return returnValue;
664 EditFieldHandlePtr CSMDrawerBase::editHandleDisplayString (void)
666 SFString::EditHandlePtr returnValue(
667 new SFString::EditHandle(
668 &_sfDisplayString,
669 this->getType().getFieldDesc(DisplayStringFieldId),
670 this));
673 editSField(DisplayStringFieldMask);
675 return returnValue;
678 GetFieldHandlePtr CSMDrawerBase::getHandleAspect (void) const
680 SFAspectId::GetHandlePtr returnValue(
681 new SFAspectId::GetHandle(
682 &_sfAspect,
683 this->getType().getFieldDesc(AspectFieldId),
684 const_cast<CSMDrawerBase *>(this)));
686 return returnValue;
689 EditFieldHandlePtr CSMDrawerBase::editHandleAspect (void)
691 SFAspectId::EditHandlePtr returnValue(
692 new SFAspectId::EditHandle(
693 &_sfAspect,
694 this->getType().getFieldDesc(AspectFieldId),
695 this));
698 editSField(AspectFieldMask);
700 return returnValue;
704 #ifdef OSG_MT_CPTR_ASPECT
705 void CSMDrawerBase::execSyncV( FieldContainer &oFrom,
706 ConstFieldMaskArg whichField,
707 AspectOffsetStore &oOffsets,
708 ConstFieldMaskArg syncMode,
709 const UInt32 uiSyncInfo)
711 CSMDrawer *pThis = static_cast<CSMDrawer *>(this);
713 pThis->execSync(static_cast<CSMDrawer *>(&oFrom),
714 whichField,
715 oOffsets,
716 syncMode,
717 uiSyncInfo);
719 #endif
722 #ifdef OSG_MT_CPTR_ASPECT
723 FieldContainer *CSMDrawerBase::createAspectCopy(
724 const FieldContainer *pRefAspect) const
726 CSMDrawer *returnValue;
728 newAspectCopy(returnValue,
729 dynamic_cast<const CSMDrawer *>(pRefAspect),
730 dynamic_cast<const CSMDrawer *>(this));
732 return returnValue;
734 #endif
736 void CSMDrawerBase::resolveLinks(void)
738 Inherited::resolveLinks();
740 static_cast<CSMDrawer *>(this)->clearWindows();
746 OSG_END_NAMESPACE