1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 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 \*---------------------------------------------------------------------------*/
40 #ifndef _OSGSTATCOLLECTOR_H_
41 #define _OSGSTATCOLLECTOR_H_
47 #include "OSGBaseTypes.h"
48 #include "OSGFieldTraits.h"
49 #include "OSGDataType.h"
51 #include "OSGSField.h"
53 #include "OSGStatElemDesc.h"
54 #include "OSGMemoryObject.h"
59 class StatElemDescBase
;
61 /*! \brief Manager for Stat elements, see \guide{Statistics} for details.
62 \ingroup GrpBaseStatistics
63 \ingroup GrpLibOSGBase
66 class OSG_BASE_DLLMAPPING StatCollector
: public MemoryObject
69 /*========================== PUBLIC =================================*/
73 typedef MemoryObject Inherited
;
74 typedef StatCollector Self
;
76 OSG_GEN_INTERNAL_MEMOBJPTR(StatCollector
);
78 /*---------------------------------------------------------------------*/
82 UInt32
getNumOfElems(void ) const;
83 void refitElemNum (void );
84 void clearElems (void );
85 bool isValidID (Int32 elemId
) const;
86 void reset (StatElemDescBase::ResetMode mode
=
87 StatElemDescBase::RESET_DRAW
);
90 /*---------------------------------------------------------------------*/
91 /*! \name Constructor */
94 StatElem
*getElem(Int32 elemId
) const;
96 StatElem
*getElem(Int32 elemId
,
97 bool doCreate
= true);
99 StatElem
*getElem(StatElemDescBase
&desc
,
100 bool docreate
= true);
103 T
*getElem(StatElemDesc
<T
> &desc
,
104 bool doCreate
= true);
107 /*---------------------------------------------------------------------*/
108 /*! \name Constructor */
111 void putToString ( std::string
&outVal
) const;
112 bool getFromCString(const Char8
*&inVal
);
113 bool getValue ( std::string
&name
,
117 /*---------------------------------------------------------------------*/
118 /*! \name Constructor */
122 StatCollector(const StatCollector
&source
);
124 /*---------------------------------------------------------------------*/
125 /*! \name Destructor */
128 virtual ~StatCollector(void);
131 /*---------------------------------------------------------------------*/
132 /*! \name Operators */
135 const StatCollector
&operator =(const StatCollector
&source
);
138 /*---------------------------------------------------------------------*/
142 static StatCollector
*create(void);
145 /*---------------------------------------------------------------------*/
146 /*! \name Comparison */
149 bool operator == (const StatCollector
&rhs
) const;
150 bool operator < (const StatCollector
&other
) const;
153 /*---------------------------------------------------------------------*/
154 /*! \name Operators */
157 StatCollector
operator + (const StatCollector
&other
);
158 StatCollector
&operator += (const StatCollector
&other
);
161 /*========================= PROTECTED ===============================*/
165 /*========================== PRIVATE ================================*/
169 typedef std::vector
<StatElem
*> StatElemStore
;
170 typedef StatElemStore::iterator StatElemStoreIt
;
171 typedef StatElemStore::const_iterator StatElemStoreConstIt
;
173 StatElemStore _elemVec
;
176 typedef StatCollector
* StatCollectorP
;
177 typedef StatCollector
* const StatCollectorPConst
;
178 typedef StatCollector
* const StatCollectorPConstArg
;
180 OSG_GEN_MEMOBJPTR(StatCollector
);
183 #if !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
185 /*! \brief Single Statistics element, see \ref PageSystemStatistics for
187 \ingroup GrpBaseStatistics
188 \ingroup GrpBaseFieldTraits
189 \ingroup GrpLibOSGBase
193 struct FieldTraits
<StatCollectorP
> :
194 public FieldTraitsTemplateBase
<StatCollectorP
>
196 static DataType _type
;
197 typedef FieldTraits
<StatCollectorP
> Self
;
199 enum { Convertible
= Self::ToStringConvertible
|
200 Self::FromStringConvertible
};
202 static OSG_BASE_DLLMAPPING
203 DataType
&getType (void);
205 static const Char8
*getSName (void) { return "SFStatCollectorP"; }
206 static const Char8
*getMName (void) { return "MFStatCollectorP"; }
208 static StatCollectorP
getDefault (void) { return new StatCollector(); }
210 static bool getFromCString( StatCollectorP
&outVal
,
214 return outVal
->getFromCString(inVal
);
219 static void putToString (const StatCollectorP
&inVal
,
223 inVal
->putToString(outVal
);
227 static UInt32
getBinSize(const StatCollectorP
&)
232 static void copyToBin( BinaryDataHandler
& OSG_CHECK_ARG(pMem
),
233 const StatCollectorP
& OSG_CHECK_ARG(oObject
))
237 static void copyToBin( BinaryDataHandler
& OSG_CHECK_ARG(pMem
),
238 const StatCollectorP
* OSG_CHECK_ARG(pObjectStore
),
239 UInt32
OSG_CHECK_ARG(uiNumObjects
))
243 static void copyFromBin(BinaryDataHandler
& OSG_CHECK_ARG(pMem
),
244 StatCollectorP
& OSG_CHECK_ARG(oObject
))
248 static void copyFromBin(BinaryDataHandler
& OSG_CHECK_ARG(pMem
),
249 StatCollectorP
* OSG_CHECK_ARG(pObjectStore
),
250 UInt32
OSG_CHECK_ARG(uiNumObjects
))
255 #endif // !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
258 #ifndef DOXYGEN_SHOULD_SKIP_THIS
260 /*! \ingroup GrpBaseFieldSingle
262 typedef SField
<StatCollectorP
> SFStatCollectorP
;
264 #else // these are the doxygen hacks
266 /*! \ingroup GrpBaseFieldSingle
267 \ingroup GrpBaseStatistics
268 \ingroup GrpLibOSGBase
270 struct SFStatCollectorP
: public SField
<StatCollectorP
> {};
272 #endif // these are the doxygen hacks
276 #include "OSGStatCollector.inl"
278 #endif /* _OSGSTATCOLLECTOR_H_ */