fixed: gcc8 compile issues
[opensg.git] / Source / Contrib / ComplexSceneManager / VRMLNodes / OSGValueEmitter.h
blob44fd13f0b56c0dc7c61a63ca2bbae5442d74cf41
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 _OSGVALUEEMITTER_H_
40 #define _OSGVALUEEMITTER_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 "OSGBaseFields.h"
53 #include "OSGMathFields.h"
54 #include "OSGVecFields.h"
56 OSG_BEGIN_NAMESPACE
58 //! \brief Real32Counter Base Class.
60 template<class Desc>
61 class SValueEmitter : public NodeCore
63 public:
65 typedef NodeCore Inherited;
66 typedef NodeCore ParentContainer;
67 typedef SValueEmitter Self;
69 typedef Inherited::TypeObject TypeObject;
70 typedef TypeObject::InitPhase InitPhase;
72 OSG_GEN_INTERNALPTR(Self);
74 /*========================== PUBLIC =================================*/
76 public:
78 enum
80 TriggerFieldId = Inherited::NextFieldId,
81 ValueFieldId = TriggerFieldId + 1,
82 IgnoreNextChangeFieldId = ValueFieldId + 1,
83 NextFieldId = IgnoreNextChangeFieldId + 1
86 static const OSG::BitVector TriggerFieldMask =
87 (TypeTraits<BitVector>::One << TriggerFieldId);
89 static const OSG::BitVector ValueFieldMask =
90 (TypeTraits<BitVector>::One << ValueFieldId);
92 static const OSG::BitVector IgnoreNextChangeFieldMask =
93 (TypeTraits<BitVector>::One << IgnoreNextChangeFieldId);
95 typedef typename Desc::SFValueType SFValueType;
96 typedef typename SFValueType::StoredType ValueType;
98 /*---------------------------------------------------------------------*/
99 /*! \name Class Get */
100 /*! \{ */
102 static FieldContainerType &getClassType (void);
103 static UInt32 getClassTypeId (void);
104 static UInt16 getClassGroupId(void);
105 static const Char8 *getClassname (void);
107 /*! \} */
108 /*---------------------------------------------------------------------*/
109 /*! \name FieldContainer Get */
110 /*! \{ */
112 virtual FieldContainerType &getType (void);
113 virtual const FieldContainerType &getType (void) const;
115 virtual UInt32 getContainerSize(void) const;
117 /*! \} */
118 /*---------------------------------------------------------------------*/
119 /*! \name Field Get */
120 /*! \{ */
123 SFValueType *editSFValue (void);
124 const SFValueType *getSFValue (void) const;
126 ValueType &editValue (void);
127 ValueType getValue (void) const;
129 SFBool *editSFIgnoreNextChange(void);
130 const SFBool *getSFIgnoreNextChange (void) const;
132 /*! \} */
133 /*---------------------------------------------------------------------*/
134 /*! \name Field Set */
135 /*! \{ */
137 void setValue(const ValueType value);
139 /*! \} */
140 /*---------------------------------------------------------------------*/
141 /*! \name Ptr MField Set */
142 /*! \{ */
144 virtual void changed(ConstFieldMaskArg whichField,
145 UInt32 origin,
146 BitVector details );
148 /*! \} */
149 /*---------------------------------------------------------------------*/
150 /*! \name Binary Access */
151 /*! \{ */
153 virtual SizeT getBinSize (ConstFieldMaskArg whichField);
154 virtual void copyToBin (BinaryDataHandler &pMem,
155 ConstFieldMaskArg whichField);
156 virtual void copyFromBin(BinaryDataHandler &pMem,
157 ConstFieldMaskArg whichField);
160 /*! \} */
161 /*---------------------------------------------------------------------*/
162 /*! \name Construction */
163 /*! \{ */
165 static ObjTransitPtr create (void );
166 static Self *createEmpty (void );
168 static ObjTransitPtr createLocal (BitVector bFlags = FCLocal::All);
169 static ObjTransitPtr createDependent (BitVector bFlags = FCLocal::All);
171 static Self *createEmptyLocal(BitVector bFlags = FCLocal::All);
173 /*! \} */
174 /*---------------------------------------------------------------------*/
175 /*! \name Copy */
176 /*! \{ */
178 virtual FieldContainerTransitPtr shallowCopy (void) const;
179 virtual FieldContainerTransitPtr shallowCopyLocal(
180 BitVector bFlags = FCLocal::All) const;
181 virtual FieldContainerTransitPtr shallowCopyDependent(
182 BitVector bFlags ) const;
184 /*! \} */
185 /*========================= PROTECTED ===============================*/
187 protected:
189 static TypeObject _type;
191 static void classDescInserter(TypeObject &oType);
193 /*---------------------------------------------------------------------*/
194 /*! \name Fields */
195 /*! \{ */
197 SFOSGAny _sfTrigger;
198 SFValueType _sfValue;
199 SFBool _sfIgnoreNextChange;
201 /*! \} */
202 /*---------------------------------------------------------------------*/
203 /*! \name Constructors */
204 /*! \{ */
206 SValueEmitter(void);
207 SValueEmitter(const SValueEmitter &source);
209 /*! \} */
210 /*---------------------------------------------------------------------*/
211 /*! \name Destructors */
212 /*! \{ */
214 virtual ~SValueEmitter(void);
216 /*! \} */
217 /*---------------------------------------------------------------------*/
218 /*! \name onCreate */
219 /*! \{ */
221 /*! \} */
222 /*---------------------------------------------------------------------*/
223 /*! \name Generic Field Access */
224 /*! \{ */
226 GetFieldHandlePtr getHandleTrigger (void) const;
227 EditFieldHandlePtr editHandleTrigger (void);
229 GetFieldHandlePtr getHandleValue (void) const;
230 EditFieldHandlePtr editHandleValue (void);
232 GetFieldHandlePtr getHandleIgnoreNextChange (void) const;
233 EditFieldHandlePtr editHandleIgnoreNextChange(void);
235 /*! \} */
236 /*---------------------------------------------------------------------*/
237 /*! \name Sync */
238 /*! \{ */
240 #ifdef OSG_MT_CPTR_ASPECT
241 virtual void execSyncV( FieldContainer &oFrom,
242 ConstFieldMaskArg whichField,
243 AspectOffsetStore &oOffsets,
244 ConstFieldMaskArg syncMode ,
245 const UInt32 uiSyncInfo);
247 void execSync ( Self *pFrom,
248 ConstFieldMaskArg whichField,
249 AspectOffsetStore &oOffsets,
250 ConstFieldMaskArg syncMode ,
251 const UInt32 uiSyncInfo);
252 #endif
254 /*! \} */
255 /*---------------------------------------------------------------------*/
256 /*! \name Edit */
257 /*! \{ */
259 /*! \} */
260 /*---------------------------------------------------------------------*/
261 /*! \name Aspect Create */
262 /*! \{ */
264 #ifdef OSG_MT_CPTR_ASPECT
265 virtual FieldContainer *createAspectCopy(
266 const FieldContainer *pRefAspect) const;
267 #endif
269 /*! \} */
270 /*---------------------------------------------------------------------*/
271 /*! \name Edit */
272 /*! \{ */
273 /*! \} */
274 /*---------------------------------------------------------------------*/
275 /*! \name Sync */
276 /*! \{ */
278 virtual void resolveLinks(void);
280 /*! \} */
281 /*---------------------------------------------------------------------*/
282 /*! \name Init */
283 /*! \{ */
285 static void initMethod(InitPhase ePhase);
287 /*! \} */
288 /*========================== PRIVATE ================================*/
290 private:
292 friend class FieldContainer;
294 /*---------------------------------------------------------------------*/
296 // prohibit default functions (move to 'public' if you need one)
297 void operator =(const SValueEmitter &source);
300 struct BoolEmitterDesc
302 typedef SFBool SFValueType;
304 static const Char8 *getClassname(void)
306 return "BoolEmitter";
309 static bool getDefault(void)
311 return true;
315 struct Int32EmitterDesc
317 typedef SFInt32 SFValueType;
319 static const Char8 *getClassname(void)
321 return "Int32Emitter";
324 static Int32 getDefault(void)
326 return 0;
330 struct UInt32EmitterDesc
332 typedef SFUInt32 SFValueType;
334 static const Char8 *getClassname(void)
336 return "UInt32Emitter";
339 static UInt32 getDefault(void)
341 return 0;
345 struct Real32EmitterDesc
347 typedef SFReal32 SFValueType;
349 static const Char8 *getClassname(void)
351 return "Real32Emitter";
354 static Real32 getDefault(void)
356 return 0.f;
360 struct TimeEmitterDesc
362 typedef SFTime SFValueType;
364 static const Char8 *getClassname(void)
366 return "TimeEmitter";
369 static Time getDefault(void)
371 return 0.f;
375 struct Vec2fEmitterDesc
377 typedef SFVec2f SFValueType;
379 static const Char8 *getClassname(void)
381 return "Vec2fEmitter";
384 static Vec2f getDefault(void)
386 return Vec2f(0.f, 0.f);
390 struct Vec3fEmitterDesc
392 typedef SFVec3f SFValueType;
394 static const Char8 *getClassname(void)
396 return "Vec3fEmitter";
399 static Vec3f getDefault(void)
401 return Vec3f(0.f, 0.f, 0.f);
405 struct StringEmitterDesc
407 typedef SFString SFValueType;
409 static const Char8 *getClassname(void)
411 return "StringEmitter";
414 static std::string getDefault(void)
416 return std::string();
420 struct MatrixEmitterDesc
422 typedef SFMatrix SFValueType;
424 static const Char8 *getClassname(void)
426 return "MatrixEmitter";
429 static Matrix getDefault(void)
431 Matrix m;
433 m.setIdentity();
435 return m;
439 typedef SValueEmitter<BoolEmitterDesc > BoolEmitter;
440 typedef SValueEmitter<Int32EmitterDesc > Int32Emitter;
441 typedef SValueEmitter<UInt32EmitterDesc> UInt32Emitter;
442 typedef SValueEmitter<Real32EmitterDesc> Real32Emitter;
443 typedef SValueEmitter<TimeEmitterDesc > TimeEmitter;
444 typedef SValueEmitter<Vec2fEmitterDesc > Vec2fEmitter;
445 typedef SValueEmitter<Vec3fEmitterDesc > Vec3fEmitter;
446 typedef SValueEmitter<StringEmitterDesc> StringEmitter;
447 typedef SValueEmitter<MatrixEmitterDesc> MatrixEmitter;
449 OSG_END_NAMESPACE
451 #include "OSGValueEmitter.inl"
453 #endif /* _OSGVALUEEMITTER_H_ */