osg::StatIntOnceElem Class Reference
[Statistics]

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

#include <OSGStatIntOnceElem.h>

Inheritance diagram for osg::StatIntOnceElem:

osg::StatElem

List of all members.

Public Types

typedef std::set< UInt32IdHash

Public Member Functions

instance


virtual void reset (void)
void add (UInt32 contributorId, Int32 v)
void sub (UInt32 contributorId, Int32 v)
void inc (UInt32 contributorId)
void dec (UInt32 contributorId)
Int32 get (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 StatIntOnceElem &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


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

Private Types

typedef StatElem Inherited

Private Member Functions

 StatIntOnceElem (const StatIntOnceElem &source)
StatIntOnceElemoperator= (const StatIntOnceElem &source)

Private Attributes

Int32 _value
IdHash _ids


Detailed Description

The StatIntOnceElem is similar to the osg::StatIntElem, but it keeps track of who has contributed already and only allows each ID to contribute once. Statistics for details.

Definition at line 72 of file OSGStatIntOnceElem.h.


Member Typedef Documentation

typedef std::set< UInt32 > osg::StatIntOnceElem::IdHash

Definition at line 81 of file OSGStatIntOnceElem.h.

Definition at line 159 of file OSGStatIntOnceElem.h.


Constructor & Destructor Documentation

StatIntOnceElem::StatIntOnceElem ( StatElemDescBase desc  )  [protected]

Definition at line 72 of file OSGStatIntOnceElem.cpp.

Referenced by clone(), and create().

00073   : StatElem(desc), 
00074     _value(0),
00075     _ids()
00076 {
00077 }

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

Definition at line 85 of file OSGStatIntOnceElem.cpp.

00086 {
00087 }

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


Member Function Documentation

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

Reimplemented from osg::StatElem.

Definition at line 88 of file OSGStatIntOnceElem.h.

00088 { return "StatIntOnceElem"; }

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

Definition at line 79 of file OSGStatIntOnceElem.cpp.

References StatIntOnceElem().

00080 {
00081     return new StatIntOnceElem(desc);
00082 }

void StatIntOnceElem::reset ( void   )  [virtual]

Implements osg::StatElem.

Definition at line 116 of file OSGStatIntOnceElem.cpp.

References _ids, and _value.

00117 { 
00118     _value = 0; 
00119     _ids.clear();
00120 }

void osg::StatIntOnceElem::add ( UInt32  contributorId,
Int32  v 
) [inline]

Definition at line 42 of file OSGStatIntOnceElem.inl.

References _ids, and _value.

00043 {
00044     if(_ids.find(contributorId) == _ids.end())
00045     {
00046         _value += v;
00047         _ids.insert(contributorId);
00048     }
00049 }

void osg::StatIntOnceElem::sub ( UInt32  contributorId,
Int32  v 
) [inline]

Definition at line 51 of file OSGStatIntOnceElem.inl.

References _ids, and _value.

00052 {
00053     if(_ids.find(contributorId) == _ids.end())
00054     {
00055         _value -= v;
00056         _ids.insert(contributorId);
00057     }
00058 }

void osg::StatIntOnceElem::inc ( UInt32  contributorId  )  [inline]

Definition at line 60 of file OSGStatIntOnceElem.inl.

References _ids, and _value.

00061 {
00062     if(_ids.find(contributorId) == _ids.end())
00063     {
00064         _value ++;
00065         _ids.insert(contributorId);
00066     }
00067 }

void osg::StatIntOnceElem::dec ( UInt32  contributorId  )  [inline]

Definition at line 69 of file OSGStatIntOnceElem.inl.

References _ids, and _value.

00070 {
00071     if(_ids.find(contributorId) == _ids.end())
00072     {
00073         _value --;
00074         _ids.insert(contributorId);
00075     }
00076 }

Int32 osg::StatIntOnceElem::get ( void   )  const [inline]

Definition at line 78 of file OSGStatIntOnceElem.inl.

References _value.

Referenced by operator<().

00079 {
00080     return _value;
00081 }

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

Implements osg::StatElem.

Definition at line 91 of file OSGStatIntOnceElem.cpp.

References _value.

00092 {
00093     if(!format)
00094     {
00095         FieldDataTraits<Int32>::putToString(_value, str);
00096     }
00097     else
00098     {
00099         char *temp = new char [strlen(format) + 40];
00100         sprintf(temp, format, _value);
00101         str = temp;
00102         delete [] temp;
00103     }
00104 }

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

Implements osg::StatElem.

Definition at line 106 of file OSGStatIntOnceElem.cpp.

References _value.

00107 {
00108     return FieldDataTraits<Int32>::getFromString(_value, inVal);
00109 }

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

Implements osg::StatElem.

Definition at line 111 of file OSGStatIntOnceElem.cpp.

00112 {
00113     return static_cast<Real64>(get());
00114 }

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

Definition at line 137 of file OSGStatIntOnceElem.cpp.

References get().

00138 {
00139     return this->get() < other.get();
00140 }

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

Implements osg::StatElem.

Definition at line 144 of file OSGStatIntOnceElem.cpp.

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

00145 {
00146     StatIntOnceElem *e = new StatIntOnceElem(getDesc());
00147     
00148     *e = *this;
00149     
00150     return e;
00151 }

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

Implements osg::StatElem.

Definition at line 155 of file OSGStatIntOnceElem.cpp.

References _ids, and _value.

00156 {
00157     const StatIntOnceElem *o = dynamic_cast<const StatIntOnceElem *>(&other);
00158     
00159     _value += o->_value;
00160 
00161     IdHash::const_iterator it = o->_ids.begin();
00162 
00163     while (it != o->_ids.end())
00164     {
00165         _ids.insert(*it);
00166         ++it;
00167     }
00168 
00169     return *this;
00170 }

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

Definition at line 124 of file OSGStatIntOnceElem.cpp.

References _ids, and _value.

00125 {
00126     if (this == &source)
00127         return *this;
00128 
00129     _value = source._value;
00130     _ids = source._ids;
00131     
00132     return *this;
00133 }

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

Definition at line 163 of file OSGStatIntOnceElem.h.

Referenced by add(), dec(), inc(), operator+=(), operator=(), reset(), and sub().


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

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