fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Misc / OSGVisitSubTreeBase.cpp
bloba1866e54d665e19d598abb5297da1ced91a955e3
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 VisitSubTree!
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 "OSGNode.h" // SubTreeRoot Class
67 #include "OSGVisitSubTreeBase.h"
68 #include "OSGVisitSubTree.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::VisitSubTree
79 VisitSubTree provides a way to point the renderer to another section of the
80 scene graph for rendering. This is useful for multi-pass algorithms using
81 OSG::Stage because it provides a way to render the same graph multiple times
82 without duplicating the nodes.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var Node * VisitSubTreeBase::_sfSubTreeRoot
90 Reference to the sub-graph to draw in place of this node.
91 Whatever node is pointed to will be drawn here as if it was duplicated
92 at this location.
95 /*! \var UInt32 VisitSubTreeBase::_sfSubTreeTravMask
96 This travmask will be used to update the action mask on traversal (and)
99 /*! \var UInt32 VisitSubTreeBase::_sfTravMaskMode
100 This defines how the travmask will be used to update the action mask on
101 traversal
105 /***************************************************************************\
106 * FieldType/FieldTrait Instantiation *
107 \***************************************************************************/
109 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
110 PointerType FieldTraits<VisitSubTree *, nsOSG>::_type(
111 "VisitSubTreePtr",
112 "GroupPtr",
113 VisitSubTree::getClassType(),
114 nsOSG);
115 #endif
117 OSG_FIELDTRAITS_GETTYPE_NS(VisitSubTree *, nsOSG)
119 /***************************************************************************\
120 * Field Description *
121 \***************************************************************************/
123 void VisitSubTreeBase::classDescInserter(TypeObject &oType)
125 FieldDescriptionBase *pDesc = NULL;
128 pDesc = new SFWeakNodePtr::Description(
129 SFWeakNodePtr::getClassType(),
130 "subTreeRoot",
131 "Reference to the sub-graph to draw in place of this node.\n"
132 "Whatever node is pointed to will be drawn here as if it was duplicated\n"
133 "at this location.\n",
134 SubTreeRootFieldId, SubTreeRootFieldMask,
135 false,
136 (Field::SFDefaultFlags | Field::FCustomAccess),
137 static_cast<FieldEditMethodSig>(&VisitSubTree::editHandleSubTreeRoot),
138 static_cast<FieldGetMethodSig >(&VisitSubTree::getHandleSubTreeRoot));
140 oType.addInitialDesc(pDesc);
142 pDesc = new SFUInt32::Description(
143 SFUInt32::getClassType(),
144 "subTreeTravMask",
145 "This travmask will be used to update the action mask on traversal (and)\n",
146 SubTreeTravMaskFieldId, SubTreeTravMaskFieldMask,
147 false,
148 (Field::SFDefaultFlags | Field::FStdAccess),
149 static_cast<FieldEditMethodSig>(&VisitSubTree::editHandleSubTreeTravMask),
150 static_cast<FieldGetMethodSig >(&VisitSubTree::getHandleSubTreeTravMask));
152 oType.addInitialDesc(pDesc);
154 pDesc = new SFUInt32::Description(
155 SFUInt32::getClassType(),
156 "travMaskMode",
157 "This defines how the travmask will be used to update the action mask on \n"
158 "traversal\n",
159 TravMaskModeFieldId, TravMaskModeFieldMask,
160 false,
161 (Field::SFDefaultFlags | Field::FStdAccess),
162 static_cast<FieldEditMethodSig>(&VisitSubTree::editHandleTravMaskMode),
163 static_cast<FieldGetMethodSig >(&VisitSubTree::getHandleTravMaskMode));
165 oType.addInitialDesc(pDesc);
169 VisitSubTreeBase::TypeObject VisitSubTreeBase::_type(
170 VisitSubTreeBase::getClassname(),
171 Inherited::getClassname(),
172 "NULL",
173 nsOSG, //Namespace
174 reinterpret_cast<PrototypeCreateF>(&VisitSubTreeBase::createEmptyLocal),
175 reinterpret_cast<InitContainerF>(&VisitSubTree::initMethod),
176 reinterpret_cast<ExitContainerF>(&VisitSubTree::exitMethod),
177 reinterpret_cast<InitalInsertDescFunc>(
178 reinterpret_cast<void *>(&VisitSubTree::classDescInserter)),
179 false,
181 "<?xml version=\"1.0\"?>\n"
182 "\n"
183 "<FieldContainer\n"
184 " name=\"VisitSubTree\"\n"
185 " parent=\"Group\"\n"
186 " library=\"Group\"\n"
187 " pointerfieldtypes=\"none\"\n"
188 " structure=\"concrete\"\n"
189 " systemcomponent=\"true\"\n"
190 " parentsystemcomponent=\"true\"\n"
191 " decoratable=\"false\"\n"
192 " useLocalIncludes=\"false\"\n"
193 " isNodeCore=\"true\"\n"
194 " docGroupBase=\"GrpGroupMisc\"\n"
195 " >\n"
196 " VisitSubTree provides a way to point the renderer to another section of the\n"
197 " scene graph for rendering. This is useful for multi-pass algorithms using\n"
198 " OSG::Stage because it provides a way to render the same graph multiple times\n"
199 " without duplicating the nodes.\n"
200 " <Field\n"
201 " name=\"subTreeRoot\"\n"
202 " type=\"Node\"\n"
203 " category=\"weakpointer\"\n"
204 " cardinality=\"single\"\n"
205 " visibility=\"external\"\n"
206 " defaultValue=\"NULL\"\n"
207 " access=\"protected\"\n"
208 " ptrFieldAccess = \"custom\"\n"
209 " >\n"
210 " Reference to the sub-graph to draw in place of this node.\n"
211 " Whatever node is pointed to will be drawn here as if it was duplicated\n"
212 " at this location.\n"
213 " </Field>\n"
214 " <Field\n"
215 " name=\"subTreeTravMask\"\n"
216 " type=\"UInt32\"\n"
217 " cardinality=\"single\"\n"
218 " visibility=\"external\"\n"
219 " defaultValue=\"TypeTraits&lt;UInt32&gt;::getMax()\"\n"
220 " access=\"public\"\n"
221 " >\n"
222 " This travmask will be used to update the action mask on traversal (and)\n"
223 " </Field>\n"
224 " <Field\n"
225 " name=\"travMaskMode\"\n"
226 " type=\"UInt32\"\n"
227 " cardinality=\"single\"\n"
228 " visibility=\"external\"\n"
229 " defaultValue=\"VisitSubTree::AndTravMask\"\n"
230 " access=\"public\"\n"
231 " >\n"
232 " This defines how the travmask will be used to update the action mask on \n"
233 " traversal\n"
234 " </Field>\n"
235 "</FieldContainer>\n",
236 "VisitSubTree provides a way to point the renderer to another section of the\n"
237 "scene graph for rendering. This is useful for multi-pass algorithms using\n"
238 "OSG::Stage because it provides a way to render the same graph multiple times\n"
239 "without duplicating the nodes.\n"
242 /*------------------------------ get -----------------------------------*/
244 FieldContainerType &VisitSubTreeBase::getType(void)
246 return _type;
249 const FieldContainerType &VisitSubTreeBase::getType(void) const
251 return _type;
254 UInt32 VisitSubTreeBase::getContainerSize(void) const
256 return sizeof(VisitSubTree);
259 /*------------------------- decorator get ------------------------------*/
262 //! Get the VisitSubTree::_sfSubTreeRoot field.
263 const SFWeakNodePtr *VisitSubTreeBase::getSFSubTreeRoot(void) const
265 return &_sfSubTreeRoot;
268 //! Get the value of the VisitSubTree::_sfSubTreeRoot field.
269 Node * VisitSubTreeBase::getSubTreeRoot(void) const
271 return _sfSubTreeRoot.getValue();
276 SFUInt32 *VisitSubTreeBase::editSFSubTreeTravMask(void)
278 editSField(SubTreeTravMaskFieldMask);
280 return &_sfSubTreeTravMask;
283 const SFUInt32 *VisitSubTreeBase::getSFSubTreeTravMask(void) const
285 return &_sfSubTreeTravMask;
289 SFUInt32 *VisitSubTreeBase::editSFTravMaskMode(void)
291 editSField(TravMaskModeFieldMask);
293 return &_sfTravMaskMode;
296 const SFUInt32 *VisitSubTreeBase::getSFTravMaskMode(void) const
298 return &_sfTravMaskMode;
306 /*------------------------------ access -----------------------------------*/
308 SizeT VisitSubTreeBase::getBinSize(ConstFieldMaskArg whichField)
310 SizeT returnValue = Inherited::getBinSize(whichField);
312 if(FieldBits::NoField != (SubTreeRootFieldMask & whichField))
314 returnValue += _sfSubTreeRoot.getBinSize();
316 if(FieldBits::NoField != (SubTreeTravMaskFieldMask & whichField))
318 returnValue += _sfSubTreeTravMask.getBinSize();
320 if(FieldBits::NoField != (TravMaskModeFieldMask & whichField))
322 returnValue += _sfTravMaskMode.getBinSize();
325 return returnValue;
328 void VisitSubTreeBase::copyToBin(BinaryDataHandler &pMem,
329 ConstFieldMaskArg whichField)
331 Inherited::copyToBin(pMem, whichField);
333 if(FieldBits::NoField != (SubTreeRootFieldMask & whichField))
335 _sfSubTreeRoot.copyToBin(pMem);
337 if(FieldBits::NoField != (SubTreeTravMaskFieldMask & whichField))
339 _sfSubTreeTravMask.copyToBin(pMem);
341 if(FieldBits::NoField != (TravMaskModeFieldMask & whichField))
343 _sfTravMaskMode.copyToBin(pMem);
347 void VisitSubTreeBase::copyFromBin(BinaryDataHandler &pMem,
348 ConstFieldMaskArg whichField)
350 Inherited::copyFromBin(pMem, whichField);
352 if(FieldBits::NoField != (SubTreeRootFieldMask & whichField))
354 editSField(SubTreeRootFieldMask);
355 _sfSubTreeRoot.copyFromBin(pMem);
357 if(FieldBits::NoField != (SubTreeTravMaskFieldMask & whichField))
359 editSField(SubTreeTravMaskFieldMask);
360 _sfSubTreeTravMask.copyFromBin(pMem);
362 if(FieldBits::NoField != (TravMaskModeFieldMask & whichField))
364 editSField(TravMaskModeFieldMask);
365 _sfTravMaskMode.copyFromBin(pMem);
369 //! create a new instance of the class
370 VisitSubTreeTransitPtr VisitSubTreeBase::createLocal(BitVector bFlags)
372 VisitSubTreeTransitPtr fc;
374 if(getClassType().getPrototype() != NULL)
376 FieldContainerTransitPtr tmpPtr =
377 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
379 fc = dynamic_pointer_cast<VisitSubTree>(tmpPtr);
382 return fc;
385 //! create a new instance of the class, copy the container flags
386 VisitSubTreeTransitPtr VisitSubTreeBase::createDependent(BitVector bFlags)
388 VisitSubTreeTransitPtr fc;
390 if(getClassType().getPrototype() != NULL)
392 FieldContainerTransitPtr tmpPtr =
393 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
395 fc = dynamic_pointer_cast<VisitSubTree>(tmpPtr);
398 return fc;
401 //! create a new instance of the class
402 VisitSubTreeTransitPtr VisitSubTreeBase::create(void)
404 VisitSubTreeTransitPtr fc;
406 if(getClassType().getPrototype() != NULL)
408 FieldContainerTransitPtr tmpPtr =
409 getClassType().getPrototype()-> shallowCopy();
411 fc = dynamic_pointer_cast<VisitSubTree>(tmpPtr);
414 return fc;
417 VisitSubTree *VisitSubTreeBase::createEmptyLocal(BitVector bFlags)
419 VisitSubTree *returnValue;
421 newPtr<VisitSubTree>(returnValue, bFlags);
423 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
425 return returnValue;
428 //! create an empty new instance of the class, do not copy the prototype
429 VisitSubTree *VisitSubTreeBase::createEmpty(void)
431 VisitSubTree *returnValue;
433 newPtr<VisitSubTree>(returnValue, Thread::getCurrentLocalFlags());
435 returnValue->_pFieldFlags->_bNamespaceMask &=
436 ~Thread::getCurrentLocalFlags();
438 return returnValue;
442 FieldContainerTransitPtr VisitSubTreeBase::shallowCopyLocal(
443 BitVector bFlags) const
445 VisitSubTree *tmpPtr;
447 newPtr(tmpPtr, dynamic_cast<const VisitSubTree *>(this), bFlags);
449 FieldContainerTransitPtr returnValue(tmpPtr);
451 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
453 return returnValue;
456 FieldContainerTransitPtr VisitSubTreeBase::shallowCopyDependent(
457 BitVector bFlags) const
459 VisitSubTree *tmpPtr;
461 newPtr(tmpPtr, dynamic_cast<const VisitSubTree *>(this), ~bFlags);
463 FieldContainerTransitPtr returnValue(tmpPtr);
465 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
467 return returnValue;
470 FieldContainerTransitPtr VisitSubTreeBase::shallowCopy(void) const
472 VisitSubTree *tmpPtr;
474 newPtr(tmpPtr,
475 dynamic_cast<const VisitSubTree *>(this),
476 Thread::getCurrentLocalFlags());
478 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
480 FieldContainerTransitPtr returnValue(tmpPtr);
482 return returnValue;
488 /*------------------------- constructors ----------------------------------*/
490 VisitSubTreeBase::VisitSubTreeBase(void) :
491 Inherited(),
492 _sfSubTreeRoot (NULL),
493 _sfSubTreeTravMask (UInt32(TypeTraits<UInt32>::getMax())),
494 _sfTravMaskMode (UInt32(VisitSubTree::AndTravMask))
498 VisitSubTreeBase::VisitSubTreeBase(const VisitSubTreeBase &source) :
499 Inherited(source),
500 _sfSubTreeRoot (NULL),
501 _sfSubTreeTravMask (source._sfSubTreeTravMask ),
502 _sfTravMaskMode (source._sfTravMaskMode )
507 /*-------------------------- destructors ----------------------------------*/
509 VisitSubTreeBase::~VisitSubTreeBase(void)
513 void VisitSubTreeBase::onCreate(const VisitSubTree *source)
515 Inherited::onCreate(source);
517 if(source != NULL)
519 VisitSubTree *pThis = static_cast<VisitSubTree *>(this);
521 pThis->setSubTreeRoot(source->getSubTreeRoot());
525 GetFieldHandlePtr VisitSubTreeBase::getHandleSubTreeRoot (void) const
527 SFWeakNodePtr::GetHandlePtr returnValue(
528 new SFWeakNodePtr::GetHandle(
529 &_sfSubTreeRoot,
530 this->getType().getFieldDesc(SubTreeRootFieldId),
531 const_cast<VisitSubTreeBase *>(this)));
533 return returnValue;
536 EditFieldHandlePtr VisitSubTreeBase::editHandleSubTreeRoot (void)
538 SFWeakNodePtr::EditHandlePtr returnValue(
539 new SFWeakNodePtr::EditHandle(
540 &_sfSubTreeRoot,
541 this->getType().getFieldDesc(SubTreeRootFieldId),
542 this));
544 returnValue->setSetMethod(
545 boost::bind(&VisitSubTree::setSubTreeRoot,
546 static_cast<VisitSubTree *>(this), _1));
548 editSField(SubTreeRootFieldMask);
550 return returnValue;
553 GetFieldHandlePtr VisitSubTreeBase::getHandleSubTreeTravMask (void) const
555 SFUInt32::GetHandlePtr returnValue(
556 new SFUInt32::GetHandle(
557 &_sfSubTreeTravMask,
558 this->getType().getFieldDesc(SubTreeTravMaskFieldId),
559 const_cast<VisitSubTreeBase *>(this)));
561 return returnValue;
564 EditFieldHandlePtr VisitSubTreeBase::editHandleSubTreeTravMask(void)
566 SFUInt32::EditHandlePtr returnValue(
567 new SFUInt32::EditHandle(
568 &_sfSubTreeTravMask,
569 this->getType().getFieldDesc(SubTreeTravMaskFieldId),
570 this));
573 editSField(SubTreeTravMaskFieldMask);
575 return returnValue;
578 GetFieldHandlePtr VisitSubTreeBase::getHandleTravMaskMode (void) const
580 SFUInt32::GetHandlePtr returnValue(
581 new SFUInt32::GetHandle(
582 &_sfTravMaskMode,
583 this->getType().getFieldDesc(TravMaskModeFieldId),
584 const_cast<VisitSubTreeBase *>(this)));
586 return returnValue;
589 EditFieldHandlePtr VisitSubTreeBase::editHandleTravMaskMode (void)
591 SFUInt32::EditHandlePtr returnValue(
592 new SFUInt32::EditHandle(
593 &_sfTravMaskMode,
594 this->getType().getFieldDesc(TravMaskModeFieldId),
595 this));
598 editSField(TravMaskModeFieldMask);
600 return returnValue;
604 #ifdef OSG_MT_CPTR_ASPECT
605 void VisitSubTreeBase::execSyncV( FieldContainer &oFrom,
606 ConstFieldMaskArg whichField,
607 AspectOffsetStore &oOffsets,
608 ConstFieldMaskArg syncMode,
609 const UInt32 uiSyncInfo)
611 VisitSubTree *pThis = static_cast<VisitSubTree *>(this);
613 pThis->execSync(static_cast<VisitSubTree *>(&oFrom),
614 whichField,
615 oOffsets,
616 syncMode,
617 uiSyncInfo);
619 #endif
622 #ifdef OSG_MT_CPTR_ASPECT
623 FieldContainer *VisitSubTreeBase::createAspectCopy(
624 const FieldContainer *pRefAspect) const
626 VisitSubTree *returnValue;
628 newAspectCopy(returnValue,
629 dynamic_cast<const VisitSubTree *>(pRefAspect),
630 dynamic_cast<const VisitSubTree *>(this));
632 return returnValue;
634 #endif
636 void VisitSubTreeBase::resolveLinks(void)
638 Inherited::resolveLinks();
640 static_cast<VisitSubTree *>(this)->setSubTreeRoot(NULL);
646 OSG_END_NAMESPACE