Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  master (f31105fd)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CounterArray.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #pragma once
12 
13 #include <Gaudi/Accumulators.h>
14 #include <array>
15 #include <string>
16 #include <utility>
17 
19 
20  namespace details {
21 
27  std::string_view text;
28  FormatCounterDefault( std::string_view t ) : text{ t } {}
29  std::string operator()( size_t n );
30  };
31 
36  template <typename Counter, std::size_t N>
37  struct CounterArrayInternal : std::array<Counter, N> {
39  template <typename OWNER, std::invocable<int> FormatName, std::size_t... Ns>
41  : std::array<Counter, N>{ Counter{ owner, fname( Ns ) }... } {
42  static_assert( sizeof...( Ns ) < 1000, "Using CounterArray with 1000 arrays or more is prohibited. This "
43  "would lead to very long compilation times" );
44  }
46  template <typename OWNER, std::size_t... Ns>
48  : std::array<Counter, N>{ Counter{ owner, FormatCounterDefault{ name }( Ns ) }... } {
49  static_assert( sizeof...( Ns ) < 1000, "Using CounterArray with 1000 arrays or more is prohibited. This "
50  "would lead to very long compilation times" );
51  }
53  template <std::size_t... Ns>
55  return std::array{ ( *this )[Ns].buffer()... };
56  }
57  };
58  } // namespace details
59 
88  template <typename Counter, std::size_t N>
90  template <typename OWNER, typename FormatName>
91  CounterArray( OWNER* owner, FormatName&& fname )
92  : details::CounterArrayInternal<Counter, N>( owner, fname, std::make_integer_sequence<std::size_t, N>{} ) {}
93  auto buffer() {
94  return details::CounterArrayInternal<Counter, N>::buffer( std::make_integer_sequence<std::size_t, N>{} );
95  }
96  };
97 
98 } // namespace Gaudi::Accumulators
Gaudi::Accumulators::details::FormatCounterDefault::operator()
std::string operator()(size_t n)
Definition: CounterArray.cpp:14
std::string
STL class.
IOTest.N
N
Definition: IOTest.py:112
Gaudi::Accumulators::details::FormatCounterDefault::FormatCounterDefault
FormatCounterDefault(std::string_view t)
Definition: CounterArray.h:28
Gaudi::Accumulators::Counter
A basic integral counter;.
Definition: Accumulators.h:939
std::integer_sequence
Gaudi::Accumulators::details::CounterArrayInternal::buffer
auto buffer(std::integer_sequence< std::size_t, Ns... >)
Method to form an array of buffers.
Definition: CounterArray.h:54
Gaudi::Accumulators::details::CounterArrayInternal::CounterArrayInternal
CounterArrayInternal(OWNER *owner, FormatName &&fname, std::integer_sequence< std::size_t, Ns... >)
constructor with callables for FormatName
Definition: CounterArray.h:40
bug_34121.t
t
Definition: bug_34121.py:31
Gaudi::Accumulators::details::FormatCounterDefault
Default formating for counter names, only calling fmt::format on the text given at construction and p...
Definition: CounterArray.h:26
Gaudi::Accumulators::CounterArray::CounterArray
CounterArray(OWNER *owner, FormatName &&fname)
Definition: CounterArray.h:91
details
Definition: AnyDataWrapper.h:19
std::array
STL class.
Gaudi::Accumulators::CounterArray
generic class implementing an array of counters The only addition to a raw array is the constructor t...
Definition: CounterArray.h:89
cpluginsvc.n
n
Definition: cpluginsvc.py:234
Gaudi::Accumulators::CounterArray::buffer
auto buffer()
Definition: CounterArray.h:93
Accumulators.h
Gaudi::Accumulators
Definition: CounterArray.h:18
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Containers::array
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
Definition: KeyedObjectManager.h:37
std
STL namespace.
std::size_t
Gaudi::Accumulators::details::CounterArrayInternal::CounterArrayInternal
CounterArrayInternal(OWNER *owner, std::string_view name, std::integer_sequence< std::size_t, Ns... >)
constructor for strings, FormatCounterDefault is used as the default callable
Definition: CounterArray.h:47
Gaudi::Accumulators::details::CounterArrayInternal
internal class implementing an array of counters
Definition: CounterArray.h:37
Gaudi::Accumulators::details::FormatCounterDefault::text
std::string_view text
Definition: CounterArray.h:27