changed: gcc8 base update
[opensg.git] / Source / System / State / Auxiliary / OSGTextureSelectChunkBase.cpp
blob83d27f9172a1cfaab600f5cd9606fc68651dfd9d
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 TextureSelectChunk!
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 "OSGTextureBaseChunk.h" // Textures Class
67 #include "OSGTextureSelectChunkBase.h"
68 #include "OSGTextureSelectChunk.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::TextureSelectChunk
79 The TextureSelectChunk allows choosing from a field of textures. It can be
80 used to change between a set of textures more easily than adding/removing
81 chunks the the used material, and can be used in places where only chunks
82 are allowed.
85 /***************************************************************************\
86 * Field Documentation *
87 \***************************************************************************/
89 /*! \var UInt32 TextureSelectChunkBase::_sfChoice
90 Texture selector
93 /*! \var TextureBaseChunk * TextureSelectChunkBase::_mfTextures
94 Texture chunks to choose from
98 /***************************************************************************\
99 * FieldType/FieldTrait Instantiation *
100 \***************************************************************************/
102 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
103 PointerType FieldTraits<TextureSelectChunk *, nsOSG>::_type(
104 "TextureSelectChunkPtr",
105 "TextureBaseChunkPtr",
106 TextureSelectChunk::getClassType(),
107 nsOSG);
108 #endif
110 OSG_FIELDTRAITS_GETTYPE_NS(TextureSelectChunk *, nsOSG)
112 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
113 TextureSelectChunk *,
114 nsOSG)
116 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
117 TextureSelectChunk *,
118 nsOSG)
120 /***************************************************************************\
121 * Field Description *
122 \***************************************************************************/
124 void TextureSelectChunkBase::classDescInserter(TypeObject &oType)
126 FieldDescriptionBase *pDesc = NULL;
129 pDesc = new SFUInt32::Description(
130 SFUInt32::getClassType(),
131 "choice",
132 "Texture selector\n",
133 ChoiceFieldId, ChoiceFieldMask,
134 false,
135 (Field::SFDefaultFlags | Field::FStdAccess),
136 static_cast<FieldEditMethodSig>(&TextureSelectChunk::editHandleChoice),
137 static_cast<FieldGetMethodSig >(&TextureSelectChunk::getHandleChoice));
139 oType.addInitialDesc(pDesc);
141 pDesc = new MFUnrecTextureBaseChunkPtr::Description(
142 MFUnrecTextureBaseChunkPtr::getClassType(),
143 "textures",
144 "Texture chunks to choose from \n",
145 TexturesFieldId, TexturesFieldMask,
146 false,
147 (Field::MFDefaultFlags | Field::FStdAccess),
148 static_cast<FieldEditMethodSig>(&TextureSelectChunk::editHandleTextures),
149 static_cast<FieldGetMethodSig >(&TextureSelectChunk::getHandleTextures));
151 oType.addInitialDesc(pDesc);
155 TextureSelectChunkBase::TypeObject TextureSelectChunkBase::_type(
156 TextureSelectChunkBase::getClassname(),
157 Inherited::getClassname(),
158 "NULL",
159 nsOSG, //Namespace
160 reinterpret_cast<PrototypeCreateF>(&TextureSelectChunkBase::createEmptyLocal),
161 reinterpret_cast<InitContainerF>(&TextureSelectChunk::initMethod),
162 reinterpret_cast<ExitContainerF>(&TextureSelectChunk::exitMethod),
163 reinterpret_cast<InitalInsertDescFunc>(
164 reinterpret_cast<void *>(&TextureSelectChunk::classDescInserter)),
165 false,
167 "<?xml version=\"1.0\"?>\n"
168 "\n"
169 "<FieldContainer\n"
170 " name=\"TextureSelectChunk\"\n"
171 " parent=\"TextureBaseChunk\"\n"
172 " library=\"State\"\n"
173 " pointerfieldtypes=\"both\"\n"
174 " structure=\"concrete\"\n"
175 " systemcomponent=\"true\"\n"
176 " parentsystemcomponent=\"true\"\n"
177 " decoratable=\"false\"\n"
178 " docGroupBase=\"GrpStateAuxiliary\"\n"
179 " >\n"
180 " The TextureSelectChunk allows choosing from a field of textures. It can be \n"
181 " used to change between a set of textures more easily than adding/removing \n"
182 " chunks the the used material, and can be used in places where only chunks\n"
183 " are allowed.\n"
184 "\n"
185 " <Field\n"
186 "\t name=\"choice\"\n"
187 "\t type=\"UInt32\"\n"
188 "\t cardinality=\"single\"\n"
189 "\t visibility=\"external\"\n"
190 "\t access=\"public\"\n"
191 "\t defaultValue=\"0\"\n"
192 "\t >\n"
193 "\tTexture selector\n"
194 " </Field>\n"
195 " <Field\n"
196 "\t name=\"textures\"\n"
197 "\t type=\"TextureBaseChunkPtr\"\n"
198 "\t cardinality=\"multi\"\n"
199 "\t visibility=\"external\"\n"
200 "\t access=\"public\"\n"
201 "\t >\n"
202 "\tTexture chunks to choose from \n"
203 " </Field>\n"
204 "</FieldContainer>\n",
205 "The TextureSelectChunk allows choosing from a field of textures. It can be \n"
206 "used to change between a set of textures more easily than adding/removing \n"
207 "chunks the the used material, and can be used in places where only chunks\n"
208 "are allowed.\n"
211 /*------------------------------ get -----------------------------------*/
213 FieldContainerType &TextureSelectChunkBase::getType(void)
215 return _type;
218 const FieldContainerType &TextureSelectChunkBase::getType(void) const
220 return _type;
223 UInt32 TextureSelectChunkBase::getContainerSize(void) const
225 return sizeof(TextureSelectChunk);
228 /*------------------------- decorator get ------------------------------*/
231 SFUInt32 *TextureSelectChunkBase::editSFChoice(void)
233 editSField(ChoiceFieldMask);
235 return &_sfChoice;
238 const SFUInt32 *TextureSelectChunkBase::getSFChoice(void) const
240 return &_sfChoice;
244 //! Get the TextureSelectChunk::_mfTextures field.
245 const MFUnrecTextureBaseChunkPtr *TextureSelectChunkBase::getMFTextures(void) const
247 return &_mfTextures;
250 MFUnrecTextureBaseChunkPtr *TextureSelectChunkBase::editMFTextures (void)
252 editMField(TexturesFieldMask, _mfTextures);
254 return &_mfTextures;
256 TextureBaseChunk * TextureSelectChunkBase::getTextures(const UInt32 index) const
258 return _mfTextures[index];
263 void TextureSelectChunkBase::pushToTextures(TextureBaseChunk * const value)
265 editMField(TexturesFieldMask, _mfTextures);
267 _mfTextures.push_back(value);
270 void TextureSelectChunkBase::assignTextures (const MFUnrecTextureBaseChunkPtr &value)
272 MFUnrecTextureBaseChunkPtr::const_iterator elemIt =
273 value.begin();
274 MFUnrecTextureBaseChunkPtr::const_iterator elemEnd =
275 value.end ();
277 static_cast<TextureSelectChunk *>(this)->clearTextures();
279 while(elemIt != elemEnd)
281 this->pushToTextures(*elemIt);
283 ++elemIt;
287 void TextureSelectChunkBase::removeFromTextures(UInt32 uiIndex)
289 if(uiIndex < _mfTextures.size())
291 editMField(TexturesFieldMask, _mfTextures);
293 _mfTextures.erase(uiIndex);
297 void TextureSelectChunkBase::removeObjFromTextures(TextureBaseChunk * const value)
299 Int32 iElemIdx = _mfTextures.findIndex(value);
301 if(iElemIdx != -1)
303 editMField(TexturesFieldMask, _mfTextures);
305 _mfTextures.erase(iElemIdx);
308 void TextureSelectChunkBase::clearTextures(void)
310 editMField(TexturesFieldMask, _mfTextures);
313 _mfTextures.clear();
318 /*------------------------------ access -----------------------------------*/
320 SizeT TextureSelectChunkBase::getBinSize(ConstFieldMaskArg whichField)
322 SizeT returnValue = Inherited::getBinSize(whichField);
324 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
326 returnValue += _sfChoice.getBinSize();
328 if(FieldBits::NoField != (TexturesFieldMask & whichField))
330 returnValue += _mfTextures.getBinSize();
333 return returnValue;
336 void TextureSelectChunkBase::copyToBin(BinaryDataHandler &pMem,
337 ConstFieldMaskArg whichField)
339 Inherited::copyToBin(pMem, whichField);
341 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
343 _sfChoice.copyToBin(pMem);
345 if(FieldBits::NoField != (TexturesFieldMask & whichField))
347 _mfTextures.copyToBin(pMem);
351 void TextureSelectChunkBase::copyFromBin(BinaryDataHandler &pMem,
352 ConstFieldMaskArg whichField)
354 Inherited::copyFromBin(pMem, whichField);
356 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
358 editSField(ChoiceFieldMask);
359 _sfChoice.copyFromBin(pMem);
361 if(FieldBits::NoField != (TexturesFieldMask & whichField))
363 editMField(TexturesFieldMask, _mfTextures);
364 _mfTextures.copyFromBin(pMem);
368 //! create a new instance of the class
369 TextureSelectChunkTransitPtr TextureSelectChunkBase::createLocal(BitVector bFlags)
371 TextureSelectChunkTransitPtr fc;
373 if(getClassType().getPrototype() != NULL)
375 FieldContainerTransitPtr tmpPtr =
376 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
378 fc = dynamic_pointer_cast<TextureSelectChunk>(tmpPtr);
381 return fc;
384 //! create a new instance of the class, copy the container flags
385 TextureSelectChunkTransitPtr TextureSelectChunkBase::createDependent(BitVector bFlags)
387 TextureSelectChunkTransitPtr fc;
389 if(getClassType().getPrototype() != NULL)
391 FieldContainerTransitPtr tmpPtr =
392 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
394 fc = dynamic_pointer_cast<TextureSelectChunk>(tmpPtr);
397 return fc;
400 //! create a new instance of the class
401 TextureSelectChunkTransitPtr TextureSelectChunkBase::create(void)
403 TextureSelectChunkTransitPtr fc;
405 if(getClassType().getPrototype() != NULL)
407 FieldContainerTransitPtr tmpPtr =
408 getClassType().getPrototype()-> shallowCopy();
410 fc = dynamic_pointer_cast<TextureSelectChunk>(tmpPtr);
413 return fc;
416 TextureSelectChunk *TextureSelectChunkBase::createEmptyLocal(BitVector bFlags)
418 TextureSelectChunk *returnValue;
420 newPtr<TextureSelectChunk>(returnValue, bFlags);
422 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
424 return returnValue;
427 //! create an empty new instance of the class, do not copy the prototype
428 TextureSelectChunk *TextureSelectChunkBase::createEmpty(void)
430 TextureSelectChunk *returnValue;
432 newPtr<TextureSelectChunk>(returnValue, Thread::getCurrentLocalFlags());
434 returnValue->_pFieldFlags->_bNamespaceMask &=
435 ~Thread::getCurrentLocalFlags();
437 return returnValue;
441 FieldContainerTransitPtr TextureSelectChunkBase::shallowCopyLocal(
442 BitVector bFlags) const
444 TextureSelectChunk *tmpPtr;
446 newPtr(tmpPtr, dynamic_cast<const TextureSelectChunk *>(this), bFlags);
448 FieldContainerTransitPtr returnValue(tmpPtr);
450 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
452 return returnValue;
455 FieldContainerTransitPtr TextureSelectChunkBase::shallowCopyDependent(
456 BitVector bFlags) const
458 TextureSelectChunk *tmpPtr;
460 newPtr(tmpPtr, dynamic_cast<const TextureSelectChunk *>(this), ~bFlags);
462 FieldContainerTransitPtr returnValue(tmpPtr);
464 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
466 return returnValue;
469 FieldContainerTransitPtr TextureSelectChunkBase::shallowCopy(void) const
471 TextureSelectChunk *tmpPtr;
473 newPtr(tmpPtr,
474 dynamic_cast<const TextureSelectChunk *>(this),
475 Thread::getCurrentLocalFlags());
477 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
479 FieldContainerTransitPtr returnValue(tmpPtr);
481 return returnValue;
487 /*------------------------- constructors ----------------------------------*/
489 TextureSelectChunkBase::TextureSelectChunkBase(void) :
490 Inherited(),
491 _sfChoice (UInt32(0)),
492 _mfTextures ()
496 TextureSelectChunkBase::TextureSelectChunkBase(const TextureSelectChunkBase &source) :
497 Inherited(source),
498 _sfChoice (source._sfChoice ),
499 _mfTextures ()
504 /*-------------------------- destructors ----------------------------------*/
506 TextureSelectChunkBase::~TextureSelectChunkBase(void)
510 void TextureSelectChunkBase::onCreate(const TextureSelectChunk *source)
512 Inherited::onCreate(source);
514 if(source != NULL)
516 TextureSelectChunk *pThis = static_cast<TextureSelectChunk *>(this);
518 MFUnrecTextureBaseChunkPtr::const_iterator TexturesIt =
519 source->_mfTextures.begin();
520 MFUnrecTextureBaseChunkPtr::const_iterator TexturesEnd =
521 source->_mfTextures.end ();
523 while(TexturesIt != TexturesEnd)
525 pThis->pushToTextures(*TexturesIt);
527 ++TexturesIt;
532 GetFieldHandlePtr TextureSelectChunkBase::getHandleChoice (void) const
534 SFUInt32::GetHandlePtr returnValue(
535 new SFUInt32::GetHandle(
536 &_sfChoice,
537 this->getType().getFieldDesc(ChoiceFieldId),
538 const_cast<TextureSelectChunkBase *>(this)));
540 return returnValue;
543 EditFieldHandlePtr TextureSelectChunkBase::editHandleChoice (void)
545 SFUInt32::EditHandlePtr returnValue(
546 new SFUInt32::EditHandle(
547 &_sfChoice,
548 this->getType().getFieldDesc(ChoiceFieldId),
549 this));
552 editSField(ChoiceFieldMask);
554 return returnValue;
557 GetFieldHandlePtr TextureSelectChunkBase::getHandleTextures (void) const
559 MFUnrecTextureBaseChunkPtr::GetHandlePtr returnValue(
560 new MFUnrecTextureBaseChunkPtr::GetHandle(
561 &_mfTextures,
562 this->getType().getFieldDesc(TexturesFieldId),
563 const_cast<TextureSelectChunkBase *>(this)));
565 return returnValue;
568 EditFieldHandlePtr TextureSelectChunkBase::editHandleTextures (void)
570 MFUnrecTextureBaseChunkPtr::EditHandlePtr returnValue(
571 new MFUnrecTextureBaseChunkPtr::EditHandle(
572 &_mfTextures,
573 this->getType().getFieldDesc(TexturesFieldId),
574 this));
576 returnValue->setAddMethod(
577 boost::bind(&TextureSelectChunk::pushToTextures,
578 static_cast<TextureSelectChunk *>(this), _1));
579 returnValue->setRemoveMethod(
580 boost::bind(&TextureSelectChunk::removeFromTextures,
581 static_cast<TextureSelectChunk *>(this), _1));
582 returnValue->setRemoveObjMethod(
583 boost::bind(&TextureSelectChunk::removeObjFromTextures,
584 static_cast<TextureSelectChunk *>(this), _1));
585 returnValue->setClearMethod(
586 boost::bind(&TextureSelectChunk::clearTextures,
587 static_cast<TextureSelectChunk *>(this)));
589 editMField(TexturesFieldMask, _mfTextures);
591 return returnValue;
595 #ifdef OSG_MT_CPTR_ASPECT
596 void TextureSelectChunkBase::execSyncV( FieldContainer &oFrom,
597 ConstFieldMaskArg whichField,
598 AspectOffsetStore &oOffsets,
599 ConstFieldMaskArg syncMode,
600 const UInt32 uiSyncInfo)
602 TextureSelectChunk *pThis = static_cast<TextureSelectChunk *>(this);
604 pThis->execSync(static_cast<TextureSelectChunk *>(&oFrom),
605 whichField,
606 oOffsets,
607 syncMode,
608 uiSyncInfo);
610 #endif
613 #ifdef OSG_MT_CPTR_ASPECT
614 FieldContainer *TextureSelectChunkBase::createAspectCopy(
615 const FieldContainer *pRefAspect) const
617 TextureSelectChunk *returnValue;
619 newAspectCopy(returnValue,
620 dynamic_cast<const TextureSelectChunk *>(pRefAspect),
621 dynamic_cast<const TextureSelectChunk *>(this));
623 return returnValue;
625 #endif
627 void TextureSelectChunkBase::resolveLinks(void)
629 Inherited::resolveLinks();
631 static_cast<TextureSelectChunk *>(this)->clearTextures();
637 OSG_END_NAMESPACE