11 #ifndef GAUDIKERNEL_COUNTERHOLDER_H 12 #define GAUDIKERNEL_COUNTERHOLDER_H 20 #include <type_traits> 26 static_assert( std::is_base_of_v<INamedInterface, BASE>,
27 "CounterHolder template argument must inherit from INamedInterface" );
33 auto lock = std::scoped_lock{m_mutex};
34 m_counters.emplace(
std::move( tag ), r );
37 const Gaudi::Accumulators::PrintableCounter*
findCounter( std::string_view tag )
const {
38 auto lock = std::scoped_lock{m_mutex};
39 auto p = m_counters.find( tag );
40 return p != m_counters.end() ? &p->second.get() :
nullptr;
43 template <
typename Callable>
45 auto lock = std::scoped_lock{m_mutex};
47 [f = std::forward<Callable>( f )](
const auto& p ) { std::invoke( f, p.first, p.second.get() ); } );
51 auto lock = std::scoped_lock{m_mutex};
52 return m_counters.size();
56 auto lock = std::scoped_lock{m_mutex};
57 return count_if(
begin( m_counters ),
end( m_counters ),
58 [](
const auto&
c ) {
return c.second.get().toBePrinted(); } );
62 auto lock = std::scoped_lock{m_mutex};
std::size_t nOfCountersToBePrinted()
void forEachCounter(Callable &&f) const
IInterface compliant class extending IInterface with the name() method.
std::map< std::string, std::reference_wrapper< Gaudi::Accumulators::PrintableCounter >, std::less<> > m_counters
void declareCounter(std::string tag, Gaudi::Accumulators::PrintableCounter &r)
const Gaudi::Accumulators::PrintableCounter * findCounter(std::string_view tag) const
AttribStringParser::Iterator begin(const AttribStringParser &parser)