The Gaudi Framework  v37r1 (a7f61348)
CounterArray.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2022 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 <utility>
15 
16 namespace Gaudi::Accumulators {
17 
18  namespace details {
19 
25  std::string_view text;
26  FormatCounterDefault( std::string_view t ) : text{ t } {}
27  std::string operator()( size_t n );
28  };
29 
34  template <typename Counter, std::size_t N>
35  struct CounterArrayInternal : std::array<Counter, N> {
37  template <typename OWNER, typename FormatName, std::size_t... Ns,
38  typename = typename std::enable_if_t<std::is_invocable_v<FormatName, int>>>
40  : std::array<Counter, N>{ Counter{ owner, fname( Ns ) }... } {
41  static_assert( sizeof...( Ns ) < 1000, "Using CounterArray with 1000 arrays or more is prohibited. This "
42  "would lead to very long compilation times" );
43  }
45  template <typename OWNER, std::size_t... Ns>
47  : std::array<Counter, N>{ Counter{ owner, FormatCounterDefault{ name }( Ns ) }... } {
48  static_assert( sizeof...( Ns ) < 1000, "Using CounterArray with 1000 arrays or more is prohibited. This "
49  "would lead to very long compilation times" );
50  }
51  };
52  } // namespace details
53 
79  template <typename Counter, std::size_t N>
81  template <typename OWNER, typename FormatName>
82  CounterArray( OWNER* owner, FormatName&& fname )
83  : details::CounterArrayInternal<Counter, N>( owner, fname, std::make_integer_sequence<std::size_t, N>{} ) {}
84  };
85 
86 } // namespace Gaudi::Accumulators
Gaudi::Accumulators::details::FormatCounterDefault::operator()
std::string operator()(size_t n)
Definition: CounterArray.cpp:23
std::string
STL class.
IOTest.N
N
Definition: IOTest.py:110
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:39
Gaudi::Accumulators::details::FormatCounterDefault::FormatCounterDefault
FormatCounterDefault(std::string_view t)
Definition: CounterArray.h:26
bug_34121.name
name
Definition: bug_34121.py:20
Gaudi::Accumulators::Counter
A basic integral counter;.
Definition: Accumulators.h:905
std::integer_sequence
bug_34121.t
t
Definition: bug_34121.py:30
Gaudi::Accumulators::details::FormatCounterDefault
Default formating for counter names, only calling fmt::format on the text given at construction and p...
Definition: CounterArray.h:24
Gaudi::Accumulators::CounterArray::CounterArray
CounterArray(OWNER *owner, FormatName &&fname)
Definition: CounterArray.h:82
details
Definition: AnyDataWrapper.h:18
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:80
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:235
Accumulators.h
Gaudi::Accumulators
Definition: HistogramsTests.cpp:20
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:46
Gaudi::Accumulators::details::CounterArrayInternal
internal class implementing an array of counters
Definition: CounterArray.h:35
Gaudi::Accumulators::details::FormatCounterDefault::text
std::string_view text
Definition: CounterArray.h:25