fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / State / Base / OSGStateBase.cpp
blob0e4e003273c40f05617e35b02ffca87900102040
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 State!
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 "OSGStateChunk.h" // Chunks Class
67 #include "OSGStateBase.h"
68 #include "OSGState.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::State
79 The state base class. See \ref PageSystemState for the conceptual background.
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var Int32 StateBase::_sfTransparencyMode
87 Set the transparency mode, possible values are TransparencyAutoDetection,
88 TransparencyForceTransparent and TransparencyForceOpaque
91 /*! \var StateChunk * StateBase::_mfChunks
96 /***************************************************************************\
97 * FieldType/FieldTrait Instantiation *
98 \***************************************************************************/
100 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
101 PointerType FieldTraits<State *, nsOSG>::_type(
102 "StatePtr",
103 "FieldContainerPtr",
104 State::getClassType(),
105 nsOSG);
106 #endif
108 OSG_FIELDTRAITS_GETTYPE_NS(State *, nsOSG)
110 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
111 State *,
112 nsOSG)
114 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
115 State *,
116 nsOSG)
118 /***************************************************************************\
119 * Field Description *
120 \***************************************************************************/
122 void StateBase::classDescInserter(TypeObject &oType)
124 FieldDescriptionBase *pDesc = NULL;
127 pDesc = new SFInt32::Description(
128 SFInt32::getClassType(),
129 "transparencyMode",
130 "Set the transparency mode, possible values are TransparencyAutoDetection,\n"
131 "TransparencyForceTransparent and TransparencyForceOpaque \n",
132 TransparencyModeFieldId, TransparencyModeFieldMask,
133 false,
134 (Field::SFDefaultFlags | Field::FStdAccess),
135 static_cast<FieldEditMethodSig>(&State::editHandleTransparencyMode),
136 static_cast<FieldGetMethodSig >(&State::getHandleTransparencyMode));
138 oType.addInitialDesc(pDesc);
140 pDesc = new MFUnrecStateChunkPtr::Description(
141 MFUnrecStateChunkPtr::getClassType(),
142 "chunks",
144 ChunksFieldId, ChunksFieldMask,
145 false,
146 (Field::MFDefaultFlags | Field::FStdAccess),
147 static_cast <FieldEditMethodSig>(&State::invalidEditField),
148 static_cast <FieldGetMethodSig >(&State::invalidGetField));
150 oType.addInitialDesc(pDesc);
154 StateBase::TypeObject StateBase::_type(
155 StateBase::getClassname(),
156 Inherited::getClassname(),
157 "NULL",
158 nsOSG, //Namespace
159 reinterpret_cast<PrototypeCreateF>(&StateBase::createEmptyLocal),
160 reinterpret_cast<InitContainerF>(&State::initMethod),
161 reinterpret_cast<ExitContainerF>(&State::exitMethod),
162 reinterpret_cast<InitalInsertDescFunc>(
163 reinterpret_cast<void *>(&State::classDescInserter)),
164 false,
166 "<?xml version=\"1.0\" ?>\n"
167 "\n"
168 "<FieldContainer\n"
169 " name=\"State\"\n"
170 " parent=\"FieldContainer\"\n"
171 " library=\"System\"\n"
172 " structure=\"concrete\"\n"
173 " pointerfieldtypes=\"both\"\n"
174 " systemcomponent=\"true\"\n"
175 " parentsystemcomponent=\"true\"\n"
176 " docGroupBase=\"GrpSystemState\"\n"
177 " >\n"
178 " \n"
179 " The state base class. See \\ref PageSystemState for the conceptual background.\n"
180 " <Field\n"
181 " name=\"transparencyMode\"\n"
182 " type=\"Int32\"\n"
183 " cardinality=\"single\"\n"
184 " visibility=\"external\"\n"
185 " defaultValue=\"0\"\n"
186 " access=\"public\"\n"
187 " >\n"
188 "\tSet the transparency mode, possible values are TransparencyAutoDetection,\n"
189 "\tTransparencyForceTransparent and TransparencyForceOpaque \n"
190 " </Field>\n"
191 " <Field\n"
192 " name=\"chunks\"\n"
193 " type=\"StateChunkPtr\"\n"
194 " cardinality=\"multi\"\n"
195 " visibility=\"external\"\n"
196 " removeTo=\"NULL\"\n"
197 " clearMField=\"true\"\n"
198 " access=\"none\"\n"
199 " >\n"
200 " </Field>\n"
201 "</FieldContainer>\n",
202 "The state base class. See \\ref PageSystemState for the conceptual background.\n"
205 /*------------------------------ get -----------------------------------*/
207 FieldContainerType &StateBase::getType(void)
209 return _type;
212 const FieldContainerType &StateBase::getType(void) const
214 return _type;
217 UInt32 StateBase::getContainerSize(void) const
219 return sizeof(State);
222 /*------------------------- decorator get ------------------------------*/
225 SFInt32 *StateBase::editSFTransparencyMode(void)
227 editSField(TransparencyModeFieldMask);
229 return &_sfTransparencyMode;
232 const SFInt32 *StateBase::getSFTransparencyMode(void) const
234 return &_sfTransparencyMode;
243 /*------------------------------ access -----------------------------------*/
245 SizeT StateBase::getBinSize(ConstFieldMaskArg whichField)
247 SizeT returnValue = Inherited::getBinSize(whichField);
249 if(FieldBits::NoField != (TransparencyModeFieldMask & whichField))
251 returnValue += _sfTransparencyMode.getBinSize();
253 if(FieldBits::NoField != (ChunksFieldMask & whichField))
255 returnValue += _mfChunks.getBinSize();
258 return returnValue;
261 void StateBase::copyToBin(BinaryDataHandler &pMem,
262 ConstFieldMaskArg whichField)
264 Inherited::copyToBin(pMem, whichField);
266 if(FieldBits::NoField != (TransparencyModeFieldMask & whichField))
268 _sfTransparencyMode.copyToBin(pMem);
270 if(FieldBits::NoField != (ChunksFieldMask & whichField))
272 _mfChunks.copyToBin(pMem);
276 void StateBase::copyFromBin(BinaryDataHandler &pMem,
277 ConstFieldMaskArg whichField)
279 Inherited::copyFromBin(pMem, whichField);
281 if(FieldBits::NoField != (TransparencyModeFieldMask & whichField))
283 editSField(TransparencyModeFieldMask);
284 _sfTransparencyMode.copyFromBin(pMem);
286 if(FieldBits::NoField != (ChunksFieldMask & whichField))
288 editMField(ChunksFieldMask, _mfChunks);
289 _mfChunks.copyFromBin(pMem);
293 //! create a new instance of the class
294 StateTransitPtr StateBase::createLocal(BitVector bFlags)
296 StateTransitPtr fc;
298 if(getClassType().getPrototype() != NULL)
300 FieldContainerTransitPtr tmpPtr =
301 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
303 fc = dynamic_pointer_cast<State>(tmpPtr);
306 return fc;
309 //! create a new instance of the class, copy the container flags
310 StateTransitPtr StateBase::createDependent(BitVector bFlags)
312 StateTransitPtr fc;
314 if(getClassType().getPrototype() != NULL)
316 FieldContainerTransitPtr tmpPtr =
317 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
319 fc = dynamic_pointer_cast<State>(tmpPtr);
322 return fc;
325 //! create a new instance of the class
326 StateTransitPtr StateBase::create(void)
328 StateTransitPtr fc;
330 if(getClassType().getPrototype() != NULL)
332 FieldContainerTransitPtr tmpPtr =
333 getClassType().getPrototype()-> shallowCopy();
335 fc = dynamic_pointer_cast<State>(tmpPtr);
338 return fc;
341 State *StateBase::createEmptyLocal(BitVector bFlags)
343 State *returnValue;
345 newPtr<State>(returnValue, bFlags);
347 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
349 return returnValue;
352 //! create an empty new instance of the class, do not copy the prototype
353 State *StateBase::createEmpty(void)
355 State *returnValue;
357 newPtr<State>(returnValue, Thread::getCurrentLocalFlags());
359 returnValue->_pFieldFlags->_bNamespaceMask &=
360 ~Thread::getCurrentLocalFlags();
362 return returnValue;
366 FieldContainerTransitPtr StateBase::shallowCopyLocal(
367 BitVector bFlags) const
369 State *tmpPtr;
371 newPtr(tmpPtr, dynamic_cast<const State *>(this), bFlags);
373 FieldContainerTransitPtr returnValue(tmpPtr);
375 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
377 return returnValue;
380 FieldContainerTransitPtr StateBase::shallowCopyDependent(
381 BitVector bFlags) const
383 State *tmpPtr;
385 newPtr(tmpPtr, dynamic_cast<const State *>(this), ~bFlags);
387 FieldContainerTransitPtr returnValue(tmpPtr);
389 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
391 return returnValue;
394 FieldContainerTransitPtr StateBase::shallowCopy(void) const
396 State *tmpPtr;
398 newPtr(tmpPtr,
399 dynamic_cast<const State *>(this),
400 Thread::getCurrentLocalFlags());
402 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
404 FieldContainerTransitPtr returnValue(tmpPtr);
406 return returnValue;
412 /*------------------------- constructors ----------------------------------*/
414 StateBase::StateBase(void) :
415 Inherited(),
416 _sfTransparencyMode (Int32(0)),
417 _mfChunks ()
421 StateBase::StateBase(const StateBase &source) :
422 Inherited(source),
423 _sfTransparencyMode (source._sfTransparencyMode ),
424 _mfChunks ()
429 /*-------------------------- destructors ----------------------------------*/
431 StateBase::~StateBase(void)
436 GetFieldHandlePtr StateBase::getHandleTransparencyMode (void) const
438 SFInt32::GetHandlePtr returnValue(
439 new SFInt32::GetHandle(
440 &_sfTransparencyMode,
441 this->getType().getFieldDesc(TransparencyModeFieldId),
442 const_cast<StateBase *>(this)));
444 return returnValue;
447 EditFieldHandlePtr StateBase::editHandleTransparencyMode(void)
449 SFInt32::EditHandlePtr returnValue(
450 new SFInt32::EditHandle(
451 &_sfTransparencyMode,
452 this->getType().getFieldDesc(TransparencyModeFieldId),
453 this));
456 editSField(TransparencyModeFieldMask);
458 return returnValue;
461 GetFieldHandlePtr StateBase::getHandleChunks (void) const
463 MFUnrecStateChunkPtr::GetHandlePtr returnValue;
465 return returnValue;
468 EditFieldHandlePtr StateBase::editHandleChunks (void)
470 EditFieldHandlePtr returnValue;
472 return returnValue;
476 #ifdef OSG_MT_CPTR_ASPECT
477 void StateBase::execSyncV( FieldContainer &oFrom,
478 ConstFieldMaskArg whichField,
479 AspectOffsetStore &oOffsets,
480 ConstFieldMaskArg syncMode,
481 const UInt32 uiSyncInfo)
483 State *pThis = static_cast<State *>(this);
485 pThis->execSync(static_cast<State *>(&oFrom),
486 whichField,
487 oOffsets,
488 syncMode,
489 uiSyncInfo);
491 #endif
494 #ifdef OSG_MT_CPTR_ASPECT
495 FieldContainer *StateBase::createAspectCopy(
496 const FieldContainer *pRefAspect) const
498 State *returnValue;
500 newAspectCopy(returnValue,
501 dynamic_cast<const State *>(pRefAspect),
502 dynamic_cast<const State *>(this));
504 return returnValue;
506 #endif
508 void StateBase::resolveLinks(void)
510 Inherited::resolveLinks();
516 OSG_END_NAMESPACE