6 #ifndef DISMEC_COLLECTION_H
7 #define DISMEC_COLLECTION_H
11 #include <type_traits>
78 void register_stat(
const std::string& name, std::unique_ptr<Statistics> stat);
144 void enable(
const std::string& stat);
150 void disable(
const std::string& stat);
155 [[nodiscard]]
bool has_stat(
const std::string& name)
const;
173 template<
class T, std::enable_if_t<!std::is_invocable_v<T>,
bool> = true>
197 template<
class F, std::enable_if_t<std::is_invocable_v<F>,
bool> = true>
constexpr T to_index() const
! Explicitly convert to an integer.
This class manages a collection of named Statistics objects.
void declare_tag(tag_id_t index, std::string name)
Declares a new tag value.
std::vector< StatisticMetaData > m_MetaData
TagContainer get_tag_by_name(const std::string &name) const
Gets the tag with the given name.
bool is_enabled(stat_id_t stat) const
Quickly checks whether collection of data is enabled for the given statistics.
std::vector< std::unique_ptr< Statistics > > m_Statistics
void do_record(int index, T &&value)
const Statistics & get_stat(const std::string &name) const
Returns the Statistics object corresponding to the slot name.
void record(stat_id_t stat, F &&callable)
Records a value that is computed only when needed.
std::vector< bool > m_Enabled
void provide_tags(const StatisticsCollection &other)
Registers all the tags of the other collection as read-only tags in this collection.
void disable(stat_id_t stat)
Explicitly disable the collection of statistics for the given index.
const std::vector< StatisticMetaData > & get_statistics_meta() const
Gets a vector with the declarations for all statistics.
const std::vector< TagContainer > & get_all_tags() const
Gets a vector which contains all the tags owned by this collection.
bool is_enabled_by_name(const std::string &name) const
Checks whether gathering data is enabled based on the statistic's name.
void declare_stat(stat_id_t index, StatisticMetaData meta)
Declares a new statistics. Defines the corresponding index and name.
std::vector< TagContainer > m_TagValues
void enable(stat_id_t stat)
Explicitly enable the collection of statistics for the given index.
bool has_stat(const std::string &name) const
Returns whether a stat with the given name is declared.
void set_tag(tag_id_t tag, int value)
Sets the tag to the given integer value.
void record(stat_id_t stat, T &&value)
Records an already computed value.
void register_stat(const std::string &name, std::unique_ptr< Statistics > stat)
Registers a Statistics object to the named slot.
std::unordered_map< std::string, TagContainer > m_TagLookup
TODO maybe we should solve this with a variant which does the dispatch of expected type and tag.
A tag container combines a name with a shared pointer, which points to the tag value.
void __attribute__((hot)) htd_sum_new(const std