changed: gcc8 base update
[opensg.git] / Source / Base / FieldContainer / Attachments / OSGGlobalsAttachmentBase.cpp
blob6c630169d22830c2fddc233880e0a2f399cbddd9
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 GlobalsAttachment!
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 "OSGFieldContainer.h" // Elements Class
67 #include "OSGGlobalsAttachmentBase.h"
68 #include "OSGGlobalsAttachment.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
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",
99 "AttachmentPtr",
100 GlobalsAttachment::getClassType(),
101 nsOSG);
102 #endif
104 OSG_FIELDTRAITS_GETTYPE_NS(GlobalsAttachment *, nsOSG)
106 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
107 GlobalsAttachment *,
108 nsOSG)
110 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
111 GlobalsAttachment *,
112 nsOSG)
114 DataType &FieldTraits< GlobalsAttachment *, nsOSG + 1 >::getType(void)
116 return FieldTraits<GlobalsAttachment *, nsOSG>::getType();
120 OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
121 GlobalsAttachment *,
122 UnrecordedRefCountPolicy,
123 nsOSG + 1)
126 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
127 GlobalsAttachment *,
128 UnrecordedRefCountPolicy,
129 nsOSG + 1)
132 DataType &FieldTraits<GlobalsAttachment *, nsOSG + 2 >::getType(void)
134 return FieldTraits<GlobalsAttachment *, nsOSG>::getType();
138 OSG_SFIELDTYPE_INST(ParentPointerSField,
139 GlobalsAttachment *,
140 NoRefCountPolicy,
141 nsOSG + 2);
143 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField,
144 GlobalsAttachment *,
145 NoRefCountPolicy,
146 nsOSG + 2)
149 OSG_MFIELDTYPE_INST(ParentPointerMField,
150 GlobalsAttachment *,
151 NoRefCountPolicy,
154 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerMField,
155 GlobalsAttachment *,
156 NoRefCountPolicy,
160 /***************************************************************************\
161 * Field Description *
162 \***************************************************************************/
164 void GlobalsAttachmentBase::classDescInserter(TypeObject &oType)
166 FieldDescriptionBase *pDesc = NULL;
169 pDesc = new MFUnrecFieldContainerPtr::Description(
170 MFUnrecFieldContainerPtr::getClassType(),
171 "elements",
172 "global elements store inside the attachment\n",
173 ElementsFieldId, ElementsFieldMask,
174 false,
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(),
186 "globals",
187 nsOSG, //Namespace
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)),
193 false,
195 "<?xml version=\"1.0\" ?>\n"
196 "\n"
197 "<FieldContainer\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"
210 " >\n"
211 " attached to the root node by the loader infrastructure if the file\n"
212 " contains elements outside the main graph.\n"
213 " <Field\n"
214 " name=\"elements\"\n"
215 " category=\"pointer\"\n"
216 " type=\"FieldContainer\"\n"
217 " cardinality=\"multi\"\n"
218 " visibility=\"external\"\n"
219 " >\n"
220 " global elements store inside the attachment\n"
221 " </Field>\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)
231 return _type;
234 const FieldContainerType &GlobalsAttachmentBase::getType(void) const
236 return _type;
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
250 return &_mfElements;
253 MFUnrecFieldContainerPtr *GlobalsAttachmentBase::editMFElements (void)
255 editMField(ElementsFieldMask, _mfElements);
257 return &_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 =
276 value.begin();
277 MFUnrecFieldContainerPtr::const_iterator elemEnd =
278 value.end ();
280 static_cast<GlobalsAttachment *>(this)->clearElements();
282 while(elemIt != elemEnd)
284 this->pushToElements(*elemIt);
286 ++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);
304 if(iElemIdx != -1)
306 editMField(ElementsFieldMask, _mfElements);
308 _mfElements.erase(iElemIdx);
311 void GlobalsAttachmentBase::clearElements(void)
313 editMField(ElementsFieldMask, _mfElements);
316 _mfElements.clear();
321 /*------------------------------ access -----------------------------------*/
323 SizeT GlobalsAttachmentBase::getBinSize(ConstFieldMaskArg whichField)
325 SizeT returnValue = Inherited::getBinSize(whichField);
327 if(FieldBits::NoField != (ElementsFieldMask & whichField))
329 returnValue += _mfElements.getBinSize();
332 return returnValue;
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);
371 return fc;
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);
387 return fc;
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);
403 return fc;
406 GlobalsAttachment *GlobalsAttachmentBase::createEmptyLocal(BitVector bFlags)
408 GlobalsAttachment *returnValue;
410 newPtr<GlobalsAttachment>(returnValue, bFlags);
412 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
414 return returnValue;
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();
427 return returnValue;
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;
442 return returnValue;
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;
456 return returnValue;
459 FieldContainerTransitPtr GlobalsAttachmentBase::shallowCopy(void) const
461 GlobalsAttachment *tmpPtr;
463 newPtr(tmpPtr,
464 dynamic_cast<const GlobalsAttachment *>(this),
465 Thread::getCurrentLocalFlags());
467 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
469 FieldContainerTransitPtr returnValue(tmpPtr);
471 return returnValue;
477 /*------------------------- constructors ----------------------------------*/
479 GlobalsAttachmentBase::GlobalsAttachmentBase(void) :
480 Inherited(),
481 _mfElements ()
485 GlobalsAttachmentBase::GlobalsAttachmentBase(const GlobalsAttachmentBase &source) :
486 Inherited(source),
487 _mfElements ()
492 /*-------------------------- destructors ----------------------------------*/
494 GlobalsAttachmentBase::~GlobalsAttachmentBase(void)
498 void GlobalsAttachmentBase::onCreate(const GlobalsAttachment *source)
500 Inherited::onCreate(source);
502 if(source != NULL)
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);
515 ++ElementsIt;
520 GetFieldHandlePtr GlobalsAttachmentBase::getHandleElements (void) const
522 MFUnrecFieldContainerPtr::GetHandlePtr returnValue(
523 new MFUnrecFieldContainerPtr::GetHandle(
524 &_mfElements,
525 this->getType().getFieldDesc(ElementsFieldId),
526 const_cast<GlobalsAttachmentBase *>(this)));
528 return returnValue;
531 EditFieldHandlePtr GlobalsAttachmentBase::editHandleElements (void)
533 MFUnrecFieldContainerPtr::EditHandlePtr returnValue(
534 new MFUnrecFieldContainerPtr::EditHandle(
535 &_mfElements,
536 this->getType().getFieldDesc(ElementsFieldId),
537 this));
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);
554 return returnValue;
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),
568 whichField,
569 oOffsets,
570 syncMode,
571 uiSyncInfo);
573 #endif
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));
586 return returnValue;
588 #endif
590 void GlobalsAttachmentBase::resolveLinks(void)
592 Inherited::resolveLinks();
594 static_cast<GlobalsAttachment *>(this)->clearElements();
600 OSG_END_NAMESPACE