The Gaudi Framework  v37r1 (a7f61348)
Gaudi::Accumulators::CounterArray< Counter, N > Struct Template Reference

generic class implementing an array of counters The only addition to a raw array is the constructor that allows to build names of the counters automatically from the index of the counter in the array There are 2 possibilities : More...

#include </builds/gaudi/Gaudi/GaudiKernel/include/Gaudi/Accumulators/CounterArray.h>

Inheritance diagram for Gaudi::Accumulators::CounterArray< Counter, N >:
Collaboration diagram for Gaudi::Accumulators::CounterArray< Counter, N >:

Public Member Functions

template<typename OWNER , typename FormatName >
 CounterArray (OWNER *owner, FormatName &&fname)
 
- Public Member Functions inherited from Gaudi::Accumulators::details::CounterArrayInternal< Counter, N >
template<typename OWNER , typename FormatName , std::size_t... Ns, typename = typename std::enable_if_t<std::is_invocable_v<FormatName, int>>>
 CounterArrayInternal (OWNER *owner, FormatName &&fname, std::integer_sequence< std::size_t, Ns... >)
 constructor with callables for FormatName More...
 
template<typename OWNER , std::size_t... Ns>
 CounterArrayInternal (OWNER *owner, std::string_view name, std::integer_sequence< std::size_t, Ns... >)
 constructor for strings, FormatCounterDefault is used as the default callable More...
 
- Public Member Functions inherited from std::array< Counter, N >
Counter max_size (Counter ... args)
 
Counter rbegin (Counter ... args)
 
Counter crend (Counter ... args)
 
Counter crbegin (Counter ... args)
 
Counter swap (Counter ... args)
 
Counter data (Counter ... args)
 
Counter back (Counter ... args)
 
Counter end (Counter ... args)
 
Counter fill (Counter ... args)
 
Counter empty (Counter ... args)
 
Counter cend (Counter ... args)
 
Counter size (Counter ... args)
 
Counter cbegin (Counter ... args)
 
Counter rend (Counter ... args)
 
Counter front (Counter ... args)
 
Counter at (Counter ... args)
 
Counter operator[] (Counter ... args)
 
Counter begin (Counter ... args)
 

Additional Inherited Members

- Public Attributes inherited from std::array< Counter, N >
Counter elements
 STL member. More...
 

Detailed Description

template<typename Counter, std::size_t N>
struct Gaudi::Accumulators::CounterArray< Counter, N >

generic class implementing an array of counters The only addition to a raw array is the constructor that allows to build names of the counters automatically from the index of the counter in the array There are 2 possibilities :

  • if a string_view is given, it is used in a call to std::format(name, n);
  • if a callable is given, it is called on the index it should take a size_t and return some type convertible to string_view actual implementation is in CounterArrayInternal

Typical usage : // Array of 5 simple counters with simple names. Names will be MyCounter-0, MyCounter-1, ... CounterArray<Counter<>, 5> counters{ &algo, "MyCounter-{}" }; ++counters[1]; // Array of 5 averaging counters with same simple names CounterArray<AveragingCounter<>, 5> avgCounters{ &algo, "MyCounter-{}" }; avgCounters[2] += 3.14; // Array of 5 cimple counters with custom names. Names will be "0^2=0", "1^2=1", "2^2=4", ... CounterArray<Counter<>, 5> customCounters{ &algo, []( int n ) { return fmt::format( "{}^2={}", n, n*n ); } } ++customCounters[3];

Definition at line 80 of file CounterArray.h.

Constructor & Destructor Documentation

◆ CounterArray()

template<typename Counter , std::size_t N>
template<typename OWNER , typename FormatName >
Gaudi::Accumulators::CounterArray< Counter, N >::CounterArray ( OWNER *  owner,
FormatName &&  fname 
)
inline

Definition at line 82 of file CounterArray.h.

83  : details::CounterArrayInternal<Counter, N>( owner, fname, std::make_integer_sequence<std::size_t, N>{} ) {}

The documentation for this struct was generated from the following file: