osg::StatTimeStampElem Class Reference
[Statistics]

Time Statistics element, see Statistics for details. More...

#include <OSGStatTimeStampElem.h>

Inheritance diagram for osg::StatTimeStampElem:

osg::StatElem

List of all members.

Public Member Functions

instance


virtual void reset (void)
const TimeStampstart (void)
const TimeStampstop (void)
const TimeStampgetTime (void) const
virtual void putToString (std::string &str, const char *format=NULL) const
virtual bool getFromString (const Char8 *&inVal)
virtual Real64 getValue (void) const
comparison


bool operator< (const StatTimeStampElem &other) const
Creation


virtual StatElemclone (void) const
Operators


virtual StatElemoperator+= (const StatElem &other)
Instance


bool isOn (void) const
void setOn (bool on)
StatElemDescBasegetDesc (void) const
Comparison


bool operator< (const StatElem &other) const

Static Public Member Functions

Class Get


static const char * getClassname (void)
your_category


static StatElemcreate (StatElemDescBase *desc)

Protected Member Functions

Constructors


 StatTimeStampElem (StatElemDescBase *desc)
virtual ~StatTimeStampElem (void)

Private Types

typedef StatElem Inherited

Private Member Functions

 StatTimeStampElem (const StatTimeStampElem &source)
StatTimeStampElemoperator= (const StatTimeStampElem &source)

Private Attributes

TimeStamp _time


Detailed Description

The StatIntElem keeps a osg::Time value for time measurements, see Statistics for details.

Definition at line 60 of file OSGStatTimeStampElem.h.


Member Typedef Documentation

Definition at line 137 of file OSGStatTimeStampElem.h.


Constructor & Destructor Documentation

StatTimeStampElem::StatTimeStampElem ( StatElemDescBase desc  )  [protected]

Definition at line 71 of file OSGStatTimeStampElem.cpp.

Referenced by clone(), and create().

00072   : StatElem(desc), _time(0)
00073 {
00074 }

StatTimeStampElem::~StatTimeStampElem ( void   )  [protected, virtual]

Definition at line 82 of file OSGStatTimeStampElem.cpp.

00083 {
00084 }

osg::StatTimeStampElem::StatTimeStampElem ( const StatTimeStampElem source  )  [private]


Member Function Documentation

static const char* osg::StatTimeStampElem::getClassname ( void   )  [inline, static]

Reimplemented from osg::StatElem.

Definition at line 70 of file OSGStatTimeStampElem.h.

00070 { return "StatTimeStampElem"; }

StatElem * StatTimeStampElem::create ( StatElemDescBase desc  )  [static]

Definition at line 76 of file OSGStatTimeStampElem.cpp.

References StatTimeStampElem().

00077 {
00078     return new StatTimeStampElem(desc);
00079 }

void StatTimeStampElem::reset ( void   )  [virtual]

Implements osg::StatElem.

Definition at line 141 of file OSGStatTimeStampElem.cpp.

00142 { 
00143     // Time elements need to be started and stopped and can't be reset
00144 }

const TimeStamp & osg::StatTimeStampElem::start ( void   )  [inline]

Definition at line 41 of file OSGStatTimeStampElem.inl.

References _time, and osg::getTimeStamp().

00042 { 
00043     return (_time = getTimeStamp()); 
00044 }

const TimeStamp & osg::StatTimeStampElem::stop ( void   )  [inline]

Definition at line 46 of file OSGStatTimeStampElem.inl.

References _time, and osg::getTimeStamp().

00047 { 
00048     return (_time = (getTimeStamp() - _time)); 
00049 }

const TimeStamp & osg::StatTimeStampElem::getTime ( void   )  const [inline]

Definition at line 51 of file OSGStatTimeStampElem.inl.

References _time.

Referenced by getValue().

00052 { 
00053     return _time; 
00054 }

void StatTimeStampElem::putToString ( std::string &  str,
const char *  format = NULL 
) const [virtual]

Implements osg::StatElem.

Definition at line 88 of file OSGStatTimeStampElem.cpp.

References _time, and osg::getTimeStampMsecs().

00089 {
00090     double time = getTimeStampMsecs(_time) / 1000.;
00091     
00092     if(!format)
00093     {
00094         FieldDataTraits<TimeStamp>::putToString(_time, str);
00095     }
00096     else
00097     {
00098         const char *proc = strchr(format,'%');        
00099               char *temp = new char [strlen(format) + 60];
00100 
00101         if(proc)
00102         {
00103             if(! strncmp(proc, "%ms", 3))
00104             {
00105                 std::string fcopy(format);
00106                 fcopy.insert((proc - format) + 1,".2f ");
00107                 sprintf(temp, fcopy.c_str(), time*1000.);
00108             }
00109             else if(! strncmp(proc, "%r", 2))
00110             {
00111                 std::string fcopy(format);
00112                 fcopy.erase((proc - format) + 1, 1);
00113                 sprintf(temp, fcopy.c_str(), 1./time);
00114             }
00115             else
00116             {
00117                 sprintf(temp, format, time);
00118             }
00119            
00120         }
00121         else
00122         {
00123             sprintf(temp, format, time);
00124         }
00125         
00126         str = temp;
00127         delete [] temp;
00128     }
00129 }

bool StatTimeStampElem::getFromString ( const Char8 *&  inVal  )  [virtual]

Implements osg::StatElem.

Definition at line 131 of file OSGStatTimeStampElem.cpp.

References _time.

00132 {
00133     return FieldDataTraits<TimeStamp>::getFromString(_time, inVal);
00134 }

Real64 StatTimeStampElem::getValue ( void   )  const [virtual]

Implements osg::StatElem.

Definition at line 136 of file OSGStatTimeStampElem.cpp.

References getTime().

00137 {
00138     return static_cast<Real64>(getTime());
00139 }

bool StatTimeStampElem::operator< ( const StatTimeStampElem other  )  const

Definition at line 160 of file OSGStatTimeStampElem.cpp.

References _time.

00161 {
00162     return _time < other._time;
00163 }

StatElem * StatTimeStampElem::clone ( void   )  const [virtual]

Implements osg::StatElem.

Definition at line 167 of file OSGStatTimeStampElem.cpp.

References osg::StatElem::getDesc(), and StatTimeStampElem().

00168 {
00169     StatTimeStampElem *e = new StatTimeStampElem(getDesc());
00170     
00171     *e = *this;
00172     
00173     return e;
00174 }

StatElem & StatTimeStampElem::operator+= ( const StatElem other  )  [virtual]

Implements osg::StatElem.

Definition at line 178 of file OSGStatTimeStampElem.cpp.

References _time.

00179 {
00180     const StatTimeStampElem *o = dynamic_cast<const StatTimeStampElem *>(&other);
00181     
00182     _time += o->_time;
00183     
00184     return *this;
00185 }

StatTimeStampElem & StatTimeStampElem::operator= ( const StatTimeStampElem source  )  [private]

Definition at line 148 of file OSGStatTimeStampElem.cpp.

References _time.

00149 {
00150     if (this == &source)
00151         return *this;
00152 
00153     _time = source._time;
00154     
00155     return *this;
00156 }

bool osg::StatElem::isOn ( void   )  const [inline, inherited]

Definition at line 41 of file OSGStatElem.inl.

References osg::StatElem::_on.

00042 { 
00043     return _on; 
00044 }

void osg::StatElem::setOn ( bool  on  )  [inline, inherited]

Definition at line 46 of file OSGStatElem.inl.

References osg::StatElem::_on.

00047 { 
00048     _on = on; 
00049 }

StatElemDescBase * osg::StatElem::getDesc ( void   )  const [inline, inherited]

bool StatElem::operator< ( const StatElem other  )  const [inherited]

Comparison. This does not compare the actual values of the StatElem, as that may not be possible for all types.

Definition at line 134 of file OSGStatElem.cpp.

00135 {
00136     return this < &other;
00137 }


Member Data Documentation


The documentation for this class was generated from the following files:

Generated on Mon Mar 17 12:15:21 2008 for OpenSG by  doxygen 1.5.5