ezEngine  Milestone 7
ezStats Class Reference

This class holds a simple map that maps strings (keys) to strings (values), which represent certain stats. More...

#include <Stats.h>

Classes

struct  StatsEventData
 The event data that is broadcast whenever a stat is changed. More...
 

Public Types

typedef ezMap< ezString, ezStringMapType
 
typedef ezEvent< const
StatsEventData &, ezMutex
ezEventStats
 

Static Public Member Functions

static void RemoveStat (const char *szStatName)
 Removes the stat with the given name. More...
 
static void SetStat (const char *szStatName, const char *szValue)
 Sets the value of the given stat, adds it if it did not exist before. More...
 
static const char * GetStat (const char *szStatName)
 Returns the value of the given stat. Returns an empty string, if the stat did not exist before.
 
static const MapTypeGetAllStats ()
 Returns the entire map of stats, can be used to display them.
 
static void AddEventHandler (ezEventStats::Handler handler)
 Adds an event handler that is called every time a stat is changed.
 
static void RemoveEventHandler (ezEventStats::Handler handler)
 Removes a previously added event handler.
 

Static Private Attributes

static MapType s_Stats
 
static ezEventStats s_StatsEvents
 

Detailed Description

This class holds a simple map that maps strings (keys) to strings (values), which represent certain stats.

This can be used by a game to store (and continuously update) information about the internal game state. Other tools can then display this information in a convenient manner. For example the stats can be shown on screen. The data is also transmitted through ezTelemetry, and the ezInspector tool will display the information.

Member Function Documentation

void ezStats::RemoveStat ( const char *  szStatName)
static

Removes the stat with the given name.

This will also send a 'remove' message through ezTelemetry, such that external tools can remove it from their list.

void ezStats::SetStat ( const char *  szStatName,
const char *  szValue 
)
static

Sets the value of the given stat, adds it if it did not exist before.

szStatName may contain slashes (but not backslashes) to define groups and subgroups, which can be used by tools such as ezInspector to display the stats in a hierarchical way. This function will also send the name and value of the stat through ezTelemetry, such that tools like ezInspector will show the changed value.


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