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 \*---------------------------------------------------------------------------*/
39 //---------------------------------------------------------------------------
41 //---------------------------------------------------------------------------
46 #include "OSGConfig.h"
48 #include "OSGStatRealElem.h"
49 #include "OSGSysFieldTraits.h"
51 #include <boost/format.hpp>
56 /***************************************************************************\
58 \***************************************************************************/
60 /*! \class OSG::StatRealElem
62 The StatIntElem keeps an Real32 value, see \ref PageSystemStatistics for
66 /***************************************************************************\
68 \***************************************************************************/
70 /*------------- constructors & destructors --------------------------------*/
72 StatRealElem::StatRealElem(StatElemDescBase
*desc
) :
78 StatElem
*StatRealElem::create(StatElemDescBase
*desc
)
80 return new StatRealElem(desc
);
83 StatRealElem::~StatRealElem(void)
87 /*------------------------------ access -----------------------------------*/
89 void StatRealElem::putToString(
90 std::string
&str
, const std::string
&format
) const
94 FieldTraits
<Real32
>::putToString(_value
, str
);
98 std::string formatCopy
= format
;
99 std::string::size_type pos
= formatCopy
.find("%");
102 if(pos
!= std::string::npos
)
104 if((pos
= formatCopy
.find("%per")) != std::string::npos
)
106 formatCopy
.replace(pos
, 4, "%.2f");
111 boost::format
fmt(formatCopy
);
119 bool StatRealElem::getFromCString(const Char8
*&inVal
)
121 return FieldTraits
<Real32
>::getFromCString(_value
, inVal
);
124 Real64
StatRealElem::getValue(void) const
126 return static_cast<Real64
>(get());
130 void StatRealElem::reset(void)
135 /*-------------------------- assignment -----------------------------------*/
137 StatRealElem
& StatRealElem::operator = (const StatRealElem
&source
)
147 /*-------------------------- comparison -----------------------------------*/
149 bool StatRealElem::operator < (const StatRealElem
&other
) const
151 return this->get() < other
.get();
154 /*--------------------------- creation ------------------------------------*/
156 StatElem
*StatRealElem::clone(void) const
158 StatRealElem
*e
= new StatRealElem(getDesc());
165 /*--------------------------- operators ------------------------------------*/
167 StatElem
&StatRealElem::operator += (const StatElem
&other
)
169 const StatRealElem
*o
= dynamic_cast<const StatRealElem
*>(&other
);