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

Offers base statistics. More...

#include <wex/statistics.h>

Public Member Functions

 statistics (const std::vector< std::pair< const std::string, T >> &v={})
 Default constructor. More...
 
statisticsoperator+= (const statistics &s)
 Adds other statistics.
 
void clear ()
 Clears the items. More...
 
const T dec (const std::string &key, T dec_value=1)
 Decrements key with value.
 
const std::string get () const
 Returns all items as a string. More...
 
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.
 
const T set (const std::string &key, T value)
 Sets key to value. More...
 
gridshow (wxWindow *parent, bool hide_row_labels=true, bool hide_col_labels=true, wxWindowID id=wxID_ANY)
 Shows the statistics as a grid window on the parent, and specify whether to show row labels and col labels. More...
 
const gridget_grid () const
 Access to the grid, returns nullptr if the grid has not been shown yet.
 

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. The statistics can be shown 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 = {})
inline

Default constructor.

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

Member Function Documentation

◆ clear()

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

Clears the items.

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

◆ 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 >
const T wex::statistics< T >::set ( const std::string &  key,
value 
)
inline

Sets key to value.

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

◆ show()

template<class T >
grid* wex::statistics< T >::show ( wxWindow *  parent,
bool  hide_row_labels = true,
bool  hide_col_labels = true,
wxWindowID  id = wxID_ANY 
)
inline

Shows the statistics as a grid window on the parent, and specify whether to show row labels and col labels.

Returns the window that is created, or is activated, if it already was created.

Parameters
parentthe parent for the grid
hide_row_labelsshow row labels (i.e. row numbers)
hide_col_labelsshow col labels (Item, Value)
idthe id of the grid component