Stellarium 0.12.0
Home · All Namespaces · All Classes · Functions · Coding Style · Scripting · Plugins · Renderer · File Structure

StelRendererStatistics Class Reference

Stores and provides access to statistics about a StelRenderer backend. More...

#include <StelRendererStatistics.hpp>

List of all members.

Public Member Functions

 StelRendererStatistics ()
 Construct an empty StelRendererStatistics object.
bool getNext (const char *&name, double &value)
 Get next statistic name and value.
void resetIteration ()
 Reset iteration to the beginning.
double & operator[] (int index)
 Access statistic with specified index to modify it.
int addStatistic (const char *name, const StatisticSwapMode swapMode=StatisticSwapMode_DoNothing)
 Add a statistic with specified name.
void swap ()
 Called at the end of frame - changes current statistics to previous statistics.

Detailed Description

Stores and provides access to statistics about a StelRenderer backend.

This acts as a map of stings (const char*) and doubles.

Two sets of statistics are stored: current (this frame, currently recorded) and previous (previous frame, currently readable.)

To read statistics (from previous frame), they can be iterated like this:

 const char* name, double value;
 while(statistics.getNext(name, value))
 {
    //Do something with name and value
 }

To record statistics, the [] operator is used, modifying the current frame's statistics. The index is an integer previously returned by the addStatistic() member function:

 statistics[statisticID] += 1.0;

The resetIteration() member fuction can be used to reset iteration to start.

Definition at line 58 of file StelRendererStatistics.hpp.


Constructor & Destructor Documentation

StelRendererStatistics::StelRendererStatistics (  )  [inline]

Construct an empty StelRendererStatistics object.

Definition at line 63 of file StelRendererStatistics.hpp.


Member Function Documentation

int StelRendererStatistics::addStatistic ( const char *  name,
const StatisticSwapMode  swapMode = StatisticSwapMode_DoNothing 
) [inline]

Add a statistic with specified name.

Also returns the index of the statistic. Index will be 0 for the first statistic added, 1 for the second and so on.

Parameters:
name Name of the statistic. This MUST exist as long as the statistics exist. The best way to ensure this is to use a string literal.
swapMode Specifies what to do when when the swap() function is called (at the end of a frame). Used for statistics that are recorded separately each frame and need to be zeroed out.
Returns:
Index of the statistic to use with the [] operator.

Definition at line 126 of file StelRendererStatistics.hpp.

bool StelRendererStatistics::getNext ( const char *&  name,
double &  value 
) [inline]

Get next statistic name and value.

Parameters:
name Name of the statistic will be stored here (only a pointer to it).
value Value of the statistic will be stored here.
Returns:
true if we got a name/value, false if we're done iterating and name and value were not set.

Definition at line 80 of file StelRendererStatistics.hpp.

double& StelRendererStatistics::operator[] ( int  index  )  [inline]

Access statistic with specified index to modify it.

Statistics are accessed by integer indices. A clean way to do this is to use an enum with name corresponding to the name of the statistic.

Definition at line 107 of file StelRendererStatistics.hpp.

void StelRendererStatistics::resetIteration (  )  [inline]

Reset iteration to the beginning.

Definition at line 97 of file StelRendererStatistics.hpp.

void StelRendererStatistics::swap (  )  [inline]

Called at the end of frame - changes current statistics to previous statistics.

Also handles StatisticSwapMode logic, e.g. zeroing out statistics that have StatisticSwapMode_SetToZero.

Definition at line 140 of file StelRendererStatistics.hpp.


The documentation for this class was generated from the following file:
Generated on Thu Jan 31 14:05:47 2013 for Stellarium by  doxygen 1.6.3