fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / Statistics / OSGStatCollector.h
blob9fabfbe614f0368fd11bd589bd59082c364df094
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 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 \*---------------------------------------------------------------------------*/
40 #ifndef _OSGSTATCOLLECTOR_H_
41 #define _OSGSTATCOLLECTOR_H_
42 #ifdef __sgi
43 #pragma once
44 #endif
47 #include "OSGBaseTypes.h"
48 #include "OSGFieldTraits.h"
49 #include "OSGDataType.h"
51 #include "OSGSField.h"
53 #include "OSGStatElemDesc.h"
54 #include "OSGMemoryObject.h"
56 OSG_BEGIN_NAMESPACE
58 class StatElem;
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 =================================*/
71 public:
73 typedef MemoryObject Inherited;
74 typedef StatCollector Self;
76 OSG_GEN_INTERNAL_MEMOBJPTR(StatCollector);
78 /*---------------------------------------------------------------------*/
79 /*! \name Instance */
80 /*! \{ */
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);
89 /*! \} */
90 /*---------------------------------------------------------------------*/
91 /*! \name Constructor */
92 /*! \{ */
94 StatElem *getElem(Int32 elemId ) const;
96 StatElem *getElem(Int32 elemId,
97 bool doCreate = true);
99 StatElem *getElem(StatElemDescBase &desc,
100 bool docreate = true);
102 template <class T>
103 T *getElem(StatElemDesc<T> &desc,
104 bool doCreate = true);
106 /*! \} */
107 /*---------------------------------------------------------------------*/
108 /*! \name Constructor */
109 /*! \{ */
111 void putToString ( std::string &outVal) const;
112 bool getFromCString(const Char8 *&inVal );
113 bool getValue ( std::string &name,
114 Real64 &val );
116 /*! \} */
117 /*---------------------------------------------------------------------*/
118 /*! \name Constructor */
119 /*! \{ */
121 StatCollector(void);
122 StatCollector(const StatCollector &source);
124 /*---------------------------------------------------------------------*/
125 /*! \name Destructor */
126 /*! \{ */
128 virtual ~StatCollector(void);
130 /*! \} */
131 /*---------------------------------------------------------------------*/
132 /*! \name Operators */
133 /*! \{ */
135 const StatCollector &operator =(const StatCollector &source);
137 /*! \} */
138 /*---------------------------------------------------------------------*/
139 /*! \name Create */
140 /*! \{ */
142 static StatCollector *create(void);
144 /*! \} */
145 /*---------------------------------------------------------------------*/
146 /*! \name Comparison */
147 /*! \{ */
149 bool operator == (const StatCollector &rhs ) const;
150 bool operator < (const StatCollector &other) const;
152 /*! \} */
153 /*---------------------------------------------------------------------*/
154 /*! \name Operators */
155 /*! \{ */
157 StatCollector operator + (const StatCollector &other);
158 StatCollector &operator += (const StatCollector &other);
160 /*! \} */
161 /*========================= PROTECTED ===============================*/
163 protected:
165 /*========================== PRIVATE ================================*/
167 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
186 details.
187 \ingroup GrpBaseStatistics
188 \ingroup GrpBaseFieldTraits
189 \ingroup GrpLibOSGBase
192 template <>
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,
211 const Char8 *&inVal)
213 if(outVal != NULL)
214 return outVal->getFromCString(inVal);
215 else
216 return true;
219 static void putToString (const StatCollectorP &inVal,
220 std::string &outVal)
222 if(inVal != NULL)
223 inVal->putToString(outVal);
227 static UInt32 getBinSize(const StatCollectorP &)
229 return 0;
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
274 OSG_END_NAMESPACE
276 #include "OSGStatCollector.inl"
278 #endif /* _OSGSTATCOLLECTOR_H_ */