XII Release 0.1.0
Loading...
Searching...
No Matches
xiiStats 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

using MapType = xiiMap<xiiString, xiiVariant>
 
using xiiEventStats = xiiEvent<const StatsEventData&, xiiMutex>
 

Static Public Member Functions

static void RemoveStat (xiiStringView sStatName)
 Removes the stat with the given name.
 
static void SetStat (xiiStringView sStatName, const xiiVariant &value)
 Sets the value of the given stat, adds it if it did not exist before.
 
static const xiiVariantGetStat (xiiStringView sStatName)
 Returns the value of the given stat. Returns an invalid xiiVariant, 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 (xiiEventStats::Handler handler)
 Adds an event handler that is called every time a stat is changed.
 
static void RemoveEventHandler (xiiEventStats::Handler handler)
 Removes a previously added event handler.
 

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 xiiTelemetry, and the xiiInspector tool will display the information.

Member Function Documentation

◆ RemoveStat()

void xiiStats::RemoveStat ( xiiStringView sStatName)
static

Removes the stat with the given name.

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

◆ SetStat()

void xiiStats::SetStat ( xiiStringView sStatName,
const xiiVariant & value )
static

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

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


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