6 #ifndef DISMEC_STATS_TRACKED_H
7 #define DISMEC_STATS_TRACKED_H
13 class StatisticsCollection;
52 void register_stat(
const std::string& name, std::unique_ptr<Statistics> stat);
65 [[nodiscard]] std::shared_ptr<StatisticsCollection>
get_stats()
const {
74 template<
class T,
class... Args>
92 make_dependent<StatisticsCollection&, T>(*m_Collection).record(stat, std::forward<T>(value));
115 template<
class... Args>
117 static_assert(
sizeof...(Args) == 0,
"Unsupported extra args");
129 template<
class... Args>
132 static_assert(
sizeof...(Args) == 0,
"Unsupported extra args");
This class manages a collection of named Statistics objects.
void set_tag(tag_id_t tag, int value)
Sets the tag to the given integer value.
A base class to be used for all types that implement some for of statistics tracking.
void register_stat(const std::string &name, std::unique_ptr< Statistics > stat)
Registers a tracker for the statistics name.
Tracked()
Default constructor, creates the internal stats::StatisticsCollection.
~Tracked()
Non-virtual destructor. Declared protected, so we don't accidentally try to do a polymorphic delete.
std::shared_ptr< StatisticsCollection > get_stats() const
Gets an ownership-sharing reference to the StatisticsCollection.
std::shared_ptr< StatisticsCollection > m_Collection
The internal collection. Filled with a new StatisticsCollection in the constructor.
void declare_tag(tag_id_t index, std::string name)
Declares a new tag. This function just forwards all its arguments to the internal StatisticsCollectio...
void record(stat_id_t stat, T &&value)
Record statistics. This function just forwards all its arguments to the internal StatisticsCollection...
T & make_dependent(T &t)
Given an object T, and some dummy template parameters Args, returns T unchanged.
auto make_timer(stat_id_t id, Args... args)
Creates a new ScopeTimer using stats::record_scope_time.
void declare_stat(stat_id_t index, StatisticMetaData meta)
Declares a new statistics. This function just forwards all its arguments to the internal StatisticsCo...
void set_tag(tag_id_t tag, long value)
Set value of tag. This function just forwards all its arguments to the internal StatisticsCollection.
ScopeTimer record_scope_time(StatisticsCollection &accumulator, stat_id_t id)