fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / Cluster / Window / BalancedMultiWindow / OSGBalancedMultiWindowBase.cpp
blob8eb11660768801b66c11d9fc00acddbe0e4bcb9a
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 BalancedMultiWindow!
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"
66 #include "OSGBalancedMultiWindowBase.h"
67 #include "OSGBalancedMultiWindow.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::BalancedMultiWindow
78 Load balanced sort first rendering for multiple windows
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var bool BalancedMultiWindowBase::_sfBalance
86 If true load balancing is eanbled. If falst it behaves like a
87 MultiDisplayWindow
90 /*! \var bool BalancedMultiWindowBase::_sfBestCut
91 If true horizontal and vertical cuts are testet. Otherwise the longes side
92 of a viewport is split.
95 /*! \var bool BalancedMultiWindowBase::_sfShowBalancing
96 Mark regions rendered by other hosts
99 /*! \var UInt32 BalancedMultiWindowBase::_sfTileSize
103 /*! \var bool BalancedMultiWindowBase::_sfShort
108 /***************************************************************************\
109 * FieldType/FieldTrait Instantiation *
110 \***************************************************************************/
112 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
113 PointerType FieldTraits<BalancedMultiWindow *, nsOSG>::_type(
114 "BalancedMultiWindowPtr",
115 "MultiDisplayWindowPtr",
116 BalancedMultiWindow::getClassType(),
117 nsOSG);
118 #endif
120 OSG_FIELDTRAITS_GETTYPE_NS(BalancedMultiWindow *, nsOSG)
122 /***************************************************************************\
123 * Field Description *
124 \***************************************************************************/
126 void BalancedMultiWindowBase::classDescInserter(TypeObject &oType)
128 FieldDescriptionBase *pDesc = NULL;
131 pDesc = new SFBool::Description(
132 SFBool::getClassType(),
133 "balance",
134 "If true load balancing is eanbled. If falst it behaves like a\n"
135 "MultiDisplayWindow \n",
136 BalanceFieldId, BalanceFieldMask,
137 false,
138 (Field::SFDefaultFlags | Field::FStdAccess),
139 static_cast<FieldEditMethodSig>(&BalancedMultiWindow::editHandleBalance),
140 static_cast<FieldGetMethodSig >(&BalancedMultiWindow::getHandleBalance));
142 oType.addInitialDesc(pDesc);
144 pDesc = new SFBool::Description(
145 SFBool::getClassType(),
146 "bestCut",
147 "If true horizontal and vertical cuts are testet. Otherwise the longes side\n"
148 "of a viewport is split. \n",
149 BestCutFieldId, BestCutFieldMask,
150 false,
151 (Field::SFDefaultFlags | Field::FStdAccess),
152 static_cast<FieldEditMethodSig>(&BalancedMultiWindow::editHandleBestCut),
153 static_cast<FieldGetMethodSig >(&BalancedMultiWindow::getHandleBestCut));
155 oType.addInitialDesc(pDesc);
157 pDesc = new SFBool::Description(
158 SFBool::getClassType(),
159 "showBalancing",
160 "Mark regions rendered by other hosts\n",
161 ShowBalancingFieldId, ShowBalancingFieldMask,
162 false,
163 (Field::SFDefaultFlags | Field::FStdAccess),
164 static_cast<FieldEditMethodSig>(&BalancedMultiWindow::editHandleShowBalancing),
165 static_cast<FieldGetMethodSig >(&BalancedMultiWindow::getHandleShowBalancing));
167 oType.addInitialDesc(pDesc);
169 pDesc = new SFUInt32::Description(
170 SFUInt32::getClassType(),
171 "tileSize",
173 TileSizeFieldId, TileSizeFieldMask,
174 false,
175 (Field::SFDefaultFlags | Field::FStdAccess),
176 static_cast<FieldEditMethodSig>(&BalancedMultiWindow::editHandleTileSize),
177 static_cast<FieldGetMethodSig >(&BalancedMultiWindow::getHandleTileSize));
179 oType.addInitialDesc(pDesc);
181 pDesc = new SFBool::Description(
182 SFBool::getClassType(),
183 "short",
185 ShortFieldId, ShortFieldMask,
186 false,
187 (Field::SFDefaultFlags | Field::FStdAccess),
188 static_cast<FieldEditMethodSig>(&BalancedMultiWindow::editHandleShort),
189 static_cast<FieldGetMethodSig >(&BalancedMultiWindow::getHandleShort));
191 oType.addInitialDesc(pDesc);
195 BalancedMultiWindowBase::TypeObject BalancedMultiWindowBase::_type(
196 BalancedMultiWindowBase::getClassname(),
197 Inherited::getClassname(),
198 "NULL",
199 nsOSG, //Namespace
200 reinterpret_cast<PrototypeCreateF>(&BalancedMultiWindowBase::createEmptyLocal),
201 reinterpret_cast<InitContainerF>(&BalancedMultiWindow::initMethod),
202 reinterpret_cast<ExitContainerF>(&BalancedMultiWindow::exitMethod),
203 reinterpret_cast<InitalInsertDescFunc>(
204 reinterpret_cast<void *>(&BalancedMultiWindow::classDescInserter)),
205 false,
207 "<?xml version=\"1.0\"?>\n"
208 "\n"
209 "<FieldContainer\n"
210 " name=\"BalancedMultiWindow\"\n"
211 " parent=\"MultiDisplayWindow\"\n"
212 " library=\"Cluster\"\n"
213 " pointerfieldtypes=\"none\"\n"
214 " structure=\"concrete\"\n"
215 " systemcomponent=\"true\"\n"
216 " parentsystemcomponent=\"true\"\n"
217 " decoratable=\"false\"\n"
218 " useLocalIncludes=\"true\"\n"
219 " docGroupBase=\"GrpClusterWindow\"\n"
220 " >\n"
221 " Load balanced sort first rendering for multiple windows\n"
222 " <Field\n"
223 "\t name=\"balance\"\n"
224 "\t type=\"bool\"\n"
225 "\t cardinality=\"single\"\n"
226 "\t visibility=\"external\"\n"
227 "\t defaultValue=\"true\"\n"
228 "\t access=\"public\"\n"
229 "\t >\n"
230 "\tIf true load balancing is eanbled. If falst it behaves like a\n"
231 "\tMultiDisplayWindow \n"
232 " </Field>\n"
233 " <Field\n"
234 "\t name=\"bestCut\"\n"
235 "\t type=\"bool\"\n"
236 "\t cardinality=\"single\"\n"
237 "\t visibility=\"external\"\n"
238 "\t defaultValue=\"true\"\n"
239 "\t access=\"public\"\n"
240 "\t >\n"
241 "\tIf true horizontal and vertical cuts are testet. Otherwise the longes side\n"
242 "\tof a viewport is split. \n"
243 " </Field>\n"
244 " <Field\n"
245 "\t name=\"showBalancing\"\n"
246 "\t type=\"bool\"\n"
247 "\t cardinality=\"single\"\n"
248 "\t visibility=\"external\"\n"
249 "\t defaultValue=\"false\"\n"
250 "\t access=\"public\"\n"
251 "\t >\n"
252 "\tMark regions rendered by other hosts\n"
253 " </Field>\n"
254 " <Field\n"
255 "\t name=\"tileSize\"\n"
256 "\t type=\"UInt32\"\n"
257 "\t cardinality=\"single\"\n"
258 "\t visibility=\"external\"\n"
259 "\t defaultValue=\"44\"\n"
260 "\t access=\"public\"\n"
261 "\t >\n"
262 " </Field>\n"
263 " <Field\n"
264 "\t name=\"short\"\n"
265 "\t type=\"bool\"\n"
266 "\t cardinality=\"single\"\n"
267 "\t visibility=\"external\"\n"
268 "\t defaultValue=\"true\"\n"
269 "\t access=\"public\"\n"
270 "\t >\n"
271 " </Field>\n"
272 "</FieldContainer>\n",
273 "Load balanced sort first rendering for multiple windows\n"
276 /*------------------------------ get -----------------------------------*/
278 FieldContainerType &BalancedMultiWindowBase::getType(void)
280 return _type;
283 const FieldContainerType &BalancedMultiWindowBase::getType(void) const
285 return _type;
288 UInt32 BalancedMultiWindowBase::getContainerSize(void) const
290 return sizeof(BalancedMultiWindow);
293 /*------------------------- decorator get ------------------------------*/
296 SFBool *BalancedMultiWindowBase::editSFBalance(void)
298 editSField(BalanceFieldMask);
300 return &_sfBalance;
303 const SFBool *BalancedMultiWindowBase::getSFBalance(void) const
305 return &_sfBalance;
309 SFBool *BalancedMultiWindowBase::editSFBestCut(void)
311 editSField(BestCutFieldMask);
313 return &_sfBestCut;
316 const SFBool *BalancedMultiWindowBase::getSFBestCut(void) const
318 return &_sfBestCut;
322 SFBool *BalancedMultiWindowBase::editSFShowBalancing(void)
324 editSField(ShowBalancingFieldMask);
326 return &_sfShowBalancing;
329 const SFBool *BalancedMultiWindowBase::getSFShowBalancing(void) const
331 return &_sfShowBalancing;
335 SFUInt32 *BalancedMultiWindowBase::editSFTileSize(void)
337 editSField(TileSizeFieldMask);
339 return &_sfTileSize;
342 const SFUInt32 *BalancedMultiWindowBase::getSFTileSize(void) const
344 return &_sfTileSize;
348 SFBool *BalancedMultiWindowBase::editSFShort(void)
350 editSField(ShortFieldMask);
352 return &_sfShort;
355 const SFBool *BalancedMultiWindowBase::getSFShort(void) const
357 return &_sfShort;
365 /*------------------------------ access -----------------------------------*/
367 SizeT BalancedMultiWindowBase::getBinSize(ConstFieldMaskArg whichField)
369 SizeT returnValue = Inherited::getBinSize(whichField);
371 if(FieldBits::NoField != (BalanceFieldMask & whichField))
373 returnValue += _sfBalance.getBinSize();
375 if(FieldBits::NoField != (BestCutFieldMask & whichField))
377 returnValue += _sfBestCut.getBinSize();
379 if(FieldBits::NoField != (ShowBalancingFieldMask & whichField))
381 returnValue += _sfShowBalancing.getBinSize();
383 if(FieldBits::NoField != (TileSizeFieldMask & whichField))
385 returnValue += _sfTileSize.getBinSize();
387 if(FieldBits::NoField != (ShortFieldMask & whichField))
389 returnValue += _sfShort.getBinSize();
392 return returnValue;
395 void BalancedMultiWindowBase::copyToBin(BinaryDataHandler &pMem,
396 ConstFieldMaskArg whichField)
398 Inherited::copyToBin(pMem, whichField);
400 if(FieldBits::NoField != (BalanceFieldMask & whichField))
402 _sfBalance.copyToBin(pMem);
404 if(FieldBits::NoField != (BestCutFieldMask & whichField))
406 _sfBestCut.copyToBin(pMem);
408 if(FieldBits::NoField != (ShowBalancingFieldMask & whichField))
410 _sfShowBalancing.copyToBin(pMem);
412 if(FieldBits::NoField != (TileSizeFieldMask & whichField))
414 _sfTileSize.copyToBin(pMem);
416 if(FieldBits::NoField != (ShortFieldMask & whichField))
418 _sfShort.copyToBin(pMem);
422 void BalancedMultiWindowBase::copyFromBin(BinaryDataHandler &pMem,
423 ConstFieldMaskArg whichField)
425 Inherited::copyFromBin(pMem, whichField);
427 if(FieldBits::NoField != (BalanceFieldMask & whichField))
429 editSField(BalanceFieldMask);
430 _sfBalance.copyFromBin(pMem);
432 if(FieldBits::NoField != (BestCutFieldMask & whichField))
434 editSField(BestCutFieldMask);
435 _sfBestCut.copyFromBin(pMem);
437 if(FieldBits::NoField != (ShowBalancingFieldMask & whichField))
439 editSField(ShowBalancingFieldMask);
440 _sfShowBalancing.copyFromBin(pMem);
442 if(FieldBits::NoField != (TileSizeFieldMask & whichField))
444 editSField(TileSizeFieldMask);
445 _sfTileSize.copyFromBin(pMem);
447 if(FieldBits::NoField != (ShortFieldMask & whichField))
449 editSField(ShortFieldMask);
450 _sfShort.copyFromBin(pMem);
454 //! create a new instance of the class
455 BalancedMultiWindowTransitPtr BalancedMultiWindowBase::createLocal(BitVector bFlags)
457 BalancedMultiWindowTransitPtr fc;
459 if(getClassType().getPrototype() != NULL)
461 FieldContainerTransitPtr tmpPtr =
462 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
464 fc = dynamic_pointer_cast<BalancedMultiWindow>(tmpPtr);
467 return fc;
470 //! create a new instance of the class, copy the container flags
471 BalancedMultiWindowTransitPtr BalancedMultiWindowBase::createDependent(BitVector bFlags)
473 BalancedMultiWindowTransitPtr fc;
475 if(getClassType().getPrototype() != NULL)
477 FieldContainerTransitPtr tmpPtr =
478 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
480 fc = dynamic_pointer_cast<BalancedMultiWindow>(tmpPtr);
483 return fc;
486 //! create a new instance of the class
487 BalancedMultiWindowTransitPtr BalancedMultiWindowBase::create(void)
489 BalancedMultiWindowTransitPtr fc;
491 if(getClassType().getPrototype() != NULL)
493 FieldContainerTransitPtr tmpPtr =
494 getClassType().getPrototype()-> shallowCopy();
496 fc = dynamic_pointer_cast<BalancedMultiWindow>(tmpPtr);
499 return fc;
502 BalancedMultiWindow *BalancedMultiWindowBase::createEmptyLocal(BitVector bFlags)
504 BalancedMultiWindow *returnValue;
506 newPtr<BalancedMultiWindow>(returnValue, bFlags);
508 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
510 return returnValue;
513 //! create an empty new instance of the class, do not copy the prototype
514 BalancedMultiWindow *BalancedMultiWindowBase::createEmpty(void)
516 BalancedMultiWindow *returnValue;
518 newPtr<BalancedMultiWindow>(returnValue, Thread::getCurrentLocalFlags());
520 returnValue->_pFieldFlags->_bNamespaceMask &=
521 ~Thread::getCurrentLocalFlags();
523 return returnValue;
527 FieldContainerTransitPtr BalancedMultiWindowBase::shallowCopyLocal(
528 BitVector bFlags) const
530 BalancedMultiWindow *tmpPtr;
532 newPtr(tmpPtr, dynamic_cast<const BalancedMultiWindow *>(this), bFlags);
534 FieldContainerTransitPtr returnValue(tmpPtr);
536 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
538 return returnValue;
541 FieldContainerTransitPtr BalancedMultiWindowBase::shallowCopyDependent(
542 BitVector bFlags) const
544 BalancedMultiWindow *tmpPtr;
546 newPtr(tmpPtr, dynamic_cast<const BalancedMultiWindow *>(this), ~bFlags);
548 FieldContainerTransitPtr returnValue(tmpPtr);
550 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
552 return returnValue;
555 FieldContainerTransitPtr BalancedMultiWindowBase::shallowCopy(void) const
557 BalancedMultiWindow *tmpPtr;
559 newPtr(tmpPtr,
560 dynamic_cast<const BalancedMultiWindow *>(this),
561 Thread::getCurrentLocalFlags());
563 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
565 FieldContainerTransitPtr returnValue(tmpPtr);
567 return returnValue;
573 /*------------------------- constructors ----------------------------------*/
575 BalancedMultiWindowBase::BalancedMultiWindowBase(void) :
576 Inherited(),
577 _sfBalance (bool(true)),
578 _sfBestCut (bool(true)),
579 _sfShowBalancing (bool(false)),
580 _sfTileSize (UInt32(44)),
581 _sfShort (bool(true))
585 BalancedMultiWindowBase::BalancedMultiWindowBase(const BalancedMultiWindowBase &source) :
586 Inherited(source),
587 _sfBalance (source._sfBalance ),
588 _sfBestCut (source._sfBestCut ),
589 _sfShowBalancing (source._sfShowBalancing ),
590 _sfTileSize (source._sfTileSize ),
591 _sfShort (source._sfShort )
596 /*-------------------------- destructors ----------------------------------*/
598 BalancedMultiWindowBase::~BalancedMultiWindowBase(void)
603 GetFieldHandlePtr BalancedMultiWindowBase::getHandleBalance (void) const
605 SFBool::GetHandlePtr returnValue(
606 new SFBool::GetHandle(
607 &_sfBalance,
608 this->getType().getFieldDesc(BalanceFieldId),
609 const_cast<BalancedMultiWindowBase *>(this)));
611 return returnValue;
614 EditFieldHandlePtr BalancedMultiWindowBase::editHandleBalance (void)
616 SFBool::EditHandlePtr returnValue(
617 new SFBool::EditHandle(
618 &_sfBalance,
619 this->getType().getFieldDesc(BalanceFieldId),
620 this));
623 editSField(BalanceFieldMask);
625 return returnValue;
628 GetFieldHandlePtr BalancedMultiWindowBase::getHandleBestCut (void) const
630 SFBool::GetHandlePtr returnValue(
631 new SFBool::GetHandle(
632 &_sfBestCut,
633 this->getType().getFieldDesc(BestCutFieldId),
634 const_cast<BalancedMultiWindowBase *>(this)));
636 return returnValue;
639 EditFieldHandlePtr BalancedMultiWindowBase::editHandleBestCut (void)
641 SFBool::EditHandlePtr returnValue(
642 new SFBool::EditHandle(
643 &_sfBestCut,
644 this->getType().getFieldDesc(BestCutFieldId),
645 this));
648 editSField(BestCutFieldMask);
650 return returnValue;
653 GetFieldHandlePtr BalancedMultiWindowBase::getHandleShowBalancing (void) const
655 SFBool::GetHandlePtr returnValue(
656 new SFBool::GetHandle(
657 &_sfShowBalancing,
658 this->getType().getFieldDesc(ShowBalancingFieldId),
659 const_cast<BalancedMultiWindowBase *>(this)));
661 return returnValue;
664 EditFieldHandlePtr BalancedMultiWindowBase::editHandleShowBalancing (void)
666 SFBool::EditHandlePtr returnValue(
667 new SFBool::EditHandle(
668 &_sfShowBalancing,
669 this->getType().getFieldDesc(ShowBalancingFieldId),
670 this));
673 editSField(ShowBalancingFieldMask);
675 return returnValue;
678 GetFieldHandlePtr BalancedMultiWindowBase::getHandleTileSize (void) const
680 SFUInt32::GetHandlePtr returnValue(
681 new SFUInt32::GetHandle(
682 &_sfTileSize,
683 this->getType().getFieldDesc(TileSizeFieldId),
684 const_cast<BalancedMultiWindowBase *>(this)));
686 return returnValue;
689 EditFieldHandlePtr BalancedMultiWindowBase::editHandleTileSize (void)
691 SFUInt32::EditHandlePtr returnValue(
692 new SFUInt32::EditHandle(
693 &_sfTileSize,
694 this->getType().getFieldDesc(TileSizeFieldId),
695 this));
698 editSField(TileSizeFieldMask);
700 return returnValue;
703 GetFieldHandlePtr BalancedMultiWindowBase::getHandleShort (void) const
705 SFBool::GetHandlePtr returnValue(
706 new SFBool::GetHandle(
707 &_sfShort,
708 this->getType().getFieldDesc(ShortFieldId),
709 const_cast<BalancedMultiWindowBase *>(this)));
711 return returnValue;
714 EditFieldHandlePtr BalancedMultiWindowBase::editHandleShort (void)
716 SFBool::EditHandlePtr returnValue(
717 new SFBool::EditHandle(
718 &_sfShort,
719 this->getType().getFieldDesc(ShortFieldId),
720 this));
723 editSField(ShortFieldMask);
725 return returnValue;
729 #ifdef OSG_MT_CPTR_ASPECT
730 void BalancedMultiWindowBase::execSyncV( FieldContainer &oFrom,
731 ConstFieldMaskArg whichField,
732 AspectOffsetStore &oOffsets,
733 ConstFieldMaskArg syncMode,
734 const UInt32 uiSyncInfo)
736 BalancedMultiWindow *pThis = static_cast<BalancedMultiWindow *>(this);
738 pThis->execSync(static_cast<BalancedMultiWindow *>(&oFrom),
739 whichField,
740 oOffsets,
741 syncMode,
742 uiSyncInfo);
744 #endif
747 #ifdef OSG_MT_CPTR_ASPECT
748 FieldContainer *BalancedMultiWindowBase::createAspectCopy(
749 const FieldContainer *pRefAspect) const
751 BalancedMultiWindow *returnValue;
753 newAspectCopy(returnValue,
754 dynamic_cast<const BalancedMultiWindow *>(pRefAspect),
755 dynamic_cast<const BalancedMultiWindow *>(this));
757 return returnValue;
759 #endif
761 void BalancedMultiWindowBase::resolveLinks(void)
763 Inherited::resolveLinks();
769 OSG_END_NAMESPACE