The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
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, std::invocable< int > FormatName, std::size_t... Ns>
 CounterArrayInternal (OWNER *owner, FormatName &&fname, std::integer_sequence< std::size_t, Ns... >)
 constructor with callables for FormatName
 
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
 
template<std::size_t... Ns>
auto buffer (std::integer_sequence< std::size_t, Ns... >)
 Method to form an array of buffers.
 

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 89 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 91 of file CounterArray.h.

generic class implementing an array of counters The only addition to a raw array is the constructor t...

Member Function Documentation

◆ buffer()

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

Definition at line 93 of file CounterArray.h.

93 {
95 }
auto buffer(std::integer_sequence< std::size_t, Ns... >)
Method to form an array of buffers.

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