wex v24.10.0
Public Member Functions | List of all members
wex::statistics< T > Class Template Reference

Offers base statistics. More...

#include <wex/common/statistics.h>

Inheritance diagram for wex::statistics< T >:
Inheritance graph
[legend]

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 auto & get_items () const
 Returns the items.
 
const T inc (const std::string &key, T inc_value=1)
 Increments key with value.
 
virtual const T set (const std::string &key, T value)
 Sets key to 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 = {})
inlineexplicit

Default constructor.

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

Member Function Documentation

◆ clear()

template<class T >
virtual void wex::statistics< T >::clear ( )
inlinevirtual

Clears the items.

If you have shown the statistics the window is updated as well.

Reimplemented in wex::grid_statistics< T >.

◆ get()

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

Returns all items as a string.

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

◆ set()

template<class T >
virtual const T wex::statistics< T >::set ( const std::string & key,
T value )
inlinevirtual

Sets key to value.

If you have shown the statistics the window is updated as well.

Reimplemented in wex::grid_statistics< T >.