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 _OSGVALUEEMITTER_H_
40 #define _OSGVALUEEMITTER_H_
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"
58 //! \brief Real32Counter Base Class.
61 class SValueEmitter
: public NodeCore
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 =================================*/
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 */
102 static FieldContainerType
&getClassType (void);
103 static UInt32
getClassTypeId (void);
104 static UInt16
getClassGroupId(void);
105 static const Char8
*getClassname (void);
108 /*---------------------------------------------------------------------*/
109 /*! \name FieldContainer Get */
112 virtual FieldContainerType
&getType (void);
113 virtual const FieldContainerType
&getType (void) const;
115 virtual UInt32
getContainerSize(void) const;
118 /*---------------------------------------------------------------------*/
119 /*! \name Field Get */
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;
133 /*---------------------------------------------------------------------*/
134 /*! \name Field Set */
137 void setValue(const ValueType value
);
140 /*---------------------------------------------------------------------*/
141 /*! \name Ptr MField Set */
144 virtual void changed(ConstFieldMaskArg whichField
,
149 /*---------------------------------------------------------------------*/
150 /*! \name Binary Access */
153 virtual SizeT
getBinSize (ConstFieldMaskArg whichField
);
154 virtual void copyToBin (BinaryDataHandler
&pMem
,
155 ConstFieldMaskArg whichField
);
156 virtual void copyFromBin(BinaryDataHandler
&pMem
,
157 ConstFieldMaskArg whichField
);
161 /*---------------------------------------------------------------------*/
162 /*! \name Construction */
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
);
174 /*---------------------------------------------------------------------*/
178 virtual FieldContainerTransitPtr
shallowCopy (void) const;
179 virtual FieldContainerTransitPtr
shallowCopyLocal(
180 BitVector bFlags
= FCLocal::All
) const;
181 virtual FieldContainerTransitPtr
shallowCopyDependent(
182 BitVector bFlags
) const;
185 /*========================= PROTECTED ===============================*/
189 static TypeObject _type
;
191 static void classDescInserter(TypeObject
&oType
);
193 /*---------------------------------------------------------------------*/
198 SFValueType _sfValue
;
199 SFBool _sfIgnoreNextChange
;
202 /*---------------------------------------------------------------------*/
203 /*! \name Constructors */
207 SValueEmitter(const SValueEmitter
&source
);
210 /*---------------------------------------------------------------------*/
211 /*! \name Destructors */
214 virtual ~SValueEmitter(void);
217 /*---------------------------------------------------------------------*/
218 /*! \name onCreate */
222 /*---------------------------------------------------------------------*/
223 /*! \name Generic Field Access */
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);
236 /*---------------------------------------------------------------------*/
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
);
255 /*---------------------------------------------------------------------*/
260 /*---------------------------------------------------------------------*/
261 /*! \name Aspect Create */
264 #ifdef OSG_MT_CPTR_ASPECT
265 virtual FieldContainer
*createAspectCopy(
266 const FieldContainer
*pRefAspect
) const;
270 /*---------------------------------------------------------------------*/
274 /*---------------------------------------------------------------------*/
278 virtual void resolveLinks(void);
281 /*---------------------------------------------------------------------*/
285 static void initMethod(InitPhase ePhase
);
288 /*========================== 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)
315 struct Int32EmitterDesc
317 typedef SFInt32 SFValueType
;
319 static const Char8
*getClassname(void)
321 return "Int32Emitter";
324 static Int32
getDefault(void)
330 struct UInt32EmitterDesc
332 typedef SFUInt32 SFValueType
;
334 static const Char8
*getClassname(void)
336 return "UInt32Emitter";
339 static UInt32
getDefault(void)
345 struct Real32EmitterDesc
347 typedef SFReal32 SFValueType
;
349 static const Char8
*getClassname(void)
351 return "Real32Emitter";
354 static Real32
getDefault(void)
360 struct TimeEmitterDesc
362 typedef SFTime SFValueType
;
364 static const Char8
*getClassname(void)
366 return "TimeEmitter";
369 static Time
getDefault(void)
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)
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
;
451 #include "OSGValueEmitter.inl"
453 #endif /* _OSGVALUEEMITTER_H_ */