changed: auto add updateData callback to stages so that stagedata can be updated...
[opensg.git] / Source / Base / FieldContainer / Attachments / OSGGlobalsAttachmentBase.cpp
blobb5e1746d9fcc282858ab7c9a18fdc3264ef8cc83
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
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 #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)
69 #endif
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
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",
98 "AttachmentPtr",
99 GlobalsAttachment::getClassType(),
100 nsOSG);
101 #endif
103 OSG_FIELDTRAITS_GETTYPE_NS(GlobalsAttachment *, nsOSG)
105 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
106 GlobalsAttachment *,
107 nsOSG);
109 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
110 GlobalsAttachment *,
111 nsOSG);
113 DataType &FieldTraits< GlobalsAttachment *, nsOSG + 1 >::getType(void)
115 return FieldTraits<GlobalsAttachment *, nsOSG>::getType();
119 OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
120 GlobalsAttachment *,
121 UnrecordedRefCountPolicy,
122 nsOSG + 1);
125 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
126 GlobalsAttachment *,
127 UnrecordedRefCountPolicy,
128 nsOSG + 1);
131 DataType &FieldTraits<GlobalsAttachment *, nsOSG + 2 >::getType(void)
133 return FieldTraits<GlobalsAttachment *, nsOSG>::getType();
137 OSG_SFIELDTYPE_INST(ParentPointerSField,
138 GlobalsAttachment *,
139 NoRefCountPolicy,
140 nsOSG + 2);
142 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField,
143 GlobalsAttachment *,
144 NoRefCountPolicy,
145 nsOSG + 2);
148 OSG_MFIELDTYPE_INST(ParentPointerMField,
149 GlobalsAttachment *,
150 NoRefCountPolicy,
153 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerMField,
154 GlobalsAttachment *,
155 NoRefCountPolicy,
159 /***************************************************************************\
160 * Field Description *
161 \***************************************************************************/
163 void GlobalsAttachmentBase::classDescInserter(TypeObject &oType)
165 FieldDescriptionBase *pDesc = NULL;
168 pDesc = new MFUnrecFieldContainerPtr::Description(
169 MFUnrecFieldContainerPtr::getClassType(),
170 "elements",
171 "global elements store inside the attachment\n",
172 ElementsFieldId, ElementsFieldMask,
173 false,
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(),
185 "globals",
186 nsOSG, //Namespace
187 reinterpret_cast<PrototypeCreateF>(&GlobalsAttachmentBase::createEmptyLocal),
188 GlobalsAttachment::initMethod,
189 GlobalsAttachment::exitMethod,
190 reinterpret_cast<InitalInsertDescFunc>(&GlobalsAttachment::classDescInserter),
191 false,
193 "<?xml version=\"1.0\" ?>\n"
194 "\n"
195 "<FieldContainer\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"
208 " >\n"
209 " attached to the root node by the loader infrastructure if the file\n"
210 " contains elements outside the main graph.\n"
211 " <Field\n"
212 " name=\"elements\"\n"
213 " category=\"pointer\"\n"
214 " type=\"FieldContainer\"\n"
215 " cardinality=\"multi\"\n"
216 " visibility=\"external\"\n"
217 " >\n"
218 " global elements store inside the attachment\n"
219 " </Field>\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)
229 return _type;
232 const FieldContainerType &GlobalsAttachmentBase::getType(void) const
234 return _type;
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
248 return &_mfElements;
251 MFUnrecFieldContainerPtr *GlobalsAttachmentBase::editMFElements (void)
253 editMField(ElementsFieldMask, _mfElements);
255 return &_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 =
270 value.begin();
271 MFUnrecFieldContainerPtr::const_iterator elemEnd =
272 value.end ();
274 static_cast<GlobalsAttachment *>(this)->clearElements();
276 while(elemIt != elemEnd)
278 this->pushToElements(*elemIt);
280 ++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);
298 if(iElemIdx != -1)
300 editMField(ElementsFieldMask, _mfElements);
302 _mfElements.erase(iElemIdx);
305 void GlobalsAttachmentBase::clearElements(void)
307 editMField(ElementsFieldMask, _mfElements);
310 _mfElements.clear();
315 /*------------------------------ access -----------------------------------*/
317 SizeT GlobalsAttachmentBase::getBinSize(ConstFieldMaskArg whichField)
319 SizeT returnValue = Inherited::getBinSize(whichField);
321 if(FieldBits::NoField != (ElementsFieldMask & whichField))
323 returnValue += _mfElements.getBinSize();
326 return returnValue;
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);
365 return fc;
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);
381 return fc;
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);
397 return fc;
400 GlobalsAttachment *GlobalsAttachmentBase::createEmptyLocal(BitVector bFlags)
402 GlobalsAttachment *returnValue;
404 newPtr<GlobalsAttachment>(returnValue, bFlags);
406 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
408 return returnValue;
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();
421 return returnValue;
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;
436 return returnValue;
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;
450 return returnValue;
453 FieldContainerTransitPtr GlobalsAttachmentBase::shallowCopy(void) const
455 GlobalsAttachment *tmpPtr;
457 newPtr(tmpPtr,
458 dynamic_cast<const GlobalsAttachment *>(this),
459 Thread::getCurrentLocalFlags());
461 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
463 FieldContainerTransitPtr returnValue(tmpPtr);
465 return returnValue;
471 /*------------------------- constructors ----------------------------------*/
473 GlobalsAttachmentBase::GlobalsAttachmentBase(void) :
474 Inherited(),
475 _mfElements ()
479 GlobalsAttachmentBase::GlobalsAttachmentBase(const GlobalsAttachmentBase &source) :
480 Inherited(source),
481 _mfElements ()
486 /*-------------------------- destructors ----------------------------------*/
488 GlobalsAttachmentBase::~GlobalsAttachmentBase(void)
492 void GlobalsAttachmentBase::onCreate(const GlobalsAttachment *source)
494 Inherited::onCreate(source);
496 if(source != NULL)
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);
509 ++ElementsIt;
514 GetFieldHandlePtr GlobalsAttachmentBase::getHandleElements (void) const
516 MFUnrecFieldContainerPtr::GetHandlePtr returnValue(
517 new MFUnrecFieldContainerPtr::GetHandle(
518 &_mfElements,
519 this->getType().getFieldDesc(ElementsFieldId),
520 const_cast<GlobalsAttachmentBase *>(this)));
522 return returnValue;
525 EditFieldHandlePtr GlobalsAttachmentBase::editHandleElements (void)
527 MFUnrecFieldContainerPtr::EditHandlePtr returnValue(
528 new MFUnrecFieldContainerPtr::EditHandle(
529 &_mfElements,
530 this->getType().getFieldDesc(ElementsFieldId),
531 this));
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);
548 return returnValue;
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),
562 whichField,
563 oOffsets,
564 syncMode,
565 uiSyncInfo);
567 #endif
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));
580 return returnValue;
582 #endif
584 void GlobalsAttachmentBase::resolveLinks(void)
586 Inherited::resolveLinks();
588 static_cast<GlobalsAttachment *>(this)->clearElements();
594 OSG_END_NAMESPACE