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 GlobalsAttachment!
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" // Elements Class
67 #include "OSGGlobalsAttachmentBase.h"
68 #include "OSGGlobalsAttachment.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::GlobalsAttachment
79 attached to the root node by the loader infrastructure if the file
80 contains elements outside the main graph.
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var FieldContainer * GlobalsAttachmentBase::_mfElements
88 global elements store inside the attachment
92 /***************************************************************************\
93 * FieldType/FieldTrait Instantiation *
94 \***************************************************************************/
96 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
97 PointerType FieldTraits
<GlobalsAttachment
*, nsOSG
>::_type(
98 "GlobalsAttachmentPtr",
100 GlobalsAttachment::getClassType(),
104 OSG_FIELDTRAITS_GETTYPE_NS(GlobalsAttachment
*, nsOSG
)
106 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
110 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
114 DataType
&FieldTraits
< GlobalsAttachment
*, nsOSG
+ 1 >::getType(void)
116 return FieldTraits
<GlobalsAttachment
*, nsOSG
>::getType();
120 OSG_EXPORT_PTR_SFIELD(ChildPointerSField
,
122 UnrecordedRefCountPolicy
,
126 OSG_EXPORT_PTR_MFIELD(ChildPointerMField
,
128 UnrecordedRefCountPolicy
,
132 DataType
&FieldTraits
<GlobalsAttachment
*, nsOSG
+ 2 >::getType(void)
134 return FieldTraits
<GlobalsAttachment
*, nsOSG
>::getType();
138 OSG_SFIELDTYPE_INST(ParentPointerSField
,
143 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField
,
149 OSG_MFIELDTYPE_INST(ParentPointerMField
,
154 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerMField
,
160 /***************************************************************************\
161 * Field Description *
162 \***************************************************************************/
164 void GlobalsAttachmentBase::classDescInserter(TypeObject
&oType
)
166 FieldDescriptionBase
*pDesc
= NULL
;
169 pDesc
= new MFUnrecFieldContainerPtr::Description(
170 MFUnrecFieldContainerPtr::getClassType(),
172 "global elements store inside the attachment\n",
173 ElementsFieldId
, ElementsFieldMask
,
175 (Field::MFDefaultFlags
| Field::FStdAccess
),
176 static_cast<FieldEditMethodSig
>(&GlobalsAttachment::editHandleElements
),
177 static_cast<FieldGetMethodSig
>(&GlobalsAttachment::getHandleElements
));
179 oType
.addInitialDesc(pDesc
);
183 GlobalsAttachmentBase::TypeObject
GlobalsAttachmentBase::_type(
184 GlobalsAttachmentBase::getClassname(),
185 Inherited::getClassname(),
188 reinterpret_cast<PrototypeCreateF
>(&GlobalsAttachmentBase::createEmptyLocal
),
189 reinterpret_cast<InitContainerF
>(&GlobalsAttachment::initMethod
),
190 reinterpret_cast<ExitContainerF
>(&GlobalsAttachment::exitMethod
),
191 reinterpret_cast<InitalInsertDescFunc
>(
192 reinterpret_cast<void *>(&GlobalsAttachment::classDescInserter
)),
195 "<?xml version=\"1.0\" ?>\n"
198 " name=\"GlobalsAttachment\"\n"
199 " parent=\"Attachment\"\n"
200 " library=\"Base\"\n"
201 " structure=\"concrete\"\n"
202 " group=\"globals\"\n"
203 " pointerfieldtypes=\"both\"\n"
204 " parentFields=\"both\"\n"
205 " childFields=\"both\"\n"
206 " systemcomponent=\"true\"\n"
207 " parentsystemcomponent=\"true\"\n"
208 " isNodeCore=\"false\"\n"
209 " docGroupBase=\"GrpBaseFieldContainer\"\n"
211 " attached to the root node by the loader infrastructure if the file\n"
212 " contains elements outside the main graph.\n"
214 " name=\"elements\"\n"
215 " category=\"pointer\"\n"
216 " type=\"FieldContainer\"\n"
217 " cardinality=\"multi\"\n"
218 " visibility=\"external\"\n"
220 " global elements store inside the attachment\n"
222 "</FieldContainer>\n",
223 "attached to the root node by the loader infrastructure if the file\n"
224 "contains elements outside the main graph.\n"
227 /*------------------------------ get -----------------------------------*/
229 FieldContainerType
&GlobalsAttachmentBase::getType(void)
234 const FieldContainerType
&GlobalsAttachmentBase::getType(void) const
239 UInt32
GlobalsAttachmentBase::getContainerSize(void) const
241 return sizeof(GlobalsAttachment
);
244 /*------------------------- decorator get ------------------------------*/
247 //! Get the GlobalsAttachment::_mfElements field.
248 const MFUnrecFieldContainerPtr
*GlobalsAttachmentBase::getMFElements(void) const
253 MFUnrecFieldContainerPtr
*GlobalsAttachmentBase::editMFElements (void)
255 editMField(ElementsFieldMask
, _mfElements
);
259 FieldContainer
* GlobalsAttachmentBase::getElements(const UInt32 index
) const
261 return _mfElements
[index
];
266 void GlobalsAttachmentBase::pushToElements(FieldContainer
* const value
)
268 editMField(ElementsFieldMask
, _mfElements
);
270 _mfElements
.push_back(value
);
273 void GlobalsAttachmentBase::assignElements (const MFUnrecFieldContainerPtr
&value
)
275 MFUnrecFieldContainerPtr::const_iterator elemIt
=
277 MFUnrecFieldContainerPtr::const_iterator elemEnd
=
280 static_cast<GlobalsAttachment
*>(this)->clearElements();
282 while(elemIt
!= elemEnd
)
284 this->pushToElements(*elemIt
);
290 void GlobalsAttachmentBase::removeFromElements(UInt32 uiIndex
)
292 if(uiIndex
< _mfElements
.size())
294 editMField(ElementsFieldMask
, _mfElements
);
296 _mfElements
.erase(uiIndex
);
300 void GlobalsAttachmentBase::removeObjFromElements(FieldContainer
* const value
)
302 Int32 iElemIdx
= _mfElements
.findIndex(value
);
306 editMField(ElementsFieldMask
, _mfElements
);
308 _mfElements
.erase(iElemIdx
);
311 void GlobalsAttachmentBase::clearElements(void)
313 editMField(ElementsFieldMask
, _mfElements
);
321 /*------------------------------ access -----------------------------------*/
323 SizeT
GlobalsAttachmentBase::getBinSize(ConstFieldMaskArg whichField
)
325 SizeT returnValue
= Inherited::getBinSize(whichField
);
327 if(FieldBits::NoField
!= (ElementsFieldMask
& whichField
))
329 returnValue
+= _mfElements
.getBinSize();
335 void GlobalsAttachmentBase::copyToBin(BinaryDataHandler
&pMem
,
336 ConstFieldMaskArg whichField
)
338 Inherited::copyToBin(pMem
, whichField
);
340 if(FieldBits::NoField
!= (ElementsFieldMask
& whichField
))
342 _mfElements
.copyToBin(pMem
);
346 void GlobalsAttachmentBase::copyFromBin(BinaryDataHandler
&pMem
,
347 ConstFieldMaskArg whichField
)
349 Inherited::copyFromBin(pMem
, whichField
);
351 if(FieldBits::NoField
!= (ElementsFieldMask
& whichField
))
353 editMField(ElementsFieldMask
, _mfElements
);
354 _mfElements
.copyFromBin(pMem
);
358 //! create a new instance of the class
359 GlobalsAttachmentTransitPtr
GlobalsAttachmentBase::createLocal(BitVector bFlags
)
361 GlobalsAttachmentTransitPtr fc
;
363 if(getClassType().getPrototype() != NULL
)
365 FieldContainerTransitPtr tmpPtr
=
366 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
368 fc
= dynamic_pointer_cast
<GlobalsAttachment
>(tmpPtr
);
374 //! create a new instance of the class, copy the container flags
375 GlobalsAttachmentTransitPtr
GlobalsAttachmentBase::createDependent(BitVector bFlags
)
377 GlobalsAttachmentTransitPtr fc
;
379 if(getClassType().getPrototype() != NULL
)
381 FieldContainerTransitPtr tmpPtr
=
382 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
384 fc
= dynamic_pointer_cast
<GlobalsAttachment
>(tmpPtr
);
390 //! create a new instance of the class
391 GlobalsAttachmentTransitPtr
GlobalsAttachmentBase::create(void)
393 GlobalsAttachmentTransitPtr fc
;
395 if(getClassType().getPrototype() != NULL
)
397 FieldContainerTransitPtr tmpPtr
=
398 getClassType().getPrototype()-> shallowCopy();
400 fc
= dynamic_pointer_cast
<GlobalsAttachment
>(tmpPtr
);
406 GlobalsAttachment
*GlobalsAttachmentBase::createEmptyLocal(BitVector bFlags
)
408 GlobalsAttachment
*returnValue
;
410 newPtr
<GlobalsAttachment
>(returnValue
, bFlags
);
412 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
417 //! create an empty new instance of the class, do not copy the prototype
418 GlobalsAttachment
*GlobalsAttachmentBase::createEmpty(void)
420 GlobalsAttachment
*returnValue
;
422 newPtr
<GlobalsAttachment
>(returnValue
, Thread::getCurrentLocalFlags());
424 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
425 ~Thread::getCurrentLocalFlags();
431 FieldContainerTransitPtr
GlobalsAttachmentBase::shallowCopyLocal(
432 BitVector bFlags
) const
434 GlobalsAttachment
*tmpPtr
;
436 newPtr(tmpPtr
, dynamic_cast<const GlobalsAttachment
*>(this), bFlags
);
438 FieldContainerTransitPtr
returnValue(tmpPtr
);
440 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
445 FieldContainerTransitPtr
GlobalsAttachmentBase::shallowCopyDependent(
446 BitVector bFlags
) const
448 GlobalsAttachment
*tmpPtr
;
450 newPtr(tmpPtr
, dynamic_cast<const GlobalsAttachment
*>(this), ~bFlags
);
452 FieldContainerTransitPtr
returnValue(tmpPtr
);
454 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
459 FieldContainerTransitPtr
GlobalsAttachmentBase::shallowCopy(void) const
461 GlobalsAttachment
*tmpPtr
;
464 dynamic_cast<const GlobalsAttachment
*>(this),
465 Thread::getCurrentLocalFlags());
467 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
469 FieldContainerTransitPtr
returnValue(tmpPtr
);
477 /*------------------------- constructors ----------------------------------*/
479 GlobalsAttachmentBase::GlobalsAttachmentBase(void) :
485 GlobalsAttachmentBase::GlobalsAttachmentBase(const GlobalsAttachmentBase
&source
) :
492 /*-------------------------- destructors ----------------------------------*/
494 GlobalsAttachmentBase::~GlobalsAttachmentBase(void)
498 void GlobalsAttachmentBase::onCreate(const GlobalsAttachment
*source
)
500 Inherited::onCreate(source
);
504 GlobalsAttachment
*pThis
= static_cast<GlobalsAttachment
*>(this);
506 MFUnrecFieldContainerPtr::const_iterator ElementsIt
=
507 source
->_mfElements
.begin();
508 MFUnrecFieldContainerPtr::const_iterator ElementsEnd
=
509 source
->_mfElements
.end ();
511 while(ElementsIt
!= ElementsEnd
)
513 pThis
->pushToElements(*ElementsIt
);
520 GetFieldHandlePtr
GlobalsAttachmentBase::getHandleElements (void) const
522 MFUnrecFieldContainerPtr::GetHandlePtr
returnValue(
523 new MFUnrecFieldContainerPtr::GetHandle(
525 this->getType().getFieldDesc(ElementsFieldId
),
526 const_cast<GlobalsAttachmentBase
*>(this)));
531 EditFieldHandlePtr
GlobalsAttachmentBase::editHandleElements (void)
533 MFUnrecFieldContainerPtr::EditHandlePtr
returnValue(
534 new MFUnrecFieldContainerPtr::EditHandle(
536 this->getType().getFieldDesc(ElementsFieldId
),
539 returnValue
->setAddMethod(
540 boost::bind(&GlobalsAttachment::pushToElements
,
541 static_cast<GlobalsAttachment
*>(this), _1
));
542 returnValue
->setRemoveMethod(
543 boost::bind(&GlobalsAttachment::removeFromElements
,
544 static_cast<GlobalsAttachment
*>(this), _1
));
545 returnValue
->setRemoveObjMethod(
546 boost::bind(&GlobalsAttachment::removeObjFromElements
,
547 static_cast<GlobalsAttachment
*>(this), _1
));
548 returnValue
->setClearMethod(
549 boost::bind(&GlobalsAttachment::clearElements
,
550 static_cast<GlobalsAttachment
*>(this)));
552 editMField(ElementsFieldMask
, _mfElements
);
558 #ifdef OSG_MT_CPTR_ASPECT
559 void GlobalsAttachmentBase::execSyncV( FieldContainer
&oFrom
,
560 ConstFieldMaskArg whichField
,
561 AspectOffsetStore
&oOffsets
,
562 ConstFieldMaskArg syncMode
,
563 const UInt32 uiSyncInfo
)
565 GlobalsAttachment
*pThis
= static_cast<GlobalsAttachment
*>(this);
567 pThis
->execSync(static_cast<GlobalsAttachment
*>(&oFrom
),
576 #ifdef OSG_MT_CPTR_ASPECT
577 FieldContainer
*GlobalsAttachmentBase::createAspectCopy(
578 const FieldContainer
*pRefAspect
) const
580 GlobalsAttachment
*returnValue
;
582 newAspectCopy(returnValue
,
583 dynamic_cast<const GlobalsAttachment
*>(pRefAspect
),
584 dynamic_cast<const GlobalsAttachment
*>(this));
590 void GlobalsAttachmentBase::resolveLinks(void)
592 Inherited::resolveLinks();
594 static_cast<GlobalsAttachment
*>(this)->clearElements();