fixed: gcc8 compile issues
[opensg.git] / Source / Contrib / ComplexSceneManager / VRMLNodes / OSGCounters.h
blob61992ca57172d9e7267954d077d7323079592796
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2006 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
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. *
18 * *
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. *
23 * *
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. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGCOUNTERS_H_
40 #define _OSGCOUNTERS_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
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"
55 OSG_BEGIN_NAMESPACE
57 //! \brief Real32Counter Base Class.
59 template<class Desc>
60 class CounterImpl : public Counter
62 public:
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 =================================*/
75 public:
77 enum
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 */
105 /*! \{ */
107 static FieldContainerType &getClassType (void);
108 static UInt32 getClassTypeId (void);
109 static UInt16 getClassGroupId(void);
110 static const Char8 *getClassname (void);
112 /*! \} */
113 /*---------------------------------------------------------------------*/
114 /*! \name FieldContainer Get */
115 /*! \{ */
117 virtual FieldContainerType &getType (void);
118 virtual const FieldContainerType &getType (void) const;
120 virtual UInt32 getContainerSize(void) const;
122 /*! \} */
123 /*---------------------------------------------------------------------*/
124 /*! \name Field Get */
125 /*! \{ */
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;
147 /*! \} */
148 /*---------------------------------------------------------------------*/
149 /*! \name Field Set */
150 /*! \{ */
152 void setStep (const ValueType value);
153 void setResetValue (const ValueType value);
154 void setValue (const ValueType value);
156 /*! \} */
157 /*---------------------------------------------------------------------*/
158 /*! \name Ptr MField Set */
159 /*! \{ */
161 virtual void changed(ConstFieldMaskArg whichField,
162 UInt32 origin,
163 BitVector details );
165 /*! \} */
166 /*---------------------------------------------------------------------*/
167 /*! \name Binary Access */
168 /*! \{ */
170 virtual SizeT getBinSize (ConstFieldMaskArg whichField);
171 virtual void copyToBin (BinaryDataHandler &pMem,
172 ConstFieldMaskArg whichField);
173 virtual void copyFromBin(BinaryDataHandler &pMem,
174 ConstFieldMaskArg whichField);
177 /*! \} */
178 /*---------------------------------------------------------------------*/
179 /*! \name Construction */
180 /*! \{ */
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);
190 /*! \} */
191 /*---------------------------------------------------------------------*/
192 /*! \name Copy */
193 /*! \{ */
195 virtual FieldContainerTransitPtr shallowCopy (void) const;
196 virtual FieldContainerTransitPtr shallowCopyLocal(
197 BitVector bFlags = FCLocal::All) const;
198 virtual FieldContainerTransitPtr shallowCopyDependent(
199 BitVector bFlags ) const;
201 /*! \} */
202 /*========================= PROTECTED ===============================*/
204 protected:
206 static TypeObject _type;
208 static void classDescInserter(TypeObject &oType);
210 /*---------------------------------------------------------------------*/
211 /*! \name Fields */
212 /*! \{ */
214 SFValueType _sfStep;
215 SFValueType _sfResetValue;
216 SFValueType _sfValue;
218 /*! \} */
219 /*---------------------------------------------------------------------*/
220 /*! \name Constructors */
221 /*! \{ */
223 CounterImpl(void);
224 CounterImpl(const CounterImpl &source);
226 /*! \} */
227 /*---------------------------------------------------------------------*/
228 /*! \name Destructors */
229 /*! \{ */
231 virtual ~CounterImpl(void);
233 /*! \} */
234 /*---------------------------------------------------------------------*/
235 /*! \name onCreate */
236 /*! \{ */
239 /*! \} */
240 /*---------------------------------------------------------------------*/
241 /*! \name Generic Field Access */
242 /*! \{ */
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);
251 /*! \} */
252 /*---------------------------------------------------------------------*/
253 /*! \name Sync */
254 /*! \{ */
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);
268 #endif
270 /*! \} */
271 /*---------------------------------------------------------------------*/
272 /*! \name Edit */
273 /*! \{ */
275 /*! \} */
276 /*---------------------------------------------------------------------*/
277 /*! \name Aspect Create */
278 /*! \{ */
280 #ifdef OSG_MT_CPTR_ASPECT
281 virtual FieldContainer *createAspectCopy(
282 const FieldContainer *pRefAspect) const;
283 #endif
285 /*! \} */
286 /*---------------------------------------------------------------------*/
287 /*! \name Edit */
288 /*! \{ */
289 /*! \} */
290 /*---------------------------------------------------------------------*/
291 /*! \name Sync */
292 /*! \{ */
294 virtual void resolveLinks(void);
296 /*! \} */
297 /*---------------------------------------------------------------------*/
298 /*! \name Init */
299 /*! \{ */
301 static void initMethod(InitPhase ePhase);
303 /*! \} */
304 /*========================== PRIVATE ================================*/
306 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;
401 OSG_END_NAMESPACE
403 #include "OSGCounters.inl"
406 #endif /* _OSGCOUNTERS_H_ */