wex v26.10.0
wex::statistics< T > Class Template Reference

Offers base statistics. More...

#include <wex/common/statistics.h>

Inheritance diagram for wex::statistics< T >:
Inheritance graph

Public Member Functions

 statistics (const std::vector< std::pair< const std::string, T > > &v={})
 Default constructor.
virtual ~statistics ()=default
 Destructor.
statisticsoperator+= (const statistics &s)
 Adds other statistics.
virtual void clear ()
 Clears the items.
const T dec (const std::string &key, T dec_value=1)
 Decrements key with value.
bool empty () const
 Returns true if items are empty.
const std::string get () const
 Returns all items as a string.
const T get (const std::string &key) const
 Returns value for specified key.
const std::map< std::string, T > & get_items () const
 Returns the items.
const T inc (const std::string &key, T inc_value=1)
 Increments key with value. Returns value.
virtual const T set (const std::string &key, T value)
 Sets key to value. Returns value.

Detailed Description

template<class T>
class wex::statistics< T >

Offers base statistics.

All statistics involve a key value pair, where the key is a string, and the value a template. There are some virtual methods you can use in a base class e.g. to show the statistics on a grid, that is automatically updated whenever statistics change.

Constructor & Destructor Documentation

◆ statistics()

template<class T>
wex::statistics< T >::statistics ( const std::vector< std::pair< const std::string, T > > & v = {})
explicit

Default constructor.

You can specify a vector of values to initialize the statistics.

Member Function Documentation

◆ get()

template<class T>
const std::string wex::statistics< T >::get ( ) const

Returns all items as a string.

All items are returned as a string, with comma's separating items, and a : separating key and value.