1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
48 ** class ContainerCollection!
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
65 #include "OSGFieldContainer.h" // Containers Class
67 #include "OSGContainerCollectionBase.h"
68 #include "OSGContainerCollection.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::ContainerCollection
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var std::string ContainerCollectionBase::_sfName
87 The name of the container collection. Can be used to identify collections.
90 /*! \var FieldContainer * ContainerCollectionBase::_mfContainers
91 A list of containers held in the collection.
95 /***************************************************************************\
96 * FieldType/FieldTrait Instantiation *
97 \***************************************************************************/
99 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
100 PointerType FieldTraits
<ContainerCollection
*, nsOSG
>::_type(
101 "ContainerCollectionPtr",
103 ContainerCollection::getClassType(),
107 OSG_FIELDTRAITS_GETTYPE_NS(ContainerCollection
*, nsOSG
)
109 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
110 ContainerCollection
*,
113 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
114 ContainerCollection
*,
117 /***************************************************************************\
118 * Field Description *
119 \***************************************************************************/
121 void ContainerCollectionBase::classDescInserter(TypeObject
&oType
)
123 FieldDescriptionBase
*pDesc
= NULL
;
126 pDesc
= new SFString::Description(
127 SFString::getClassType(),
129 "The name of the container collection. Can be used to identify collections.\n",
130 NameFieldId
, NameFieldMask
,
132 (Field::SFDefaultFlags
| Field::FStdAccess
),
133 static_cast<FieldEditMethodSig
>(&ContainerCollection::editHandleName
),
134 static_cast<FieldGetMethodSig
>(&ContainerCollection::getHandleName
));
136 oType
.addInitialDesc(pDesc
);
138 pDesc
= new MFUnrecFieldContainerPtr::Description(
139 MFUnrecFieldContainerPtr::getClassType(),
141 "A list of containers held in the collection.\n",
142 ContainersFieldId
, ContainersFieldMask
,
144 (Field::MFDefaultFlags
| Field::FStdAccess
),
145 static_cast<FieldEditMethodSig
>(&ContainerCollection::editHandleContainers
),
146 static_cast<FieldGetMethodSig
>(&ContainerCollection::getHandleContainers
));
148 oType
.addInitialDesc(pDesc
);
152 ContainerCollectionBase::TypeObject
ContainerCollectionBase::_type(
153 ContainerCollectionBase::getClassname(),
154 Inherited::getClassname(),
155 "ContainerCollection",
157 reinterpret_cast<PrototypeCreateF
>(&ContainerCollectionBase::createEmptyLocal
),
158 reinterpret_cast<InitContainerF
>(&ContainerCollection::initMethod
),
159 reinterpret_cast<ExitContainerF
>(&ContainerCollection::exitMethod
),
160 reinterpret_cast<InitalInsertDescFunc
>(
161 reinterpret_cast<void *>(&ContainerCollection::classDescInserter
)),
164 "<?xml version=\"1.0\" ?>\n"
167 " name=\"ContainerCollection\"\n"
168 " parent=\"Attachment\"\n"
169 " library=\"System\"\n"
170 " structure=\"concrete\"\n"
171 " pointerfieldtypes=\"both\"\n"
172 " systemcomponent=\"true\"\n"
173 " parentsystemcomponent=\"true\"\n"
174 " docGroupBase=\"GrpSystemFieldContainer\"\n"
178 "\t type=\"std::string\"\n"
179 "\t cardinality=\"single\"\n"
180 "\t visibility=\"external\"\n"
181 "\t access=\"public\"\n"
183 "\tThe name of the container collection. Can be used to identify collections.\n"
186 "\t name=\"containers\"\n"
187 "\t type=\"FieldContainerPtr\"\n"
188 "\t cardinality=\"multi\"\n"
189 "\t visibility=\"external\"\n"
190 " access=\"public\"\n"
192 " A list of containers held in the collection.\n"
194 "</FieldContainer>\n",
198 /*------------------------------ get -----------------------------------*/
200 FieldContainerType
&ContainerCollectionBase::getType(void)
205 const FieldContainerType
&ContainerCollectionBase::getType(void) const
210 UInt32
ContainerCollectionBase::getContainerSize(void) const
212 return sizeof(ContainerCollection
);
215 /*------------------------- decorator get ------------------------------*/
218 SFString
*ContainerCollectionBase::editSFName(void)
220 editSField(NameFieldMask
);
225 const SFString
*ContainerCollectionBase::getSFName(void) const
231 //! Get the ContainerCollection::_mfContainers field.
232 const MFUnrecFieldContainerPtr
*ContainerCollectionBase::getMFContainers(void) const
234 return &_mfContainers
;
237 MFUnrecFieldContainerPtr
*ContainerCollectionBase::editMFContainers (void)
239 editMField(ContainersFieldMask
, _mfContainers
);
241 return &_mfContainers
;
243 FieldContainer
* ContainerCollectionBase::getContainers(const UInt32 index
) const
245 return _mfContainers
[index
];
250 void ContainerCollectionBase::pushToContainers(FieldContainer
* const value
)
252 editMField(ContainersFieldMask
, _mfContainers
);
254 _mfContainers
.push_back(value
);
257 void ContainerCollectionBase::assignContainers(const MFUnrecFieldContainerPtr
&value
)
259 MFUnrecFieldContainerPtr::const_iterator elemIt
=
261 MFUnrecFieldContainerPtr::const_iterator elemEnd
=
264 static_cast<ContainerCollection
*>(this)->clearContainers();
266 while(elemIt
!= elemEnd
)
268 this->pushToContainers(*elemIt
);
274 void ContainerCollectionBase::removeFromContainers(UInt32 uiIndex
)
276 if(uiIndex
< _mfContainers
.size())
278 editMField(ContainersFieldMask
, _mfContainers
);
280 _mfContainers
.erase(uiIndex
);
284 void ContainerCollectionBase::removeObjFromContainers(FieldContainer
* const value
)
286 Int32 iElemIdx
= _mfContainers
.findIndex(value
);
290 editMField(ContainersFieldMask
, _mfContainers
);
292 _mfContainers
.erase(iElemIdx
);
295 void ContainerCollectionBase::clearContainers(void)
297 editMField(ContainersFieldMask
, _mfContainers
);
300 _mfContainers
.clear();
305 /*------------------------------ access -----------------------------------*/
307 SizeT
ContainerCollectionBase::getBinSize(ConstFieldMaskArg whichField
)
309 SizeT returnValue
= Inherited::getBinSize(whichField
);
311 if(FieldBits::NoField
!= (NameFieldMask
& whichField
))
313 returnValue
+= _sfName
.getBinSize();
315 if(FieldBits::NoField
!= (ContainersFieldMask
& whichField
))
317 returnValue
+= _mfContainers
.getBinSize();
323 void ContainerCollectionBase::copyToBin(BinaryDataHandler
&pMem
,
324 ConstFieldMaskArg whichField
)
326 Inherited::copyToBin(pMem
, whichField
);
328 if(FieldBits::NoField
!= (NameFieldMask
& whichField
))
330 _sfName
.copyToBin(pMem
);
332 if(FieldBits::NoField
!= (ContainersFieldMask
& whichField
))
334 _mfContainers
.copyToBin(pMem
);
338 void ContainerCollectionBase::copyFromBin(BinaryDataHandler
&pMem
,
339 ConstFieldMaskArg whichField
)
341 Inherited::copyFromBin(pMem
, whichField
);
343 if(FieldBits::NoField
!= (NameFieldMask
& whichField
))
345 editSField(NameFieldMask
);
346 _sfName
.copyFromBin(pMem
);
348 if(FieldBits::NoField
!= (ContainersFieldMask
& whichField
))
350 editMField(ContainersFieldMask
, _mfContainers
);
351 _mfContainers
.copyFromBin(pMem
);
355 //! create a new instance of the class
356 ContainerCollectionTransitPtr
ContainerCollectionBase::createLocal(BitVector bFlags
)
358 ContainerCollectionTransitPtr fc
;
360 if(getClassType().getPrototype() != NULL
)
362 FieldContainerTransitPtr tmpPtr
=
363 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
365 fc
= dynamic_pointer_cast
<ContainerCollection
>(tmpPtr
);
371 //! create a new instance of the class, copy the container flags
372 ContainerCollectionTransitPtr
ContainerCollectionBase::createDependent(BitVector bFlags
)
374 ContainerCollectionTransitPtr fc
;
376 if(getClassType().getPrototype() != NULL
)
378 FieldContainerTransitPtr tmpPtr
=
379 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
381 fc
= dynamic_pointer_cast
<ContainerCollection
>(tmpPtr
);
387 //! create a new instance of the class
388 ContainerCollectionTransitPtr
ContainerCollectionBase::create(void)
390 ContainerCollectionTransitPtr fc
;
392 if(getClassType().getPrototype() != NULL
)
394 FieldContainerTransitPtr tmpPtr
=
395 getClassType().getPrototype()-> shallowCopy();
397 fc
= dynamic_pointer_cast
<ContainerCollection
>(tmpPtr
);
403 ContainerCollection
*ContainerCollectionBase::createEmptyLocal(BitVector bFlags
)
405 ContainerCollection
*returnValue
;
407 newPtr
<ContainerCollection
>(returnValue
, bFlags
);
409 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
414 //! create an empty new instance of the class, do not copy the prototype
415 ContainerCollection
*ContainerCollectionBase::createEmpty(void)
417 ContainerCollection
*returnValue
;
419 newPtr
<ContainerCollection
>(returnValue
, Thread::getCurrentLocalFlags());
421 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
422 ~Thread::getCurrentLocalFlags();
428 FieldContainerTransitPtr
ContainerCollectionBase::shallowCopyLocal(
429 BitVector bFlags
) const
431 ContainerCollection
*tmpPtr
;
433 newPtr(tmpPtr
, dynamic_cast<const ContainerCollection
*>(this), bFlags
);
435 FieldContainerTransitPtr
returnValue(tmpPtr
);
437 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
442 FieldContainerTransitPtr
ContainerCollectionBase::shallowCopyDependent(
443 BitVector bFlags
) const
445 ContainerCollection
*tmpPtr
;
447 newPtr(tmpPtr
, dynamic_cast<const ContainerCollection
*>(this), ~bFlags
);
449 FieldContainerTransitPtr
returnValue(tmpPtr
);
451 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
456 FieldContainerTransitPtr
ContainerCollectionBase::shallowCopy(void) const
458 ContainerCollection
*tmpPtr
;
461 dynamic_cast<const ContainerCollection
*>(this),
462 Thread::getCurrentLocalFlags());
464 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
466 FieldContainerTransitPtr
returnValue(tmpPtr
);
474 /*------------------------- constructors ----------------------------------*/
476 ContainerCollectionBase::ContainerCollectionBase(void) :
483 ContainerCollectionBase::ContainerCollectionBase(const ContainerCollectionBase
&source
) :
485 _sfName (source
._sfName
),
491 /*-------------------------- destructors ----------------------------------*/
493 ContainerCollectionBase::~ContainerCollectionBase(void)
497 void ContainerCollectionBase::onCreate(const ContainerCollection
*source
)
499 Inherited::onCreate(source
);
503 ContainerCollection
*pThis
= static_cast<ContainerCollection
*>(this);
505 MFUnrecFieldContainerPtr::const_iterator ContainersIt
=
506 source
->_mfContainers
.begin();
507 MFUnrecFieldContainerPtr::const_iterator ContainersEnd
=
508 source
->_mfContainers
.end ();
510 while(ContainersIt
!= ContainersEnd
)
512 pThis
->pushToContainers(*ContainersIt
);
519 GetFieldHandlePtr
ContainerCollectionBase::getHandleName (void) const
521 SFString::GetHandlePtr
returnValue(
522 new SFString::GetHandle(
524 this->getType().getFieldDesc(NameFieldId
),
525 const_cast<ContainerCollectionBase
*>(this)));
530 EditFieldHandlePtr
ContainerCollectionBase::editHandleName (void)
532 SFString::EditHandlePtr
returnValue(
533 new SFString::EditHandle(
535 this->getType().getFieldDesc(NameFieldId
),
539 editSField(NameFieldMask
);
544 GetFieldHandlePtr
ContainerCollectionBase::getHandleContainers (void) const
546 MFUnrecFieldContainerPtr::GetHandlePtr
returnValue(
547 new MFUnrecFieldContainerPtr::GetHandle(
549 this->getType().getFieldDesc(ContainersFieldId
),
550 const_cast<ContainerCollectionBase
*>(this)));
555 EditFieldHandlePtr
ContainerCollectionBase::editHandleContainers (void)
557 MFUnrecFieldContainerPtr::EditHandlePtr
returnValue(
558 new MFUnrecFieldContainerPtr::EditHandle(
560 this->getType().getFieldDesc(ContainersFieldId
),
563 returnValue
->setAddMethod(
564 boost::bind(&ContainerCollection::pushToContainers
,
565 static_cast<ContainerCollection
*>(this), _1
));
566 returnValue
->setRemoveMethod(
567 boost::bind(&ContainerCollection::removeFromContainers
,
568 static_cast<ContainerCollection
*>(this), _1
));
569 returnValue
->setRemoveObjMethod(
570 boost::bind(&ContainerCollection::removeObjFromContainers
,
571 static_cast<ContainerCollection
*>(this), _1
));
572 returnValue
->setClearMethod(
573 boost::bind(&ContainerCollection::clearContainers
,
574 static_cast<ContainerCollection
*>(this)));
576 editMField(ContainersFieldMask
, _mfContainers
);
582 #ifdef OSG_MT_CPTR_ASPECT
583 void ContainerCollectionBase::execSyncV( FieldContainer
&oFrom
,
584 ConstFieldMaskArg whichField
,
585 AspectOffsetStore
&oOffsets
,
586 ConstFieldMaskArg syncMode
,
587 const UInt32 uiSyncInfo
)
589 ContainerCollection
*pThis
= static_cast<ContainerCollection
*>(this);
591 pThis
->execSync(static_cast<ContainerCollection
*>(&oFrom
),
600 #ifdef OSG_MT_CPTR_ASPECT
601 FieldContainer
*ContainerCollectionBase::createAspectCopy(
602 const FieldContainer
*pRefAspect
) const
604 ContainerCollection
*returnValue
;
606 newAspectCopy(returnValue
,
607 dynamic_cast<const ContainerCollection
*>(pRefAspect
),
608 dynamic_cast<const ContainerCollection
*>(this));
614 void ContainerCollectionBase::resolveLinks(void)
616 Inherited::resolveLinks();
618 static_cast<ContainerCollection
*>(this)->clearContainers();