fixed: gcc8 compile issues
[opensg.git] / Source / Contrib / ComplexSceneManager / VRMLNodes / OSGValueMultiplier.inl
blobc4f782058df864ba06b03bab0ee30930eeb01280
1 /*---------------------------------------------------------------------------*\
2  *                                OpenSG                                     *
3  *                                                                           *
4  *                                                                           *
5  *               Copyright (C) 2000-2006 by the OpenSG Forum                 *
6  *                                                                           *
7  *   contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de          *
8  *                                                                           *
9 \*---------------------------------------------------------------------------*/
10 /*---------------------------------------------------------------------------*\
11  *                                License                                    *
12  *                                                                           *
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.                               *
16  *                                                                           *
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.                          *
21  *                                                                           *
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.                 *
25  *                                                                           *
26 \*---------------------------------------------------------------------------*/
27 /*---------------------------------------------------------------------------*\
28  *                                Changes                                    *
29  *                                                                           *
30  *                                                                           *
31  *                                                                           *
32  *                                                                           *
33  *                                                                           *
34  *                                                                           *
35 \*---------------------------------------------------------------------------*/
37 OSG_BEGIN_NAMESPACE
39 template<class Desc> inline
40 UInt32 SValueMultiplier<Desc>::getContainerSize(void) const
42     return sizeof(Self);
46 template<class Desc> inline
47 typename SValueMultiplier<Desc>::SFValueType *
48     SValueMultiplier<Desc>::editSFValue(void)
50     editSField(ValueFieldMask);
52     return &_sfValue;
55 template<class Desc> inline
56 const typename SValueMultiplier<Desc>::SFValueType *
57     SValueMultiplier<Desc>::getSFValue(void) const
59     return &_sfValue;
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);
98     return &_sfLhs;
101 template<class Desc> inline
102 const typename SValueMultiplier<Desc>::SFValueType *
103     SValueMultiplier<Desc>::getSFLhs(void) const
105     return &_sfLhs;
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);
144     return &_sfRhs;
147 template<class Desc> inline
148 const typename SValueMultiplier<Desc>::SFValueType *
149     SValueMultiplier<Desc>::getSFRhs(void) const
151     return &_sfRhs;
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, 
187                                      UInt32            origin,
188                                      BitVector         details)
190     if(0x0000 != (whichField & (LhsFieldMask | RhsFieldMask)))
191     {
192        
193         Desc::multiply(this->editValue(),
194                        
195                        _sfLhs.getValue(),
196                        _sfRhs.getValue());
197     }
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))
210     {
211         returnValue += _sfValue.getBinSize();
212     }
214     if(FieldBits::NoField != (LhsFieldMask & whichField))
215     {
216         returnValue += _sfLhs.getBinSize();
217     }
219     if(FieldBits::NoField != (RhsFieldMask & whichField))
220     {
221         returnValue += _sfRhs.getBinSize();
222     }
224     return returnValue;
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))
234     {
235         _sfValue.copyToBin(pMem);
236     }
238     if(FieldBits::NoField != (LhsFieldMask & whichField))
239     {
240         _sfLhs.copyToBin(pMem);
241     }
243     if(FieldBits::NoField != (RhsFieldMask & whichField))
244     {
245         _sfRhs.copyToBin(pMem);
246     }
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))
256     {
257         _sfValue.copyFromBin(pMem);
258     }
260     if(FieldBits::NoField != (LhsFieldMask & whichField))
261     {
262         _sfLhs.copyFromBin(pMem);
263     }
265     if(FieldBits::NoField != (RhsFieldMask & whichField))
266     {
267         _sfRhs.copyFromBin(pMem);
268     }
271 //! create a new instance of the class
272 template<class Desc> inline
273 typename SValueMultiplier<Desc>::ObjTransitPtr 
274     SValueMultiplier<Desc>::createLocal(BitVector bFlags)
276     ObjTransitPtr fc;
278     if(getClassType().getPrototype() != NULL)
279     {
280         FieldContainerTransitPtr tmpPtr =
281             getClassType().getPrototype()-> shallowCopyLocal(bFlags);
283         fc = dynamic_pointer_cast<Self>(tmpPtr);
284     }
286     return fc;
289 //! create a new instance of the class
290 template<class Desc> inline
291 typename SValueMultiplier<Desc>::ObjTransitPtr 
292     SValueMultiplier<Desc>::createDependent(BitVector bFlags)
294     ObjTransitPtr fc;
296     if(getClassType().getPrototype() != NULL)
297     {
298         FieldContainerTransitPtr tmpPtr =
299             getClassType().getPrototype()-> shallowCopyDependent(bFlags);
301         fc = dynamic_pointer_cast<Self>(tmpPtr);
302     }
304     return fc;
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)
319     Self *returnValue;
321     newPtr<Self>(returnValue, bFlags);
323     returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
325     return returnValue;
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
340     Self *tmpPtr;
342     newPtr(tmpPtr, dynamic_cast<const Self *>(this), bFlags);
344     FieldContainerTransitPtr returnValue(tmpPtr);
346     tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
348     return returnValue;
351 template<class Desc> inline
352 FieldContainerTransitPtr 
353     SValueMultiplier<Desc>::shallowCopyDependent(BitVector bFlags) const
355     Self *tmpPtr;
357     newPtr(tmpPtr, dynamic_cast<const Self *>(this), ~bFlags);
359     FieldContainerTransitPtr returnValue(tmpPtr);
361     tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
363     return returnValue;
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) :
383      Inherited         (                  ),
384     _sfValue           (Desc::getDefault()),
385     _sfLhs             (Desc::getDefault()),
386     _sfRhs             (Desc::getDefault())
390 template<class Desc> inline
391 SValueMultiplier<Desc>::SValueMultiplier(const SValueMultiplier &source) :
392      Inherited         (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(
412              &_sfValue,
413              this->getType().getFieldDesc(ValueFieldId),
414              const_cast<Self *>(this)));
416     return returnValue;
419 template<class Desc> inline
420 EditFieldHandlePtr SValueMultiplier<Desc>::editHandleValue(void)
422     typename SFValueType::EditHandlePtr returnValue(
423         new typename SFValueType::EditHandle(
424              &_sfValue,
425              this->getType().getFieldDesc(ValueFieldId),
426              this));
429     editSField(ValueFieldMask);
431     return returnValue;
435 template<class Desc> inline
436 GetFieldHandlePtr SValueMultiplier<Desc>::getHandleLhs(void) const
438     typename SFValueType::GetHandlePtr returnValue(
439         new typename SFValueType::GetHandle(
440              &_sfLhs,
441              this->getType().getFieldDesc(LhsFieldId),
442              const_cast<Self *>(this)));
444     return returnValue;
447 template<class Desc> inline
448 EditFieldHandlePtr SValueMultiplier<Desc>::editHandleLhs(void)
450     typename SFValueType::EditHandlePtr returnValue(
451         new typename SFValueType::EditHandle(
452              &_sfLhs,
453              this->getType().getFieldDesc(LhsFieldId),
454              this));
457     editSField(LhsFieldMask);
459     return returnValue;
463 template<class Desc> inline
464 GetFieldHandlePtr SValueMultiplier<Desc>::getHandleRhs(void) const
466     typename SFValueType::GetHandlePtr returnValue(
467         new typename SFValueType::GetHandle(
468              &_sfRhs,
469              this->getType().getFieldDesc(RhsFieldId),
470              const_cast<Self *>(this)));
472     return returnValue;
475 template<class Desc> inline
476 EditFieldHandlePtr SValueMultiplier<Desc>::editHandleRhs(void)
478     typename SFValueType::EditHandlePtr returnValue(
479         new typename SFValueType::EditHandle(
480              &_sfRhs,
481              this->getType().getFieldDesc(RhsFieldId),
482              this));
485     editSField(RhsFieldMask);
487     return returnValue;
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),
521                     whichField,
522                     oOffsets,
523                     syncMode,
524                     uiSyncInfo);
528 template<class Desc> inline
529 FieldContainer *SValueMultiplier<Desc>::createAspectCopy(
530     const FieldContainer *pRefAspect) const
532     Self *returnValue;
534     newAspectCopy(returnValue,
535                   dynamic_cast<const Self *>(pRefAspect),
536                   dynamic_cast<const Self *>(this));
538     return returnValue;
541 #endif
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)
557     {
558     }
561 OSG_END_NAMESPACE