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 LimitedCounterImpl<Desc>::getContainerSize(void) const
45 /*------------------------- decorator get ------------------------------*/
48 template<class Desc> inline
49 typename LimitedCounterImpl<Desc>::SFLimitType *
50 LimitedCounterImpl<Desc>::editSFUpperLimit(void)
52 Self::editSField(UpperLimitFieldMask);
54 return &_sfUpperLimit;
57 template<class Desc> inline
58 const typename LimitedCounterImpl<Desc>::SFLimitType *
59 LimitedCounterImpl<Desc>::getSFUpperLimit(void) const
61 return &_sfUpperLimit;
64 template<class Desc> inline
65 typename LimitedCounterImpl<Desc>::SFLimitType *
66 LimitedCounterImpl<Desc>::editSFLowerLimit(void)
68 Self::editSField(LowerLimitFieldMask);
70 return &_sfLowerLimit;
73 template<class Desc> inline
74 const typename LimitedCounterImpl<Desc>::SFLimitType *
75 LimitedCounterImpl<Desc>::getSFLowerLimit(void) const
77 return &_sfLowerLimit;
80 template<class Desc> inline
81 SFBool *LimitedCounterImpl<Desc>::editSFLoop(void)
83 Self::editSField(LoopFieldMask);
88 template<class Desc> inline
89 const SFBool *LimitedCounterImpl<Desc>::getSFLoop(void) const
94 /*------------------------------ get -----------------------------------*/
96 //! Get the value of the LimitedReal32Counter::_sfUpperLimit field.
98 template<class Desc> inline
99 typename LimitedCounterImpl<Desc>::LimitType &
100 LimitedCounterImpl<Desc>::editUpperLimit(void)
102 Self::editSField(UpperLimitFieldMask);
104 return _sfUpperLimit.getValue();
107 //! Get the value of the LimitedReal32Counter::_sfUpperLimit field.
108 template<class Desc> inline
109 typename LimitedCounterImpl<Desc>::LimitType
110 LimitedCounterImpl<Desc>::getUpperLimit(void) const
112 return _sfUpperLimit.getValue();
115 //! Set the value of the LimitedReal32Counter::_sfUpperLimit field.
116 template<class Desc> inline
117 void LimitedCounterImpl<Desc>::setUpperLimit(const LimitType value)
119 Self::editSField(UpperLimitFieldMask);
121 _sfUpperLimit.setValue(value);
123 //! Get the value of the LimitedReal32Counter::_sfLowerLimit field.
125 template<class Desc> inline
126 typename LimitedCounterImpl<Desc>::LimitType &
127 LimitedCounterImpl<Desc>::editLowerLimit(void)
129 Self::editSField(LowerLimitFieldMask);
131 return _sfLowerLimit.getValue();
134 //! Get the value of the LimitedReal32Counter::_sfLowerLimit field.
135 template<class Desc> inline
136 typename LimitedCounterImpl<Desc>::LimitType
137 LimitedCounterImpl<Desc>::getLowerLimit(void) const
139 return _sfLowerLimit.getValue();
142 //! Set the value of the LimitedReal32Counter::_sfLowerLimit field.
143 template<class Desc> inline
144 void LimitedCounterImpl<Desc>::setLowerLimit(const LimitType value)
146 Self::editSField(LowerLimitFieldMask);
148 _sfLowerLimit.setValue(value);
150 //! Get the value of the LimitedReal32Counter::_sfLoop field.
152 template<class Desc> inline
153 bool &LimitedCounterImpl<Desc>::editLoop(void)
155 Self::editSField(LoopFieldMask);
157 return _sfLoop.getValue();
160 //! Get the value of the LimitedReal32Counter::_sfLoop field.
161 template<class Desc> inline
162 bool LimitedCounterImpl<Desc>::getLoop(void) const
164 return _sfLoop.getValue();
167 //! Set the value of the LimitedReal32Counter::_sfLoop field.
168 template<class Desc> inline
169 void LimitedCounterImpl<Desc>::setLoop(const bool value)
171 Self::editSField(LoopFieldMask);
173 _sfLoop.setValue(value);
177 template<class Desc> inline
178 void LimitedCounterImpl<Desc>::changed(ConstFieldMaskArg whichField,
182 Inherited::Inherited::changed(whichField, origin, details);
184 if((Self::IncTriggerFieldMask | Self::DecTriggerFieldMask) !=
185 (whichField & (Self::IncTriggerFieldMask | Self::DecTriggerFieldMask)))
188 if(0x0000 != (whichField & Self::IncTriggerFieldMask))
190 if(Self::getValue() >= getUpperLimit())
192 if(Self::getLoop() == true)
194 Self::setValue(getLowerLimit());
198 Self::setValue(getUpperLimit());
203 Self::setValue(Self::getValue() + Self::getStep());
207 if(0x0000 != (whichField & Self::DecTriggerFieldMask))
209 if(Self::getValue() <= getLowerLimit())
211 if(Self::getLoop() == true)
213 Self::setValue(getUpperLimit());
217 Self::setValue(getLowerLimit());
222 Self::setValue(Self::getValue() - Self::getStep());
229 /*------------------------------ access -----------------------------------*/
231 template<class Desc> inline
232 SizeT LimitedCounterImpl<Desc>::getBinSize(ConstFieldMaskArg whichField)
234 SizeT returnValue = Inherited::getBinSize(whichField);
236 if(FieldBits::NoField != (UpperLimitFieldMask & whichField))
238 returnValue += _sfUpperLimit.getBinSize();
240 if(FieldBits::NoField != (LowerLimitFieldMask & whichField))
242 returnValue += _sfLowerLimit.getBinSize();
244 if(FieldBits::NoField != (LoopFieldMask & whichField))
246 returnValue += _sfLoop.getBinSize();
252 template<class Desc> inline
253 void LimitedCounterImpl<Desc>::copyToBin(BinaryDataHandler &pMem,
254 ConstFieldMaskArg whichField)
256 Inherited::copyToBin(pMem, whichField);
258 if(FieldBits::NoField != (UpperLimitFieldMask & whichField))
260 _sfUpperLimit.copyToBin(pMem);
262 if(FieldBits::NoField != (LowerLimitFieldMask & whichField))
264 _sfLowerLimit.copyToBin(pMem);
266 if(FieldBits::NoField != (LoopFieldMask & whichField))
268 _sfLoop.copyToBin(pMem);
272 template<class Desc> inline
273 void LimitedCounterImpl<Desc>::copyFromBin(BinaryDataHandler &pMem,
274 ConstFieldMaskArg whichField)
276 Inherited::copyFromBin(pMem, whichField);
278 if(FieldBits::NoField != (UpperLimitFieldMask & whichField))
280 _sfUpperLimit.copyFromBin(pMem);
282 if(FieldBits::NoField != (LowerLimitFieldMask & whichField))
284 _sfLowerLimit.copyFromBin(pMem);
286 if(FieldBits::NoField != (LoopFieldMask & whichField))
288 _sfLoop.copyFromBin(pMem);
292 //! create a new instance of the class
293 template<class Desc> inline
294 typename LimitedCounterImpl<Desc>::ObjTransitPtr
295 LimitedCounterImpl<Desc>::createLocal(BitVector bFlags)
299 if(getClassType().getPrototype() != NULL)
301 FieldContainerTransitPtr tmpPtr =
302 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
304 fc = dynamic_pointer_cast<Self>(tmpPtr);
310 //! create a new instance of the class
311 template<class Desc> inline
312 typename LimitedCounterImpl<Desc>::ObjTransitPtr
313 LimitedCounterImpl<Desc>::createDependent(BitVector bFlags)
317 if(getClassType().getPrototype() != NULL)
319 FieldContainerTransitPtr tmpPtr =
320 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
322 fc = dynamic_pointer_cast<Self>(tmpPtr);
328 //! create a new instance of the class
329 template<class Desc> inline
330 typename LimitedCounterImpl<Desc>::ObjTransitPtr
331 LimitedCounterImpl<Desc>::create(void)
333 return createLocal();
336 template<class Desc> inline
337 typename LimitedCounterImpl<Desc>::Self *
338 LimitedCounterImpl<Desc>::createEmptyLocal(BitVector bFlags)
342 Counter::newPtr<Self>(returnValue, bFlags);
344 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
349 //! create an empty new instance of the class, do not copy the prototype
350 template<class Desc> inline
351 typename LimitedCounterImpl<Desc>::Self *
352 LimitedCounterImpl<Desc>::createEmpty(void)
354 return createEmptyLocal();
357 template<class Desc> inline
358 FieldContainerTransitPtr LimitedCounterImpl<Desc>::shallowCopyLocal(
359 BitVector bFlags) const
363 Self::newPtr(tmpPtr, dynamic_cast<const Self *>(this), bFlags);
365 FieldContainerTransitPtr returnValue(tmpPtr);
367 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
372 template<class Desc> inline
373 FieldContainerTransitPtr LimitedCounterImpl<Desc>::shallowCopyDependent(
374 BitVector bFlags) const
378 Self::newPtr(tmpPtr, dynamic_cast<const Self *>(this), ~bFlags);
380 FieldContainerTransitPtr returnValue(tmpPtr);
382 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
387 template<class Desc> inline
388 FieldContainerTransitPtr LimitedCounterImpl<Desc>::shallowCopy(void) const
390 return shallowCopyLocal();
394 template<class Desc> inline
395 const Char8 *LimitedCounterImpl<Desc>::getClassname(void)
397 return Desc::getClassname();
400 /*------------------------- constructors ----------------------------------*/
402 template<class Desc> inline
403 LimitedCounterImpl<Desc>::LimitedCounterImpl(void) :
405 _sfUpperLimit (TypeTraits<LimitType>::getMin()),
406 _sfLowerLimit (TypeTraits<LimitType>::getMax()),
411 template<class Desc> inline
412 LimitedCounterImpl<Desc>::LimitedCounterImpl(const LimitedCounterImpl &source) :
414 _sfUpperLimit (source._sfUpperLimit ),
415 _sfLowerLimit (source._sfLowerLimit ),
416 _sfLoop (source._sfLoop )
421 /*-------------------------- destructors ----------------------------------*/
423 template<class Desc> inline
424 LimitedCounterImpl<Desc>::~LimitedCounterImpl(void)
428 template<class Desc> inline
429 GetFieldHandlePtr LimitedCounterImpl<Desc>::getHandleUpperLimit(void) const
431 typename SFLimitType::GetHandlePtr returnValue(
432 new typename SFLimitType::GetHandle(
434 this->getType().getFieldDesc(UpperLimitFieldId),
435 const_cast<Self *>(this)));
440 template<class Desc> inline
441 EditFieldHandlePtr LimitedCounterImpl<Desc>::editHandleUpperLimit(void)
443 typename SFLimitType::EditHandlePtr returnValue(
444 new typename SFLimitType::EditHandle(
446 this->getType().getFieldDesc(UpperLimitFieldId),
450 Self::editSField(UpperLimitFieldMask);
455 template<class Desc> inline
456 GetFieldHandlePtr LimitedCounterImpl<Desc>::getHandleLowerLimit(void) const
458 typename SFLimitType::GetHandlePtr returnValue(
459 new typename SFLimitType::GetHandle(
461 this->getType().getFieldDesc(LowerLimitFieldId),
462 const_cast<Self *>(this)));
467 template<class Desc> inline
468 EditFieldHandlePtr LimitedCounterImpl<Desc>::editHandleLowerLimit(void)
470 typename SFLimitType::EditHandlePtr returnValue(
471 new typename SFLimitType::EditHandle(
473 this->getType().getFieldDesc(LowerLimitFieldId),
477 Self::editSField(LowerLimitFieldMask);
482 template<class Desc> inline
483 GetFieldHandlePtr LimitedCounterImpl<Desc>::getHandleLoop(void) const
485 SFBool::GetHandlePtr returnValue(
486 new SFBool::GetHandle(
488 this->getType().getFieldDesc(LoopFieldId),
489 const_cast<Self *>(this)));
494 template<class Desc> inline
495 EditFieldHandlePtr LimitedCounterImpl<Desc>::editHandleLoop(void)
497 SFBool::EditHandlePtr returnValue(
498 new SFBool::EditHandle(
500 this->getType().getFieldDesc(LoopFieldId),
504 Self::editSField(LoopFieldMask);
511 #ifdef OSG_MT_CPTR_ASPECT
512 template<class Desc> inline
513 void LimitedCounterImpl<Desc>::execSync ( Self *pFrom,
514 ConstFieldMaskArg whichField,
515 AspectOffsetStore &oOffsets,
516 ConstFieldMaskArg syncMode,
517 const UInt32 uiSyncInfo)
519 Inherited::execSync(pFrom, whichField, oOffsets, syncMode, uiSyncInfo);
521 if(FieldBits::NoField != (UpperLimitFieldMask & whichField))
522 _sfUpperLimit.syncWith(pFrom->_sfUpperLimit);
524 if(FieldBits::NoField != (LowerLimitFieldMask & whichField))
525 _sfLowerLimit.syncWith(pFrom->_sfLowerLimit);
527 if(FieldBits::NoField != (LoopFieldMask & whichField))
528 _sfLoop.syncWith(pFrom->_sfLoop);
531 template<class Desc> inline
532 void LimitedCounterImpl<Desc>::execSyncV( FieldContainer &oFrom,
533 ConstFieldMaskArg whichField,
534 AspectOffsetStore &oOffsets,
535 ConstFieldMaskArg syncMode,
536 const UInt32 uiSyncInfo)
538 Self *pThis = static_cast<Self *>(this);
540 pThis->execSync(static_cast<Self *>(&oFrom),
547 template<class Desc> inline
548 FieldContainer *LimitedCounterImpl<Desc>::createAspectCopy(
549 const FieldContainer *pRefAspect) const
553 this->newAspectCopy(returnValue,
554 dynamic_cast<const Self *>(pRefAspect),
555 dynamic_cast<const Self *>(this));
561 template<class Desc> inline
562 void LimitedCounterImpl<Desc>::resolveLinks(void)
564 Inherited::resolveLinks();
569 template<class Desc> inline
570 void LimitedCounterImpl<Desc>::initMethod(InitPhase ePhase)
572 Inherited::initMethod(ePhase);
574 if(ePhase == TypeObject::SystemPost)