The Gaudi Framework
master (bdbe7744)
Toggle main menu visibility
Loading...
Searching...
No Matches
ToolVisitor.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 <
GaudiKernel/IAlgTool.h
>
14
#include <functional>
15
#include <regex>
16
#include <type_traits>
17
20
class
ToolVisitor {
21
struct
IVisitor {
22
virtual
~IVisitor() =
default
;
23
virtual
void
visit( IAlgTool* )
const
= 0;
24
};
25
26
public
:
39
template
<std::invocable<IAlgTool*> Callable>
40
requires
( std::is_invocable_r_v<void, Callable, IAlgTool*> )
41
static
void
visit(
const
std::vector<IAlgTool*>& tools, Callable& callable,
42
const
std::regex& reject_filter = s_noFilter ) {
43
class
Visitor final :
public
IVisitor {
44
Callable* m_func;
45
46
public
:
47
Visitor( Callable* f ) : m_func{ f } {}
48
void
visit( IAlgTool* alg_tool )
const override
{ std::invoke( *m_func, alg_tool ); }
49
};
50
recursiveVisit( tools, Visitor{ &callable }, reject_filter );
51
}
52
53
private
:
54
static
void
recursiveVisit(
const
std::vector<IAlgTool*>& tools, IVisitor
const
& visitor,
55
const
std::regex& reject_filter );
56
static
const
std::regex s_noFilter;
57
};
IAlgTool.h
GaudiKernel
include
GaudiKernel
ToolVisitor.h
Generated on
for The Gaudi Framework by
1.17.0