1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGCOUNTERS_H_
40 #define _OSGCOUNTERS_H_
46 #include "OSGConfig.h"
47 #include "OSGContribCSMDef.h"
49 #include "OSGCounter.h" // Parent
51 #include "OSGSysFields.h" // Step type
52 #include "OSGVecFields.h"
53 #include "OSGMathSFields.h"
57 //! \brief Real32Counter Base Class.
60 class CounterImpl
: public Counter
64 typedef Counter Inherited
;
65 typedef Counter ParentContainer
;
66 typedef CounterImpl Self
;
68 typedef Inherited::TypeObject TypeObject
;
69 typedef TypeObject::InitPhase InitPhase
;
71 OSG_GEN_INTERNALPTR(Self
);
73 /*========================== PUBLIC =================================*/
79 StepFieldId
= Inherited::NextFieldId
,
80 ResetValueFieldId
= StepFieldId
+ 1,
81 ValueFieldId
= ResetValueFieldId
+ 1,
82 NextFieldId
= ValueFieldId
+ 1
85 static const OSG::BitVector StepFieldMask
=
86 (TypeTraits
<BitVector
>::One
<< StepFieldId
);
88 static const OSG::BitVector ResetValueFieldMask
=
89 (TypeTraits
<BitVector
>::One
<< ResetValueFieldId
);
91 static const OSG::BitVector ValueFieldMask
=
92 (TypeTraits
<BitVector
>::One
<< ValueFieldId
);
94 static const OSG::BitVector NextFieldMask
=
95 (TypeTraits
<BitVector
>::One
<< NextFieldId
);
97 typedef typename
Desc::SFValueType SFValueType
;
98 typedef SFValueType SFStepType
;
99 typedef SFValueType SFResetValueType
;
101 typedef typename
SFValueType::StoredType ValueType
;
103 /*---------------------------------------------------------------------*/
104 /*! \name Class Get */
107 static FieldContainerType
&getClassType (void);
108 static UInt32
getClassTypeId (void);
109 static UInt16
getClassGroupId(void);
110 static const Char8
*getClassname (void);
113 /*---------------------------------------------------------------------*/
114 /*! \name FieldContainer Get */
117 virtual FieldContainerType
&getType (void);
118 virtual const FieldContainerType
&getType (void) const;
120 virtual UInt32
getContainerSize(void) const;
123 /*---------------------------------------------------------------------*/
124 /*! \name Field Get */
128 SFValueType
*editSFStep (void);
129 const SFValueType
*getSFStep (void) const;
131 SFValueType
*editSFResetValue (void);
132 const SFValueType
*getSFResetValue (void) const;
134 SFValueType
*editSFValue (void);
135 const SFValueType
*getSFValue (void) const;
138 ValueType
&editStep (void);
139 ValueType
getStep (void) const;
141 ValueType
&editResetValue (void);
142 ValueType
getResetValue (void) const;
144 ValueType
&editValue (void);
145 ValueType
getValue (void) const;
148 /*---------------------------------------------------------------------*/
149 /*! \name Field Set */
152 void setStep (const ValueType value
);
153 void setResetValue (const ValueType value
);
154 void setValue (const ValueType value
);
157 /*---------------------------------------------------------------------*/
158 /*! \name Ptr MField Set */
161 virtual void changed(ConstFieldMaskArg whichField
,
166 /*---------------------------------------------------------------------*/
167 /*! \name Binary Access */
170 virtual SizeT
getBinSize (ConstFieldMaskArg whichField
);
171 virtual void copyToBin (BinaryDataHandler
&pMem
,
172 ConstFieldMaskArg whichField
);
173 virtual void copyFromBin(BinaryDataHandler
&pMem
,
174 ConstFieldMaskArg whichField
);
178 /*---------------------------------------------------------------------*/
179 /*! \name Construction */
182 static ObjTransitPtr
create (void);
183 static Self
*createEmpty (void);
185 static ObjTransitPtr
createLocal (BitVector bFlags
= FCLocal::All
);
186 static ObjTransitPtr
createDependent (BitVector bFlags
);
188 static Self
*createEmptyLocal(BitVector bFlags
= FCLocal::All
);
191 /*---------------------------------------------------------------------*/
195 virtual FieldContainerTransitPtr
shallowCopy (void) const;
196 virtual FieldContainerTransitPtr
shallowCopyLocal(
197 BitVector bFlags
= FCLocal::All
) const;
198 virtual FieldContainerTransitPtr
shallowCopyDependent(
199 BitVector bFlags
) const;
202 /*========================= PROTECTED ===============================*/
206 static TypeObject _type
;
208 static void classDescInserter(TypeObject
&oType
);
210 /*---------------------------------------------------------------------*/
215 SFValueType _sfResetValue
;
216 SFValueType _sfValue
;
219 /*---------------------------------------------------------------------*/
220 /*! \name Constructors */
224 CounterImpl(const CounterImpl
&source
);
227 /*---------------------------------------------------------------------*/
228 /*! \name Destructors */
231 virtual ~CounterImpl(void);
234 /*---------------------------------------------------------------------*/
235 /*! \name onCreate */
240 /*---------------------------------------------------------------------*/
241 /*! \name Generic Field Access */
244 GetFieldHandlePtr
getHandleStep (void) const;
245 EditFieldHandlePtr
editHandleStep (void);
246 GetFieldHandlePtr
getHandleResetValue (void) const;
247 EditFieldHandlePtr
editHandleResetValue (void);
248 GetFieldHandlePtr
getHandleValue (void) const;
249 EditFieldHandlePtr
editHandleValue (void);
252 /*---------------------------------------------------------------------*/
256 #ifdef OSG_MT_CPTR_ASPECT
257 virtual void execSyncV( FieldContainer
&oFrom
,
258 ConstFieldMaskArg whichField
,
259 AspectOffsetStore
&oOffsets
,
260 ConstFieldMaskArg syncMode
,
261 const UInt32 uiSyncInfo
);
263 void execSync ( Self
*pFrom
,
264 ConstFieldMaskArg whichField
,
265 AspectOffsetStore
&oOffsets
,
266 ConstFieldMaskArg syncMode
,
267 const UInt32 uiSyncInfo
);
271 /*---------------------------------------------------------------------*/
276 /*---------------------------------------------------------------------*/
277 /*! \name Aspect Create */
280 #ifdef OSG_MT_CPTR_ASPECT
281 virtual FieldContainer
*createAspectCopy(
282 const FieldContainer
*pRefAspect
) const;
286 /*---------------------------------------------------------------------*/
290 /*---------------------------------------------------------------------*/
294 virtual void resolveLinks(void);
297 /*---------------------------------------------------------------------*/
301 static void initMethod(InitPhase ePhase
);
304 /*========================== PRIVATE ================================*/
308 friend class FieldContainer
;
310 /*---------------------------------------------------------------------*/
312 // prohibit default functions (move to 'public' if you need one)
313 void operator =(const CounterImpl
&source
);
316 template<class FieldT
>
317 struct CounterDescBase
319 typedef typename
FieldT::StoredType ValueType
;
321 static ValueType
getZeroElement(void);
322 static ValueType
getOneElement (void);
325 struct Int32CounterDesc
: public CounterDescBase
<SFInt32
>
327 typedef SFInt32 SFValueType
;
329 static const Char8
*getClassname(void)
331 return "Int32Counter";
335 struct UInt32CounterDesc
: public CounterDescBase
<SFUInt32
>
337 typedef SFUInt32 SFValueType
;
339 static const Char8
*getClassname(void)
341 return "UInt32Counter";
345 struct Real32CounterDesc
: public CounterDescBase
<SFReal32
>
347 typedef SFReal32 SFValueType
;
349 static const Char8
*getClassname(void)
351 return "Real32Counter";
355 struct Vec2fCounterDesc
357 typedef SFVec2f SFValueType
;
359 static const Char8
*getClassname(void)
361 return "Vec2fCounter";
364 static Vec2f
getZeroElement(void);
365 static Vec2f
getOneElement (void);
368 struct Vec3fCounterDesc
370 typedef SFVec3f SFValueType
;
372 static const Char8
*getClassname(void)
374 return "Vec3fCounter";
377 static Vec3f
getZeroElement(void);
378 static Vec3f
getOneElement (void);
381 struct Vec4fCounterDesc
383 typedef SFVec4f SFValueType
;
385 static const Char8
*getClassname(void)
387 return "Vec4fCounter";
390 static Vec4f
getZeroElement(void);
391 static Vec4f
getOneElement (void);
394 typedef CounterImpl
<Int32CounterDesc
> Int32Counter
;
395 typedef CounterImpl
<UInt32CounterDesc
> UInt32Counter
;
396 typedef CounterImpl
<Real32CounterDesc
> Real32Counter
;
397 typedef CounterImpl
<Vec2fCounterDesc
> Vec2fCounter
;
398 typedef CounterImpl
<Vec3fCounterDesc
> Vec3fCounter
;
399 typedef CounterImpl
<Vec4fCounterDesc
> Vec4fCounter
;
403 #include "OSGCounters.inl"
406 #endif /* _OSGCOUNTERS_H_ */