1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
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 GlobalsAttachment!
50 *****************************************************************************
51 \*****************************************************************************/
56 #include "OSGConfig.h"
60 #include "OSGFieldContainer.h" // Elements Class
62 #include "OSGGlobalsAttachmentBase.h"
63 #include "OSGGlobalsAttachment.h"
65 #include <boost/bind.hpp>
67 #ifdef WIN32 // turn off 'this' : used in base member initializer list warning
68 #pragma warning(disable:4355)
73 /***************************************************************************\
75 \***************************************************************************/
77 /*! \class OSG::GlobalsAttachment
78 attached to the root node by the loader infrastructure if the file
79 contains elements outside the main graph.
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var FieldContainer * GlobalsAttachmentBase::_mfElements
87 global elements store inside the attachment
91 /***************************************************************************\
92 * FieldType/FieldTrait Instantiation *
93 \***************************************************************************/
95 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
96 PointerType FieldTraits
<GlobalsAttachment
*, nsOSG
>::_type(
97 "GlobalsAttachmentPtr",
99 GlobalsAttachment::getClassType(),
103 OSG_FIELDTRAITS_GETTYPE_NS(GlobalsAttachment
*, nsOSG
)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
113 DataType
&FieldTraits
< GlobalsAttachment
*, nsOSG
+ 1 >::getType(void)
115 return FieldTraits
<GlobalsAttachment
*, nsOSG
>::getType();
119 OSG_EXPORT_PTR_SFIELD(ChildPointerSField
,
121 UnrecordedRefCountPolicy
,
125 OSG_EXPORT_PTR_MFIELD(ChildPointerMField
,
127 UnrecordedRefCountPolicy
,
131 DataType
&FieldTraits
<GlobalsAttachment
*, nsOSG
+ 2 >::getType(void)
133 return FieldTraits
<GlobalsAttachment
*, nsOSG
>::getType();
137 OSG_SFIELDTYPE_INST(ParentPointerSField
,
142 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField
,
148 OSG_MFIELDTYPE_INST(ParentPointerMField
,
153 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerMField
,
159 /***************************************************************************\
160 * Field Description *
161 \***************************************************************************/
163 void GlobalsAttachmentBase::classDescInserter(TypeObject
&oType
)
165 FieldDescriptionBase
*pDesc
= NULL
;
168 pDesc
= new MFUnrecFieldContainerPtr::Description(
169 MFUnrecFieldContainerPtr::getClassType(),
171 "global elements store inside the attachment\n",
172 ElementsFieldId
, ElementsFieldMask
,
174 (Field::MFDefaultFlags
| Field::FStdAccess
),
175 static_cast<FieldEditMethodSig
>(&GlobalsAttachment::editHandleElements
),
176 static_cast<FieldGetMethodSig
>(&GlobalsAttachment::getHandleElements
));
178 oType
.addInitialDesc(pDesc
);
182 GlobalsAttachmentBase::TypeObject
GlobalsAttachmentBase::_type(
183 GlobalsAttachmentBase::getClassname(),
184 Inherited::getClassname(),
187 reinterpret_cast<PrototypeCreateF
>(&GlobalsAttachmentBase::createEmptyLocal
),
188 GlobalsAttachment::initMethod
,
189 GlobalsAttachment::exitMethod
,
190 reinterpret_cast<InitalInsertDescFunc
>(&GlobalsAttachment::classDescInserter
),
193 "<?xml version=\"1.0\" ?>\n"
196 " name=\"GlobalsAttachment\"\n"
197 " parent=\"Attachment\"\n"
198 " library=\"Base\"\n"
199 " structure=\"concrete\"\n"
200 " group=\"globals\"\n"
201 " pointerfieldtypes=\"both\"\n"
202 " parentFields=\"both\"\n"
203 " childFields=\"both\"\n"
204 " systemcomponent=\"true\"\n"
205 " parentsystemcomponent=\"true\"\n"
206 " isNodeCore=\"false\"\n"
207 " docGroupBase=\"GrpBaseFieldContainer\"\n"
209 " attached to the root node by the loader infrastructure if the file\n"
210 " contains elements outside the main graph.\n"
212 " name=\"elements\"\n"
213 " category=\"pointer\"\n"
214 " type=\"FieldContainer\"\n"
215 " cardinality=\"multi\"\n"
216 " visibility=\"external\"\n"
218 " global elements store inside the attachment\n"
220 "</FieldContainer>\n",
221 "attached to the root node by the loader infrastructure if the file\n"
222 "contains elements outside the main graph.\n"
225 /*------------------------------ get -----------------------------------*/
227 FieldContainerType
&GlobalsAttachmentBase::getType(void)
232 const FieldContainerType
&GlobalsAttachmentBase::getType(void) const
237 UInt32
GlobalsAttachmentBase::getContainerSize(void) const
239 return sizeof(GlobalsAttachment
);
242 /*------------------------- decorator get ------------------------------*/
245 //! Get the GlobalsAttachment::_mfElements field.
246 const MFUnrecFieldContainerPtr
*GlobalsAttachmentBase::getMFElements(void) const
251 MFUnrecFieldContainerPtr
*GlobalsAttachmentBase::editMFElements (void)
253 editMField(ElementsFieldMask
, _mfElements
);
260 void GlobalsAttachmentBase::pushToElements(FieldContainer
* const value
)
262 editMField(ElementsFieldMask
, _mfElements
);
264 _mfElements
.push_back(value
);
267 void GlobalsAttachmentBase::assignElements (const MFUnrecFieldContainerPtr
&value
)
269 MFUnrecFieldContainerPtr::const_iterator elemIt
=
271 MFUnrecFieldContainerPtr::const_iterator elemEnd
=
274 static_cast<GlobalsAttachment
*>(this)->clearElements();
276 while(elemIt
!= elemEnd
)
278 this->pushToElements(*elemIt
);
284 void GlobalsAttachmentBase::removeFromElements(UInt32 uiIndex
)
286 if(uiIndex
< _mfElements
.size())
288 editMField(ElementsFieldMask
, _mfElements
);
290 _mfElements
.erase(uiIndex
);
294 void GlobalsAttachmentBase::removeObjFromElements(FieldContainer
* const value
)
296 Int32 iElemIdx
= _mfElements
.findIndex(value
);
300 editMField(ElementsFieldMask
, _mfElements
);
302 _mfElements
.erase(iElemIdx
);
305 void GlobalsAttachmentBase::clearElements(void)
307 editMField(ElementsFieldMask
, _mfElements
);
315 /*------------------------------ access -----------------------------------*/
317 SizeT
GlobalsAttachmentBase::getBinSize(ConstFieldMaskArg whichField
)
319 SizeT returnValue
= Inherited::getBinSize(whichField
);
321 if(FieldBits::NoField
!= (ElementsFieldMask
& whichField
))
323 returnValue
+= _mfElements
.getBinSize();
329 void GlobalsAttachmentBase::copyToBin(BinaryDataHandler
&pMem
,
330 ConstFieldMaskArg whichField
)
332 Inherited::copyToBin(pMem
, whichField
);
334 if(FieldBits::NoField
!= (ElementsFieldMask
& whichField
))
336 _mfElements
.copyToBin(pMem
);
340 void GlobalsAttachmentBase::copyFromBin(BinaryDataHandler
&pMem
,
341 ConstFieldMaskArg whichField
)
343 Inherited::copyFromBin(pMem
, whichField
);
345 if(FieldBits::NoField
!= (ElementsFieldMask
& whichField
))
347 editMField(ElementsFieldMask
, _mfElements
);
348 _mfElements
.copyFromBin(pMem
);
352 //! create a new instance of the class
353 GlobalsAttachmentTransitPtr
GlobalsAttachmentBase::createLocal(BitVector bFlags
)
355 GlobalsAttachmentTransitPtr fc
;
357 if(getClassType().getPrototype() != NULL
)
359 FieldContainerTransitPtr tmpPtr
=
360 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
362 fc
= dynamic_pointer_cast
<GlobalsAttachment
>(tmpPtr
);
368 //! create a new instance of the class, copy the container flags
369 GlobalsAttachmentTransitPtr
GlobalsAttachmentBase::createDependent(BitVector bFlags
)
371 GlobalsAttachmentTransitPtr fc
;
373 if(getClassType().getPrototype() != NULL
)
375 FieldContainerTransitPtr tmpPtr
=
376 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
378 fc
= dynamic_pointer_cast
<GlobalsAttachment
>(tmpPtr
);
384 //! create a new instance of the class
385 GlobalsAttachmentTransitPtr
GlobalsAttachmentBase::create(void)
387 GlobalsAttachmentTransitPtr fc
;
389 if(getClassType().getPrototype() != NULL
)
391 FieldContainerTransitPtr tmpPtr
=
392 getClassType().getPrototype()-> shallowCopy();
394 fc
= dynamic_pointer_cast
<GlobalsAttachment
>(tmpPtr
);
400 GlobalsAttachment
*GlobalsAttachmentBase::createEmptyLocal(BitVector bFlags
)
402 GlobalsAttachment
*returnValue
;
404 newPtr
<GlobalsAttachment
>(returnValue
, bFlags
);
406 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
411 //! create an empty new instance of the class, do not copy the prototype
412 GlobalsAttachment
*GlobalsAttachmentBase::createEmpty(void)
414 GlobalsAttachment
*returnValue
;
416 newPtr
<GlobalsAttachment
>(returnValue
, Thread::getCurrentLocalFlags());
418 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
419 ~Thread::getCurrentLocalFlags();
425 FieldContainerTransitPtr
GlobalsAttachmentBase::shallowCopyLocal(
426 BitVector bFlags
) const
428 GlobalsAttachment
*tmpPtr
;
430 newPtr(tmpPtr
, dynamic_cast<const GlobalsAttachment
*>(this), bFlags
);
432 FieldContainerTransitPtr
returnValue(tmpPtr
);
434 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
439 FieldContainerTransitPtr
GlobalsAttachmentBase::shallowCopyDependent(
440 BitVector bFlags
) const
442 GlobalsAttachment
*tmpPtr
;
444 newPtr(tmpPtr
, dynamic_cast<const GlobalsAttachment
*>(this), ~bFlags
);
446 FieldContainerTransitPtr
returnValue(tmpPtr
);
448 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
453 FieldContainerTransitPtr
GlobalsAttachmentBase::shallowCopy(void) const
455 GlobalsAttachment
*tmpPtr
;
458 dynamic_cast<const GlobalsAttachment
*>(this),
459 Thread::getCurrentLocalFlags());
461 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
463 FieldContainerTransitPtr
returnValue(tmpPtr
);
471 /*------------------------- constructors ----------------------------------*/
473 GlobalsAttachmentBase::GlobalsAttachmentBase(void) :
479 GlobalsAttachmentBase::GlobalsAttachmentBase(const GlobalsAttachmentBase
&source
) :
486 /*-------------------------- destructors ----------------------------------*/
488 GlobalsAttachmentBase::~GlobalsAttachmentBase(void)
492 void GlobalsAttachmentBase::onCreate(const GlobalsAttachment
*source
)
494 Inherited::onCreate(source
);
498 GlobalsAttachment
*pThis
= static_cast<GlobalsAttachment
*>(this);
500 MFUnrecFieldContainerPtr::const_iterator ElementsIt
=
501 source
->_mfElements
.begin();
502 MFUnrecFieldContainerPtr::const_iterator ElementsEnd
=
503 source
->_mfElements
.end ();
505 while(ElementsIt
!= ElementsEnd
)
507 pThis
->pushToElements(*ElementsIt
);
514 GetFieldHandlePtr
GlobalsAttachmentBase::getHandleElements (void) const
516 MFUnrecFieldContainerPtr::GetHandlePtr
returnValue(
517 new MFUnrecFieldContainerPtr::GetHandle(
519 this->getType().getFieldDesc(ElementsFieldId
),
520 const_cast<GlobalsAttachmentBase
*>(this)));
525 EditFieldHandlePtr
GlobalsAttachmentBase::editHandleElements (void)
527 MFUnrecFieldContainerPtr::EditHandlePtr
returnValue(
528 new MFUnrecFieldContainerPtr::EditHandle(
530 this->getType().getFieldDesc(ElementsFieldId
),
533 returnValue
->setAddMethod(
534 boost::bind(&GlobalsAttachment::pushToElements
,
535 static_cast<GlobalsAttachment
*>(this), _1
));
536 returnValue
->setRemoveMethod(
537 boost::bind(&GlobalsAttachment::removeFromElements
,
538 static_cast<GlobalsAttachment
*>(this), _1
));
539 returnValue
->setRemoveObjMethod(
540 boost::bind(&GlobalsAttachment::removeObjFromElements
,
541 static_cast<GlobalsAttachment
*>(this), _1
));
542 returnValue
->setClearMethod(
543 boost::bind(&GlobalsAttachment::clearElements
,
544 static_cast<GlobalsAttachment
*>(this)));
546 editMField(ElementsFieldMask
, _mfElements
);
552 #ifdef OSG_MT_CPTR_ASPECT
553 void GlobalsAttachmentBase::execSyncV( FieldContainer
&oFrom
,
554 ConstFieldMaskArg whichField
,
555 AspectOffsetStore
&oOffsets
,
556 ConstFieldMaskArg syncMode
,
557 const UInt32 uiSyncInfo
)
559 GlobalsAttachment
*pThis
= static_cast<GlobalsAttachment
*>(this);
561 pThis
->execSync(static_cast<GlobalsAttachment
*>(&oFrom
),
570 #ifdef OSG_MT_CPTR_ASPECT
571 FieldContainer
*GlobalsAttachmentBase::createAspectCopy(
572 const FieldContainer
*pRefAspect
) const
574 GlobalsAttachment
*returnValue
;
576 newAspectCopy(returnValue
,
577 dynamic_cast<const GlobalsAttachment
*>(pRefAspect
),
578 dynamic_cast<const GlobalsAttachment
*>(this));
584 void GlobalsAttachmentBase::resolveLinks(void)
586 Inherited::resolveLinks();
588 static_cast<GlobalsAttachment
*>(this)->clearElements();