fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Base / Statistics / OSGStatElem.cpp
blob5a884124c1a314e0c98eb7ad2b11262813521b0a
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 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
40 // Includes
41 //---------------------------------------------------------------------------
43 #include <cstdlib>
44 #include <cstdio>
46 #include "OSGConfig.h"
48 #include "OSGStatElem.h"
50 OSG_USING_NAMESPACE
53 /***************************************************************************\
54 * Description *
55 \***************************************************************************/
57 /*! \class OSG::StatElem
59 The StatElem is the abstract base class for all the data types that can be
60 recorded statistically. See \ref PageSystemStatistics for an overview of the
61 statistics
62 structure.
64 It mainly provides the general interfaces for accessing the statistics data
65 as a Real64 value via getValue, if possible, and in ASCII via the
66 putToString and getFromString methods. Additionally every StatElem can be
67 switched on or off, to prevent collecting statistics that is not needed,
68 via the setOn methods.
69 Finally, ever StatElem can give information about itself in the form of a
70 OSG::StatElemDesc*.
72 /ext
74 To add a new StatElem type the given interface has to be implemented.
75 There are no restrictions as to which types are possible, as long as they
76 can be converted to and from a string. See StatIntElem for a simple example.
78 /endext
82 /*! \fn void OSG::StatElem::putToString( std::string &str,
83 const std::string &format) const
85 The putToString method converts the value of the StatElem into a standard
86 STL string.
88 The conversion can be parameterized by the format string parameter. It is
89 modelled after the printf()-format string. It typically should contain a
90 single "%" value to format the contents of the StatElem.
92 */
94 /***************************************************************************\
95 * Class methods *
96 \***************************************************************************/
98 /*-------------------------------------------------------------------------*\
99 - public -
100 \*-------------------------------------------------------------------------*/
102 /*------------- constructors & destructors --------------------------------*/
104 StatElem::StatElem(StatElemDescBase *desc) :
105 _on (true),
106 _desc(desc)
110 StatElem::~StatElem(void)
114 /*-------------------------- assignment -----------------------------------*/
116 StatElem &StatElem::operator = (const StatElem &source)
118 if (this == &source)
119 return *this;
121 // copy
123 _on = source._on;
124 _desc = source._desc;
126 return *this;
129 /*-------------------------- comparison -----------------------------------*/
131 /*! Comparison. This does not compare the actual values of the StatElem, as
132 that may not be possible for all types.
135 bool StatElem::operator < (const StatElem &other) const
137 return this < &other;