1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
7 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
13 * This library is free software; you can redistribute it and/or modify it *
14 * under the terms of the GNU Library General Public License as published *
15 * by the Free Software Foundation, version 2. *
17 * This library is distributed in the hope that it will be useful, but *
18 * WITHOUT ANY WARRANTY; without even the implied warranty of *
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
20 * Library General Public License for more details. *
22 * You should have received a copy of the GNU Library General Public *
23 * License along with this library; if not, write to the Free Software *
24 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
35 \*---------------------------------------------------------------------------*/
39 template<class Desc> inline
40 UInt32 SelectSValueEmitter<Desc>::getContainerSize(void) const
45 template<class Desc> inline
46 typename SelectSValueEmitter<Desc>::SFChoiceType *
47 SelectSValueEmitter<Desc>::editSFChoice(void)
49 editSField(ChoiceFieldMask);
54 template<class Desc> inline
55 const typename SelectSValueEmitter<Desc>::SFChoiceType *
56 SelectSValueEmitter<Desc>::getSFChoice(void) const
61 template<class Desc> inline
62 typename SelectSValueEmitter<Desc>::ChoiceType &
63 SelectSValueEmitter<Desc>::editChoice(void)
65 editSField(ChoiceFieldMask);
67 return _sfChoice.getValue();
70 template<class Desc> inline
71 typename SelectSValueEmitter<Desc>::ChoiceType
72 SelectSValueEmitter<Desc>::getChoice(void) const
74 return _sfChoice.getValue();
77 template<class Desc> inline
78 typename SelectSValueEmitter<Desc>::MFChoiceValuesType *
79 SelectSValueEmitter<Desc>::editMFChoiceValues(void)
81 editMField(ChoiceValuesFieldMask, _mfChoiceValues);
83 return &_mfChoiceValues;
86 template<class Desc> inline
87 const typename SelectSValueEmitter<Desc>::MFChoiceValuesType *
88 SelectSValueEmitter<Desc>::getMFChoiceValues(void) const
90 return &_mfChoiceValues;
93 template<class Desc> inline
94 typename SelectSValueEmitter<Desc>::ChoiceValuesType &
95 SelectSValueEmitter<Desc>::editChoiceValue(const UInt32 index)
97 editMField(ChoiceValuesFieldMask, _mfChoiceValues);
99 return _mfChoiceValues[index];
102 template<class Desc> inline
103 typename SelectSValueEmitter<Desc>::ChoiceValuesType
104 SelectSValueEmitter<Desc>::getChoiceValue(const UInt32 index) const
106 return _mfChoiceValues[index];
109 template<class Desc> inline
110 typename SelectSValueEmitter<Desc>::SFValueType *
111 SelectSValueEmitter<Desc>::editSFValue(void)
113 editSField(ValueFieldMask);
118 template<class Desc> inline
119 const typename SelectSValueEmitter<Desc>::SFValueType *
120 SelectSValueEmitter<Desc>::getSFValue(void) const
125 //! Get the value of the Real32Counter::_sfValue field.
127 template<class Desc> inline
128 typename SelectSValueEmitter<Desc>::ValueType &
129 SelectSValueEmitter<Desc>::editValue(void)
131 editSField(ValueFieldMask);
133 return _sfValue.getValue();
136 //! Get the value of the Real32Counter::_sfValue field.
137 template<class Desc> inline
138 typename SelectSValueEmitter<Desc>::ValueType
139 SelectSValueEmitter<Desc>::getValue(void) const
141 return _sfValue.getValue();
144 template<class Desc> inline
145 void SelectSValueEmitter<Desc>::setChoice(const ChoiceType choice)
147 editSField(ChoiceFieldMask);
149 _sfChoice.setValue(choice);
152 //! Set the value of the Real32Counter::_sfValue field.
153 template<class Desc> inline
154 void SelectSValueEmitter<Desc>::setValue(const ValueType value)
156 editSField(ValueFieldMask);
158 _sfValue.setValue(value);
161 template<class Desc> inline
162 SFBool *SelectSValueEmitter<Desc>::editSFIgnoreNextChange(void)
164 editSField(IgnoreNextChangeFieldMask);
166 return &_sfIgnoreNextChange;
169 template<class Desc> inline
170 const SFBool *SelectSValueEmitter<Desc>::getSFIgnoreNextChange (void) const
172 return &_sfIgnoreNextChange;
175 /*----------------------------- class specific ----------------------------*/
177 template<class Desc> inline
178 void SelectSValueEmitter<Desc>::changed(ConstFieldMaskArg whichField,
182 if(0x0000 != (whichField & TriggerFieldMask))
184 editSField(ValueFieldMask);
187 if(0x0000 != (whichField & (ChoiceFieldMask | ChoiceValuesFieldMask)))
189 if(_sfChoice.getValue() < _mfChoiceValues.size())
191 setValue(Desc::convert(_mfChoiceValues[_sfChoice.getValue()]));
195 if(0x0000 != (whichField & IgnoreNextChangeFieldMask))
197 if(_sfIgnoreNextChange.getValue() == false)
199 Inherited::changed(whichField, origin, details);
204 Inherited::changed(whichField, origin, details);
208 /*------------------------------ access -----------------------------------*/
209 template<class Desc> inline
210 SizeT SelectSValueEmitter<Desc>::getBinSize(ConstFieldMaskArg whichField)
212 SizeT returnValue = Inherited::getBinSize(whichField);
214 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
216 returnValue += _sfChoice.getBinSize();
219 if(FieldBits::NoField != (ChoiceValuesFieldMask & whichField))
221 returnValue += _mfChoiceValues.getBinSize();
224 if(FieldBits::NoField != (ValueFieldMask & whichField))
226 returnValue += _sfValue.getBinSize();
233 template<class Desc> inline
234 void SelectSValueEmitter<Desc>::copyToBin(BinaryDataHandler &pMem,
235 ConstFieldMaskArg whichField)
237 Inherited::copyToBin(pMem, whichField);
239 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
241 _sfChoice.copyToBin(pMem);
244 if(FieldBits::NoField != (ChoiceValuesFieldMask & whichField))
246 _mfChoiceValues.copyToBin(pMem);
249 if(FieldBits::NoField != (ValueFieldMask & whichField))
251 _sfValue.copyToBin(pMem);
255 template<class Desc> inline
256 void SelectSValueEmitter<Desc>::copyFromBin(BinaryDataHandler &pMem,
257 ConstFieldMaskArg whichField)
259 Inherited::copyFromBin(pMem, whichField);
261 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
263 _sfChoice.copyFromBin(pMem);
266 if(FieldBits::NoField != (ChoiceValuesFieldMask & whichField))
268 _mfChoiceValues.copyFromBin(pMem);
271 if(FieldBits::NoField != (ValueFieldMask & whichField))
273 _sfValue.copyFromBin(pMem);
278 //! create a new instance of the class
279 template<class Desc> inline
280 typename SelectSValueEmitter<Desc>::ObjTransitPtr
281 SelectSValueEmitter<Desc>::createLocal(BitVector bFlags)
285 if(getClassType().getPrototype() != NULL)
287 FieldContainerTransitPtr tmpPtr =
288 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
290 fc = dynamic_pointer_cast<Self>(tmpPtr);
296 //! create a new instance of the class
297 template<class Desc> inline
298 typename SelectSValueEmitter<Desc>::ObjTransitPtr
299 SelectSValueEmitter<Desc>::createDependent(BitVector bFlags)
303 if(getClassType().getPrototype() != NULL)
305 FieldContainerTransitPtr tmpPtr =
306 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
308 fc = dynamic_pointer_cast<Self>(tmpPtr);
314 //! create a new instance of the class
315 template<class Desc> inline
316 typename SelectSValueEmitter<Desc>::ObjTransitPtr
317 SelectSValueEmitter<Desc>::create(void)
319 return createLocal();
322 template<class Desc> inline
323 typename SelectSValueEmitter<Desc>::Self *
324 SelectSValueEmitter<Desc>::createEmptyLocal(BitVector bFlags)
328 newPtr<Self>(returnValue, bFlags);
330 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
335 //! create an empty new instance of the class, do not copy the prototype
336 template<class Desc> inline
337 typename SelectSValueEmitter<Desc>::Self *
338 SelectSValueEmitter<Desc>::createEmpty(void)
340 return createEmptyLocal();
344 template<class Desc> inline
345 FieldContainerTransitPtr
346 SelectSValueEmitter<Desc>::shallowCopyLocal(BitVector bFlags) const
350 newPtr(tmpPtr, dynamic_cast<const Self *>(this), bFlags);
352 FieldContainerTransitPtr returnValue(tmpPtr);
354 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
359 template<class Desc> inline
360 FieldContainerTransitPtr
361 SelectSValueEmitter<Desc>::shallowCopyDependent(BitVector bFlags) const
365 newPtr(tmpPtr, dynamic_cast<const Self *>(this), ~bFlags);
367 FieldContainerTransitPtr returnValue(tmpPtr);
369 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
374 template<class Desc> inline
375 FieldContainerTransitPtr SelectSValueEmitter<Desc>::shallowCopy(void) const
377 return shallowCopyLocal();
381 template<class Desc> inline
382 const Char8 *SelectSValueEmitter<Desc>::getClassname(void)
384 return Desc::getClassname();
387 /*------------------------- constructors ----------------------------------*/
389 template<class Desc> inline
390 SelectSValueEmitter<Desc>::SelectSValueEmitter(void) :
395 _sfValue (Desc::getDefault()),
396 _sfIgnoreNextChange(false )
400 template<class Desc> inline
401 SelectSValueEmitter<Desc>::SelectSValueEmitter(
402 const SelectSValueEmitter &source) :
405 _sfTrigger (source._sfTrigger ),
406 _sfChoice (source._sfChoice ),
407 _mfChoiceValues (source._mfChoiceValues ),
408 _sfValue (source._sfValue ),
409 _sfIgnoreNextChange(source._sfIgnoreNextChange)
414 /*-------------------------- destructors ----------------------------------*/
416 template<class Desc> inline
417 SelectSValueEmitter<Desc>::~SelectSValueEmitter(void)
421 template<class Desc> inline
422 GetFieldHandlePtr SelectSValueEmitter<Desc>::getHandleChoice(void) const
424 typename SFChoiceType::GetHandlePtr returnValue(
425 new typename SFChoiceType::GetHandle(
427 this->getType().getFieldDesc(ChoiceFieldId),
428 const_cast<Self *>(this)));
433 template<class Desc> inline
434 EditFieldHandlePtr SelectSValueEmitter<Desc>::editHandleChoice(void)
436 typename SFChoiceType::EditHandlePtr returnValue(
437 new typename SFChoiceType::EditHandle(
439 this->getType().getFieldDesc(ChoiceFieldId),
443 editSField(ChoiceFieldMask);
448 template<class Desc> inline
449 GetFieldHandlePtr SelectSValueEmitter<Desc>::getHandleChoiceValues(void) const
451 typename MFChoiceValuesType::GetHandlePtr returnValue(
452 new typename MFChoiceValuesType::GetHandle(
454 this->getType().getFieldDesc(ChoiceValuesFieldId),
455 const_cast<Self *>(this)));
460 template<class Desc> inline
461 EditFieldHandlePtr SelectSValueEmitter<Desc>::editHandleChoiceValues(void)
463 typename MFChoiceValuesType::EditHandlePtr returnValue(
464 new typename MFChoiceValuesType::EditHandle(
466 this->getType().getFieldDesc(ChoiceValuesFieldId),
470 editMField(ChoiceValuesFieldMask, _mfChoiceValues);
475 template<class Desc> inline
476 GetFieldHandlePtr SelectSValueEmitter<Desc>::getHandleValue(void) const
478 typename SFValueType::GetHandlePtr returnValue(
479 new typename SFValueType::GetHandle(
481 this->getType().getFieldDesc(ValueFieldId),
482 const_cast<Self *>(this)));
487 template<class Desc> inline
488 EditFieldHandlePtr SelectSValueEmitter<Desc>::editHandleValue(void)
490 typename SFValueType::EditHandlePtr returnValue(
491 new typename SFValueType::EditHandle(
493 this->getType().getFieldDesc(ValueFieldId),
497 editSField(ValueFieldMask);
502 template<class Desc> inline
504 SelectSValueEmitter<Desc>::getHandleIgnoreNextChange (void) const
506 typename SFBool::GetHandlePtr returnValue(
507 new typename SFBool::GetHandle(
508 &_sfIgnoreNextChange,
509 this->getType().getFieldDesc(IgnoreNextChangeFieldId),
510 const_cast<Self *>(this)));
515 template<class Desc> inline
516 EditFieldHandlePtr SelectSValueEmitter<Desc>::editHandleIgnoreNextChange(void)
518 typename SFBool::EditHandlePtr returnValue(
519 new typename SFBool::EditHandle(
520 &_sfIgnoreNextChange,
521 this->getType().getFieldDesc(IgnoreNextChangeFieldId),
525 editSField(IgnoreNextChangeFieldMask);
530 #ifdef OSG_MT_CPTR_ASPECT
531 template<class Desc> inline
532 void SelectSValueEmitter<Desc>::execSync ( Self *pFrom,
533 ConstFieldMaskArg whichField,
534 AspectOffsetStore &oOffsets,
535 ConstFieldMaskArg syncMode,
536 const UInt32 uiSyncInfo)
538 Inherited::execSync(pFrom, whichField, oOffsets, syncMode, uiSyncInfo);
540 if(FieldBits::NoField != (ChoiceFieldMask & whichField))
541 _sfChoice.syncWith(pFrom->_sfChoice);
543 if(FieldBits::NoField != (ChoiceValuesFieldMask & whichField))
545 _mfChoiceValues.syncWith(pFrom->_mfChoiceValues,
551 if(FieldBits::NoField != (ValueFieldMask & whichField))
552 _sfValue.syncWith(pFrom->_sfValue);
555 template<class Desc> inline
556 void SelectSValueEmitter<Desc>::execSyncV( FieldContainer &oFrom,
557 ConstFieldMaskArg whichField,
558 AspectOffsetStore &oOffsets,
559 ConstFieldMaskArg syncMode,
560 const UInt32 uiSyncInfo)
562 Self *pThis = static_cast<Self *>(this);
564 pThis->execSync(static_cast<Self *>(&oFrom),
572 template<class Desc> inline
573 FieldContainer *SelectSValueEmitter<Desc>::createAspectCopy(
574 const FieldContainer *pRefAspect) const
578 newAspectCopy(returnValue,
579 dynamic_cast<const Self *>(pRefAspect),
580 dynamic_cast<const Self *>(this));
587 template<class Desc> inline
588 void SelectSValueEmitter<Desc>::resolveLinks(void)
590 Inherited::resolveLinks();
595 template<class Desc> inline
596 void SelectSValueEmitter<Desc>::initMethod(InitPhase ePhase)
598 Inherited::initMethod(ePhase);
600 if(ePhase == TypeObject::SystemPost)