changed: auto add updateData callback to stages so that stagedata can be updated...
[opensg.git] / Source / Base / Statistics / OSGStatStringElem.cpp
bloba6aa0bbb530123d59c163105d2b4e7be10647fcc
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 "OSGStatStringElem.h"
50 #include <boost/format.hpp>
52 OSG_USING_NAMESPACE
55 /***************************************************************************\
56 * Description *
57 \***************************************************************************/
59 /*! \class OSG::StatStringElem
61 The StatIntElem keeps a std::string for messages, states or status
62 information, see \ref PageSystemStatistics for details.
65 /***************************************************************************\
66 * Instance methods *
67 \***************************************************************************/
69 /*------------- constructors & destructors --------------------------------*/
71 StatStringElem::StatStringElem(StatElemDescBase *desc) :
72 StatElem(desc),
73 _value ( )
77 StatElem *StatStringElem::create(StatElemDescBase *desc)
79 return new StatStringElem(desc);
82 StatStringElem::~StatStringElem(void)
86 /*------------------------------ access -----------------------------------*/
88 void StatStringElem::putToString(
89 std::string &str, const std::string &format) const
91 if(format.empty())
93 str = _value;
95 else
97 boost::format fmt(format);
99 fmt % _value;
101 str = fmt.str();
105 bool StatStringElem::getFromCString(const Char8 *&inVal)
107 if(inVal != 0)
109 _value = inVal;
112 return true;
115 Real64 StatStringElem::getValue(void) const
117 return 0;
120 void StatStringElem::reset(void)
122 _value.resize(0);
126 /*-------------------------- assignment -----------------------------------*/
128 StatStringElem& StatStringElem::operator = (const StatStringElem &source)
130 if (this == &source)
131 return *this;
133 set(source.get());
135 return *this;
138 /*-------------------------- comparison -----------------------------------*/
140 bool StatStringElem::operator < (const StatStringElem &other) const
142 return this < &other;
145 /*--------------------------- creation ------------------------------------*/
147 StatElem *StatStringElem::clone(void) const
149 StatStringElem *e = new StatStringElem(getDesc());
151 *e = *this;
153 return e;
156 /*--------------------------- operators ------------------------------------*/
158 StatElem &StatStringElem::operator += (const StatElem &other)
160 const StatStringElem *o = dynamic_cast<const StatStringElem *>(&other);
162 _value += " " + o->_value;
164 return *this;