The Gaudi Framework  master (594c33fa)
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)
 
auto buffer ()
 
- 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...
 
template<std::size_t... Ns>
auto buffer (std::integer_sequence< std::size_t, Ns... >)
 Method to form an array of buffers. 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 simple 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]; // increment via local buffer object auto cbuffer = counters.buffer(); ++cbuffer[4];

Definition at line 90 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 92 of file CounterArray.h.

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

Member Function Documentation

◆ buffer()

template<typename Counter , std::size_t N>
auto Gaudi::Accumulators::CounterArray< Counter, N >::buffer ( )
inline

Definition at line 94 of file CounterArray.h.

94  {
95  return details::CounterArrayInternal<Counter, N>::buffer( std::make_integer_sequence<std::size_t, N>{} );
96  }

The documentation for this struct was generated from the following file:
Gaudi::Accumulators::details::CounterArrayInternal::buffer
auto buffer(std::integer_sequence< std::size_t, Ns... >)
Method to form an array of buffers.
Definition: CounterArray.h:55