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 SValueMultiplier<Desc>::getContainerSize(void) const
46 template<class Desc> inline
47 typename SValueMultiplier<Desc>::SFValueType *
48 SValueMultiplier<Desc>::editSFValue(void)
50 editSField(ValueFieldMask);
55 template<class Desc> inline
56 const typename SValueMultiplier<Desc>::SFValueType *
57 SValueMultiplier<Desc>::getSFValue(void) const
62 //! Get the value of the Real32Counter::_sfValue field.
64 template<class Desc> inline
65 typename SValueMultiplier<Desc>::ValueType &
66 SValueMultiplier<Desc>::editValue(void)
68 editSField(ValueFieldMask);
70 return _sfValue.getValue();
73 //! Get the value of the Real32Counter::_sfValue field.
74 template<class Desc> inline
75 typename SValueMultiplier<Desc>::ValueType
76 SValueMultiplier<Desc>::getValue(void) const
78 return _sfValue.getValue();
81 //! Set the value of the Real32Counter::_sfValue field.
82 template<class Desc> inline
83 void SValueMultiplier<Desc>::setValue(const ValueType value)
85 editSField(ValueFieldMask);
87 _sfValue.setValue(value);
92 template<class Desc> inline
93 typename SValueMultiplier<Desc>::SFValueType *
94 SValueMultiplier<Desc>::editSFLhs(void)
96 editSField(LhsFieldMask);
101 template<class Desc> inline
102 const typename SValueMultiplier<Desc>::SFValueType *
103 SValueMultiplier<Desc>::getSFLhs(void) const
108 //! Get the value of the Real32Counter::_sfValue field.
110 template<class Desc> inline
111 typename SValueMultiplier<Desc>::ValueType &
112 SValueMultiplier<Desc>::editLhs(void)
114 editSField(LhsFieldMask);
116 return _sfLhs.getValue();
119 //! Get the value of the Real32Counter::_sfValue field.
120 template<class Desc> inline
121 typename SValueMultiplier<Desc>::ValueType
122 SValueMultiplier<Desc>::getLhs(void) const
124 return _sfLhs.getValue();
127 //! Set the value of the Real32Counter::_sfValue field.
128 template<class Desc> inline
129 void SValueMultiplier<Desc>::setLhs(const ValueType value)
131 editSField(LhsFieldMask);
133 _sfLhs.setValue(value);
138 template<class Desc> inline
139 typename SValueMultiplier<Desc>::SFValueType *
140 SValueMultiplier<Desc>::editSFRhs(void)
142 editSField(RhsFieldMask);
147 template<class Desc> inline
148 const typename SValueMultiplier<Desc>::SFValueType *
149 SValueMultiplier<Desc>::getSFRhs(void) const
154 //! Get the value of the Real32Counter::_sfValue field.
156 template<class Desc> inline
157 typename SValueMultiplier<Desc>::ValueType &
158 SValueMultiplier<Desc>::editRhs(void)
160 editSField(RhsFieldMask);
162 return _sfRhs.getValue();
165 //! Get the value of the Real32Counter::_sfValue field.
166 template<class Desc> inline
167 typename SValueMultiplier<Desc>::ValueType
168 SValueMultiplier<Desc>::getRhs(void) const
170 return _sfRhs.getValue();
173 //! Set the value of the Real32Counter::_sfValue field.
174 template<class Desc> inline
175 void SValueMultiplier<Desc>::setRhs(const ValueType value)
177 editSField(RhsFieldMask);
179 _sfRhs.setValue(value);
183 /*----------------------------- class specific ----------------------------*/
185 template<class Desc> inline
186 void SValueMultiplier<Desc>::changed(ConstFieldMaskArg whichField,
190 if(0x0000 != (whichField & (LhsFieldMask | RhsFieldMask)))
193 Desc::multiply(this->editValue(),
199 Inherited::changed(whichField, origin, details);
202 /*------------------------------ access -----------------------------------*/
204 template<class Desc> inline
205 SizeT SValueMultiplier<Desc>::getBinSize(ConstFieldMaskArg whichField)
207 SizeT returnValue = Inherited::getBinSize(whichField);
209 if(FieldBits::NoField != (ValueFieldMask & whichField))
211 returnValue += _sfValue.getBinSize();
214 if(FieldBits::NoField != (LhsFieldMask & whichField))
216 returnValue += _sfLhs.getBinSize();
219 if(FieldBits::NoField != (RhsFieldMask & whichField))
221 returnValue += _sfRhs.getBinSize();
227 template<class Desc> inline
228 void SValueMultiplier<Desc>::copyToBin(BinaryDataHandler &pMem,
229 ConstFieldMaskArg whichField)
231 Inherited::copyToBin(pMem, whichField);
233 if(FieldBits::NoField != (ValueFieldMask & whichField))
235 _sfValue.copyToBin(pMem);
238 if(FieldBits::NoField != (LhsFieldMask & whichField))
240 _sfLhs.copyToBin(pMem);
243 if(FieldBits::NoField != (RhsFieldMask & whichField))
245 _sfRhs.copyToBin(pMem);
249 template<class Desc> inline
250 void SValueMultiplier<Desc>::copyFromBin(BinaryDataHandler &pMem,
251 ConstFieldMaskArg whichField)
253 Inherited::copyFromBin(pMem, whichField);
255 if(FieldBits::NoField != (ValueFieldMask & whichField))
257 _sfValue.copyFromBin(pMem);
260 if(FieldBits::NoField != (LhsFieldMask & whichField))
262 _sfLhs.copyFromBin(pMem);
265 if(FieldBits::NoField != (RhsFieldMask & whichField))
267 _sfRhs.copyFromBin(pMem);
271 //! create a new instance of the class
272 template<class Desc> inline
273 typename SValueMultiplier<Desc>::ObjTransitPtr
274 SValueMultiplier<Desc>::createLocal(BitVector bFlags)
278 if(getClassType().getPrototype() != NULL)
280 FieldContainerTransitPtr tmpPtr =
281 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
283 fc = dynamic_pointer_cast<Self>(tmpPtr);
289 //! create a new instance of the class
290 template<class Desc> inline
291 typename SValueMultiplier<Desc>::ObjTransitPtr
292 SValueMultiplier<Desc>::createDependent(BitVector bFlags)
296 if(getClassType().getPrototype() != NULL)
298 FieldContainerTransitPtr tmpPtr =
299 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
301 fc = dynamic_pointer_cast<Self>(tmpPtr);
307 //! create a new instance of the class
308 template<class Desc> inline
309 typename SValueMultiplier<Desc>::ObjTransitPtr
310 SValueMultiplier<Desc>::create(void)
312 return createLocal();
315 template<class Desc> inline
316 typename SValueMultiplier<Desc>::Self *
317 SValueMultiplier<Desc>::createEmptyLocal(BitVector bFlags)
321 newPtr<Self>(returnValue, bFlags);
323 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
328 //! create an empty new instance of the class, do not copy the prototype
329 template<class Desc> inline
330 typename SValueMultiplier<Desc>::Self *SValueMultiplier<Desc>::createEmpty(void)
332 return createEmptyLocal();
336 template<class Desc> inline
337 FieldContainerTransitPtr
338 SValueMultiplier<Desc>::shallowCopyLocal(BitVector bFlags) const
342 newPtr(tmpPtr, dynamic_cast<const Self *>(this), bFlags);
344 FieldContainerTransitPtr returnValue(tmpPtr);
346 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
351 template<class Desc> inline
352 FieldContainerTransitPtr
353 SValueMultiplier<Desc>::shallowCopyDependent(BitVector bFlags) const
357 newPtr(tmpPtr, dynamic_cast<const Self *>(this), ~bFlags);
359 FieldContainerTransitPtr returnValue(tmpPtr);
361 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
366 template<class Desc> inline
367 FieldContainerTransitPtr SValueMultiplier<Desc>::shallowCopy(void) const
369 return shallowCopyLocal();
373 template<class Desc> inline
374 const Char8 *SValueMultiplier<Desc>::getClassname(void)
376 return Desc::getClassname();
379 /*------------------------- constructors ----------------------------------*/
381 template<class Desc> inline
382 SValueMultiplier<Desc>::SValueMultiplier(void) :
384 _sfValue (Desc::getDefault()),
385 _sfLhs (Desc::getDefault()),
386 _sfRhs (Desc::getDefault())
390 template<class Desc> inline
391 SValueMultiplier<Desc>::SValueMultiplier(const SValueMultiplier &source) :
393 _sfValue (source._sfValue ),
394 _sfLhs (source._sfLhs ),
395 _sfRhs (source._sfRhs )
400 /*-------------------------- destructors ----------------------------------*/
402 template<class Desc> inline
403 SValueMultiplier<Desc>::~SValueMultiplier(void)
407 template<class Desc> inline
408 GetFieldHandlePtr SValueMultiplier<Desc>::getHandleValue(void) const
410 typename SFValueType::GetHandlePtr returnValue(
411 new typename SFValueType::GetHandle(
413 this->getType().getFieldDesc(ValueFieldId),
414 const_cast<Self *>(this)));
419 template<class Desc> inline
420 EditFieldHandlePtr SValueMultiplier<Desc>::editHandleValue(void)
422 typename SFValueType::EditHandlePtr returnValue(
423 new typename SFValueType::EditHandle(
425 this->getType().getFieldDesc(ValueFieldId),
429 editSField(ValueFieldMask);
435 template<class Desc> inline
436 GetFieldHandlePtr SValueMultiplier<Desc>::getHandleLhs(void) const
438 typename SFValueType::GetHandlePtr returnValue(
439 new typename SFValueType::GetHandle(
441 this->getType().getFieldDesc(LhsFieldId),
442 const_cast<Self *>(this)));
447 template<class Desc> inline
448 EditFieldHandlePtr SValueMultiplier<Desc>::editHandleLhs(void)
450 typename SFValueType::EditHandlePtr returnValue(
451 new typename SFValueType::EditHandle(
453 this->getType().getFieldDesc(LhsFieldId),
457 editSField(LhsFieldMask);
463 template<class Desc> inline
464 GetFieldHandlePtr SValueMultiplier<Desc>::getHandleRhs(void) const
466 typename SFValueType::GetHandlePtr returnValue(
467 new typename SFValueType::GetHandle(
469 this->getType().getFieldDesc(RhsFieldId),
470 const_cast<Self *>(this)));
475 template<class Desc> inline
476 EditFieldHandlePtr SValueMultiplier<Desc>::editHandleRhs(void)
478 typename SFValueType::EditHandlePtr returnValue(
479 new typename SFValueType::EditHandle(
481 this->getType().getFieldDesc(RhsFieldId),
485 editSField(RhsFieldMask);
491 #ifdef OSG_MT_CPTR_ASPECT
492 template<class Desc> inline
493 void SValueMultiplier<Desc>::execSync ( Self *pFrom,
494 ConstFieldMaskArg whichField,
495 AspectOffsetStore &oOffsets,
496 ConstFieldMaskArg syncMode,
497 const UInt32 uiSyncInfo)
499 Inherited::execSync(pFrom, whichField, oOffsets, syncMode, uiSyncInfo);
501 if(FieldBits::NoField != (ValueFieldMask & whichField))
502 _sfValue.syncWith(pFrom->_sfValue);
504 if(FieldBits::NoField != (LhsFieldMask & whichField))
505 _sfLhs.syncWith(pFrom->_sfLhs);
507 if(FieldBits::NoField != (RhsFieldMask & whichField))
508 _sfRhs.syncWith(pFrom->_sfRhs);
511 template<class Desc> inline
512 void SValueMultiplier<Desc>::execSyncV( FieldContainer &oFrom,
513 ConstFieldMaskArg whichField,
514 AspectOffsetStore &oOffsets,
515 ConstFieldMaskArg syncMode,
516 const UInt32 uiSyncInfo)
518 Self *pThis = static_cast<Self *>(this);
520 pThis->execSync(static_cast<Self *>(&oFrom),
528 template<class Desc> inline
529 FieldContainer *SValueMultiplier<Desc>::createAspectCopy(
530 const FieldContainer *pRefAspect) const
534 newAspectCopy(returnValue,
535 dynamic_cast<const Self *>(pRefAspect),
536 dynamic_cast<const Self *>(this));
543 template<class Desc> inline
544 void SValueMultiplier<Desc>::resolveLinks(void)
546 Inherited::resolveLinks();
551 template<class Desc> inline
552 void SValueMultiplier<Desc>::initMethod(InitPhase ePhase)
554 Inherited::initMethod(ePhase);
556 if(ePhase == TypeObject::SystemPost)