fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Base / OSGColorMaskChunkBase.cpp
blob63176096e25c0d68afb252f7f2bcceb40c7acb32
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 ColorMaskChunk!
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 "OSGColorMaskChunkBase.h"
67 #include "OSGColorMaskChunk.h"
69 #include <boost/bind.hpp>
71 OSG_BEGIN_NAMESPACE
73 /***************************************************************************\
74 * Description *
75 \***************************************************************************/
77 /*! \class OSG::ColorMaskChunk
78 The color mask chunk contains the parameters that are specific for color writing.
81 /***************************************************************************\
82 * Field Documentation *
83 \***************************************************************************/
85 /*! \var bool ColorMaskChunkBase::_sfMaskR
86 Used to mask the writing of the R value to the color buffer.
89 /*! \var bool ColorMaskChunkBase::_sfMaskG
90 Used to mask the writing of the G value to the color buffer.
93 /*! \var bool ColorMaskChunkBase::_sfMaskB
94 Used to mask the writing of the B value to the color buffer.
97 /*! \var bool ColorMaskChunkBase::_sfMaskA
98 Used to mask the writing of the A value to the color buffer.
102 /***************************************************************************\
103 * FieldType/FieldTrait Instantiation *
104 \***************************************************************************/
106 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
107 PointerType FieldTraits<ColorMaskChunk *, nsOSG>::_type(
108 "ColorMaskChunkPtr",
109 "StateChunkPtr",
110 ColorMaskChunk::getClassType(),
111 nsOSG);
112 #endif
114 OSG_FIELDTRAITS_GETTYPE_NS(ColorMaskChunk *, nsOSG)
116 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
117 ColorMaskChunk *,
118 nsOSG)
120 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
121 ColorMaskChunk *,
122 nsOSG)
124 /***************************************************************************\
125 * Field Description *
126 \***************************************************************************/
128 void ColorMaskChunkBase::classDescInserter(TypeObject &oType)
130 FieldDescriptionBase *pDesc = NULL;
133 pDesc = new SFBool::Description(
134 SFBool::getClassType(),
135 "maskR",
136 "Used to mask the writing of the R value to the color buffer.\n",
137 MaskRFieldId, MaskRFieldMask,
138 false,
139 (Field::SFDefaultFlags | Field::FStdAccess),
140 static_cast<FieldEditMethodSig>(&ColorMaskChunk::editHandleMaskR),
141 static_cast<FieldGetMethodSig >(&ColorMaskChunk::getHandleMaskR));
143 oType.addInitialDesc(pDesc);
145 pDesc = new SFBool::Description(
146 SFBool::getClassType(),
147 "maskG",
148 "Used to mask the writing of the G value to the color buffer.\n",
149 MaskGFieldId, MaskGFieldMask,
150 false,
151 (Field::SFDefaultFlags | Field::FStdAccess),
152 static_cast<FieldEditMethodSig>(&ColorMaskChunk::editHandleMaskG),
153 static_cast<FieldGetMethodSig >(&ColorMaskChunk::getHandleMaskG));
155 oType.addInitialDesc(pDesc);
157 pDesc = new SFBool::Description(
158 SFBool::getClassType(),
159 "maskB",
160 "Used to mask the writing of the B value to the color buffer.\n",
161 MaskBFieldId, MaskBFieldMask,
162 false,
163 (Field::SFDefaultFlags | Field::FStdAccess),
164 static_cast<FieldEditMethodSig>(&ColorMaskChunk::editHandleMaskB),
165 static_cast<FieldGetMethodSig >(&ColorMaskChunk::getHandleMaskB));
167 oType.addInitialDesc(pDesc);
169 pDesc = new SFBool::Description(
170 SFBool::getClassType(),
171 "maskA",
172 "Used to mask the writing of the A value to the color buffer.\n",
173 MaskAFieldId, MaskAFieldMask,
174 false,
175 (Field::SFDefaultFlags | Field::FStdAccess),
176 static_cast<FieldEditMethodSig>(&ColorMaskChunk::editHandleMaskA),
177 static_cast<FieldGetMethodSig >(&ColorMaskChunk::getHandleMaskA));
179 oType.addInitialDesc(pDesc);
183 ColorMaskChunkBase::TypeObject ColorMaskChunkBase::_type(
184 ColorMaskChunkBase::getClassname(),
185 Inherited::getClassname(),
186 "NULL",
187 nsOSG, //Namespace
188 reinterpret_cast<PrototypeCreateF>(&ColorMaskChunkBase::createEmptyLocal),
189 reinterpret_cast<InitContainerF>(&ColorMaskChunk::initMethod),
190 reinterpret_cast<ExitContainerF>(&ColorMaskChunk::exitMethod),
191 reinterpret_cast<InitalInsertDescFunc>(
192 reinterpret_cast<void *>(&ColorMaskChunk::classDescInserter)),
193 false,
195 "<?xml version=\"1.0\"?>\n"
196 "\n"
197 "<FieldContainer\n"
198 " name=\"ColorMaskChunk\"\n"
199 " parent=\"StateChunk\"\n"
200 " library=\"System\"\n"
201 " pointerfieldtypes=\"both\"\n"
202 " structure=\"concrete\"\n"
203 " systemcomponent=\"true\"\n"
204 " parentsystemcomponent=\"true\"\n"
205 " decoratable=\"false\"\n"
206 " useLocalIncludes=\"false\"\n"
207 " docGroupBase=\"GrpSystemState\"\n"
208 ">\n"
209 "The color mask chunk contains the parameters that are specific for color writing.\n"
210 "\t<Field\n"
211 "\t\tname=\"maskR\"\n"
212 "\t\ttype=\"bool\"\n"
213 "\t\tcardinality=\"single\"\n"
214 "\t\tvisibility=\"external\"\n"
215 "\t\tdefaultValue=\"true\"\n"
216 "\t\taccess=\"public\"\n"
217 "\t>\n"
218 "\tUsed to mask the writing of the R value to the color buffer.\n"
219 "\t</Field>\n"
220 "\t<Field\n"
221 "\t\tname=\"maskG\"\n"
222 "\t\ttype=\"bool\"\n"
223 "\t\tcardinality=\"single\"\n"
224 "\t\tvisibility=\"external\"\n"
225 "\t\tdefaultValue=\"true\"\n"
226 "\t\taccess=\"public\"\n"
227 "\t>\n"
228 "\tUsed to mask the writing of the G value to the color buffer.\n"
229 "\t</Field>\n"
230 "\t<Field\n"
231 "\t\tname=\"maskB\"\n"
232 "\t\ttype=\"bool\"\n"
233 "\t\tcardinality=\"single\"\n"
234 "\t\tvisibility=\"external\"\n"
235 "\t\tdefaultValue=\"true\"\n"
236 "\t\taccess=\"public\"\n"
237 "\t>\n"
238 "\tUsed to mask the writing of the B value to the color buffer.\n"
239 "\t</Field>\n"
240 "\t<Field\n"
241 "\t\tname=\"maskA\"\n"
242 "\t\ttype=\"bool\"\n"
243 "\t\tcardinality=\"single\"\n"
244 "\t\tvisibility=\"external\"\n"
245 "\t\tdefaultValue=\"true\"\n"
246 "\t\taccess=\"public\"\n"
247 "\t>\n"
248 "\tUsed to mask the writing of the A value to the color buffer.\n"
249 "\t</Field>\n"
250 "</FieldContainer>\n",
251 "The color mask chunk contains the parameters that are specific for color writing.\n"
254 /*------------------------------ get -----------------------------------*/
256 FieldContainerType &ColorMaskChunkBase::getType(void)
258 return _type;
261 const FieldContainerType &ColorMaskChunkBase::getType(void) const
263 return _type;
266 UInt32 ColorMaskChunkBase::getContainerSize(void) const
268 return sizeof(ColorMaskChunk);
271 /*------------------------- decorator get ------------------------------*/
274 SFBool *ColorMaskChunkBase::editSFMaskR(void)
276 editSField(MaskRFieldMask);
278 return &_sfMaskR;
281 const SFBool *ColorMaskChunkBase::getSFMaskR(void) const
283 return &_sfMaskR;
287 SFBool *ColorMaskChunkBase::editSFMaskG(void)
289 editSField(MaskGFieldMask);
291 return &_sfMaskG;
294 const SFBool *ColorMaskChunkBase::getSFMaskG(void) const
296 return &_sfMaskG;
300 SFBool *ColorMaskChunkBase::editSFMaskB(void)
302 editSField(MaskBFieldMask);
304 return &_sfMaskB;
307 const SFBool *ColorMaskChunkBase::getSFMaskB(void) const
309 return &_sfMaskB;
313 SFBool *ColorMaskChunkBase::editSFMaskA(void)
315 editSField(MaskAFieldMask);
317 return &_sfMaskA;
320 const SFBool *ColorMaskChunkBase::getSFMaskA(void) const
322 return &_sfMaskA;
330 /*------------------------------ access -----------------------------------*/
332 SizeT ColorMaskChunkBase::getBinSize(ConstFieldMaskArg whichField)
334 SizeT returnValue = Inherited::getBinSize(whichField);
336 if(FieldBits::NoField != (MaskRFieldMask & whichField))
338 returnValue += _sfMaskR.getBinSize();
340 if(FieldBits::NoField != (MaskGFieldMask & whichField))
342 returnValue += _sfMaskG.getBinSize();
344 if(FieldBits::NoField != (MaskBFieldMask & whichField))
346 returnValue += _sfMaskB.getBinSize();
348 if(FieldBits::NoField != (MaskAFieldMask & whichField))
350 returnValue += _sfMaskA.getBinSize();
353 return returnValue;
356 void ColorMaskChunkBase::copyToBin(BinaryDataHandler &pMem,
357 ConstFieldMaskArg whichField)
359 Inherited::copyToBin(pMem, whichField);
361 if(FieldBits::NoField != (MaskRFieldMask & whichField))
363 _sfMaskR.copyToBin(pMem);
365 if(FieldBits::NoField != (MaskGFieldMask & whichField))
367 _sfMaskG.copyToBin(pMem);
369 if(FieldBits::NoField != (MaskBFieldMask & whichField))
371 _sfMaskB.copyToBin(pMem);
373 if(FieldBits::NoField != (MaskAFieldMask & whichField))
375 _sfMaskA.copyToBin(pMem);
379 void ColorMaskChunkBase::copyFromBin(BinaryDataHandler &pMem,
380 ConstFieldMaskArg whichField)
382 Inherited::copyFromBin(pMem, whichField);
384 if(FieldBits::NoField != (MaskRFieldMask & whichField))
386 editSField(MaskRFieldMask);
387 _sfMaskR.copyFromBin(pMem);
389 if(FieldBits::NoField != (MaskGFieldMask & whichField))
391 editSField(MaskGFieldMask);
392 _sfMaskG.copyFromBin(pMem);
394 if(FieldBits::NoField != (MaskBFieldMask & whichField))
396 editSField(MaskBFieldMask);
397 _sfMaskB.copyFromBin(pMem);
399 if(FieldBits::NoField != (MaskAFieldMask & whichField))
401 editSField(MaskAFieldMask);
402 _sfMaskA.copyFromBin(pMem);
406 //! create a new instance of the class
407 ColorMaskChunkTransitPtr ColorMaskChunkBase::createLocal(BitVector bFlags)
409 ColorMaskChunkTransitPtr fc;
411 if(getClassType().getPrototype() != NULL)
413 FieldContainerTransitPtr tmpPtr =
414 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
416 fc = dynamic_pointer_cast<ColorMaskChunk>(tmpPtr);
419 return fc;
422 //! create a new instance of the class, copy the container flags
423 ColorMaskChunkTransitPtr ColorMaskChunkBase::createDependent(BitVector bFlags)
425 ColorMaskChunkTransitPtr fc;
427 if(getClassType().getPrototype() != NULL)
429 FieldContainerTransitPtr tmpPtr =
430 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
432 fc = dynamic_pointer_cast<ColorMaskChunk>(tmpPtr);
435 return fc;
438 //! create a new instance of the class
439 ColorMaskChunkTransitPtr ColorMaskChunkBase::create(void)
441 ColorMaskChunkTransitPtr fc;
443 if(getClassType().getPrototype() != NULL)
445 FieldContainerTransitPtr tmpPtr =
446 getClassType().getPrototype()-> shallowCopy();
448 fc = dynamic_pointer_cast<ColorMaskChunk>(tmpPtr);
451 return fc;
454 ColorMaskChunk *ColorMaskChunkBase::createEmptyLocal(BitVector bFlags)
456 ColorMaskChunk *returnValue;
458 newPtr<ColorMaskChunk>(returnValue, bFlags);
460 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
462 return returnValue;
465 //! create an empty new instance of the class, do not copy the prototype
466 ColorMaskChunk *ColorMaskChunkBase::createEmpty(void)
468 ColorMaskChunk *returnValue;
470 newPtr<ColorMaskChunk>(returnValue, Thread::getCurrentLocalFlags());
472 returnValue->_pFieldFlags->_bNamespaceMask &=
473 ~Thread::getCurrentLocalFlags();
475 return returnValue;
479 FieldContainerTransitPtr ColorMaskChunkBase::shallowCopyLocal(
480 BitVector bFlags) const
482 ColorMaskChunk *tmpPtr;
484 newPtr(tmpPtr, dynamic_cast<const ColorMaskChunk *>(this), bFlags);
486 FieldContainerTransitPtr returnValue(tmpPtr);
488 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
490 return returnValue;
493 FieldContainerTransitPtr ColorMaskChunkBase::shallowCopyDependent(
494 BitVector bFlags) const
496 ColorMaskChunk *tmpPtr;
498 newPtr(tmpPtr, dynamic_cast<const ColorMaskChunk *>(this), ~bFlags);
500 FieldContainerTransitPtr returnValue(tmpPtr);
502 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
504 return returnValue;
507 FieldContainerTransitPtr ColorMaskChunkBase::shallowCopy(void) const
509 ColorMaskChunk *tmpPtr;
511 newPtr(tmpPtr,
512 dynamic_cast<const ColorMaskChunk *>(this),
513 Thread::getCurrentLocalFlags());
515 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
517 FieldContainerTransitPtr returnValue(tmpPtr);
519 return returnValue;
525 /*------------------------- constructors ----------------------------------*/
527 ColorMaskChunkBase::ColorMaskChunkBase(void) :
528 Inherited(),
529 _sfMaskR (bool(true)),
530 _sfMaskG (bool(true)),
531 _sfMaskB (bool(true)),
532 _sfMaskA (bool(true))
536 ColorMaskChunkBase::ColorMaskChunkBase(const ColorMaskChunkBase &source) :
537 Inherited(source),
538 _sfMaskR (source._sfMaskR ),
539 _sfMaskG (source._sfMaskG ),
540 _sfMaskB (source._sfMaskB ),
541 _sfMaskA (source._sfMaskA )
546 /*-------------------------- destructors ----------------------------------*/
548 ColorMaskChunkBase::~ColorMaskChunkBase(void)
553 GetFieldHandlePtr ColorMaskChunkBase::getHandleMaskR (void) const
555 SFBool::GetHandlePtr returnValue(
556 new SFBool::GetHandle(
557 &_sfMaskR,
558 this->getType().getFieldDesc(MaskRFieldId),
559 const_cast<ColorMaskChunkBase *>(this)));
561 return returnValue;
564 EditFieldHandlePtr ColorMaskChunkBase::editHandleMaskR (void)
566 SFBool::EditHandlePtr returnValue(
567 new SFBool::EditHandle(
568 &_sfMaskR,
569 this->getType().getFieldDesc(MaskRFieldId),
570 this));
573 editSField(MaskRFieldMask);
575 return returnValue;
578 GetFieldHandlePtr ColorMaskChunkBase::getHandleMaskG (void) const
580 SFBool::GetHandlePtr returnValue(
581 new SFBool::GetHandle(
582 &_sfMaskG,
583 this->getType().getFieldDesc(MaskGFieldId),
584 const_cast<ColorMaskChunkBase *>(this)));
586 return returnValue;
589 EditFieldHandlePtr ColorMaskChunkBase::editHandleMaskG (void)
591 SFBool::EditHandlePtr returnValue(
592 new SFBool::EditHandle(
593 &_sfMaskG,
594 this->getType().getFieldDesc(MaskGFieldId),
595 this));
598 editSField(MaskGFieldMask);
600 return returnValue;
603 GetFieldHandlePtr ColorMaskChunkBase::getHandleMaskB (void) const
605 SFBool::GetHandlePtr returnValue(
606 new SFBool::GetHandle(
607 &_sfMaskB,
608 this->getType().getFieldDesc(MaskBFieldId),
609 const_cast<ColorMaskChunkBase *>(this)));
611 return returnValue;
614 EditFieldHandlePtr ColorMaskChunkBase::editHandleMaskB (void)
616 SFBool::EditHandlePtr returnValue(
617 new SFBool::EditHandle(
618 &_sfMaskB,
619 this->getType().getFieldDesc(MaskBFieldId),
620 this));
623 editSField(MaskBFieldMask);
625 return returnValue;
628 GetFieldHandlePtr ColorMaskChunkBase::getHandleMaskA (void) const
630 SFBool::GetHandlePtr returnValue(
631 new SFBool::GetHandle(
632 &_sfMaskA,
633 this->getType().getFieldDesc(MaskAFieldId),
634 const_cast<ColorMaskChunkBase *>(this)));
636 return returnValue;
639 EditFieldHandlePtr ColorMaskChunkBase::editHandleMaskA (void)
641 SFBool::EditHandlePtr returnValue(
642 new SFBool::EditHandle(
643 &_sfMaskA,
644 this->getType().getFieldDesc(MaskAFieldId),
645 this));
648 editSField(MaskAFieldMask);
650 return returnValue;
654 #ifdef OSG_MT_CPTR_ASPECT
655 void ColorMaskChunkBase::execSyncV( FieldContainer &oFrom,
656 ConstFieldMaskArg whichField,
657 AspectOffsetStore &oOffsets,
658 ConstFieldMaskArg syncMode,
659 const UInt32 uiSyncInfo)
661 ColorMaskChunk *pThis = static_cast<ColorMaskChunk *>(this);
663 pThis->execSync(static_cast<ColorMaskChunk *>(&oFrom),
664 whichField,
665 oOffsets,
666 syncMode,
667 uiSyncInfo);
669 #endif
672 #ifdef OSG_MT_CPTR_ASPECT
673 FieldContainer *ColorMaskChunkBase::createAspectCopy(
674 const FieldContainer *pRefAspect) const
676 ColorMaskChunk *returnValue;
678 newAspectCopy(returnValue,
679 dynamic_cast<const ColorMaskChunk *>(pRefAspect),
680 dynamic_cast<const ColorMaskChunk *>(this));
682 return returnValue;
684 #endif
686 void ColorMaskChunkBase::resolveLinks(void)
688 Inherited::resolveLinks();
694 OSG_END_NAMESPACE