Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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 id, Int32 v)
void sub (UInt32 id, Int32 v)
void inc (UInt32 id)
void dec (UInt32 id)
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
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.

typedef StatElem osg::StatIntOnceElem::Inherited [private]
 

Definition at line 152 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  id,
Int32  v
[inline]
 

Definition at line 42 of file OSGStatIntOnceElem.inl.

References _ids, and _value.

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

void osg::StatIntOnceElem::sub UInt32  id,
Int32  v
[inline]
 

Definition at line 51 of file OSGStatIntOnceElem.inl.

References _ids, and _value.

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

void osg::StatIntOnceElem::inc UInt32  id  )  [inline]
 

Definition at line 60 of file OSGStatIntOnceElem.inl.

References _ids, and _value.

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

void osg::StatIntOnceElem::dec UInt32  id  )  [inline]
 

Definition at line 69 of file OSGStatIntOnceElem.inl.

References _ids, and _value.

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

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

Definition at line 78 of file OSGStatIntOnceElem.inl.

References _value.

Referenced by getValue(), and 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.

References get().

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 }

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]
 

Definition at line 51 of file OSGStatElem.inl.

References osg::StatElem::_desc.

Referenced by osg::StatTimeElem::clone(), osg::StatStringElem::clone(), osg::StatRealElem::clone(), clone(), osg::StatIntElem::clone(), and osg::SimpleStatisticsForeground::draw().

00052 { 
00053     return _desc; 
00054 }

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

Int32 osg::StatIntOnceElem::_value [private]
 

Definition at line 154 of file OSGStatIntOnceElem.h.

Referenced by add(), dec(), get(), getFromString(), inc(), operator=(), putToString(), reset(), and sub().

IdHash osg::StatIntOnceElem::_ids [private]
 

Definition at line 156 of file OSGStatIntOnceElem.h.

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


The documentation for this class was generated from the following files:
Generated on Thu Aug 25 04:22:52 2005 for OpenSG by  doxygen 1.4.3