The Gaudi Framework
master (57817a18)
Toggle main menu visibility
Loading...
Searching...
No Matches
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
18
namespace
Gaudi::Accumulators
{
19
20
namespace
details
{
21
26
struct
FormatCounterDefault
{
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>
40
CounterArrayInternal
( OWNER* owner, FormatName&& fname, std::integer_sequence<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
}
45
46
template
<
typename
OWNER, std::size_t... Ns>
47
CounterArrayInternal
( OWNER* owner, std::string_view name, std::integer_sequence<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
}
52
53
template
<std::size_t... Ns>
54
auto
buffer
( std::integer_sequence<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>
89
struct
CounterArray
:
details::CounterArrayInternal
<Counter, 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
Accumulators.h
Gaudi::Accumulators::details
Definition
Accumulators.h:1177
Gaudi::Accumulators
Efficient counter implementations for Gaudi.
Definition
Accumulators.h:18
details
Definition
AnyDataWrapper.h:19
std
STL namespace.
Gaudi::Accumulators::CounterArray::buffer
auto buffer()
Definition
CounterArray.h:93
Gaudi::Accumulators::CounterArray::CounterArray
CounterArray(OWNER *owner, FormatName &&fname)
Definition
CounterArray.h:91
Gaudi::Accumulators::Counter
A basic integral counter;.
Definition
Accumulators.h:962
Gaudi::Accumulators::details::CounterArrayInternal
internal class implementing an array of counters
Definition
CounterArray.h:37
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
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, 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::FormatCounterDefault
Default formating for counter names, only calling std::format on the text given at construction and p...
Definition
CounterArray.h:26
Gaudi::Accumulators::details::FormatCounterDefault::operator()
std::string operator()(size_t n)
Definition
CounterArray.cpp:14
Gaudi::Accumulators::details::FormatCounterDefault::text
std::string_view text
Definition
CounterArray.h:27
Gaudi::Accumulators::details::FormatCounterDefault::FormatCounterDefault
FormatCounterDefault(std::string_view t)
Definition
CounterArray.h:28
GaudiKernel
include
Gaudi
Accumulators
CounterArray.h
Generated on
for The Gaudi Framework by
1.17.0