The Gaudi Framework
master (57817a18)
Toggle main menu visibility
Loading...
Searching...
No Matches
ToolBinder.h
Go to the documentation of this file.
1
/*****************************************************************************\
2
* (c) Copyright 2021-2026 CERN for the benefit of the LHCb Collaboration *
3
* *
4
* This software is distributed under the terms of the GNU General Public *
5
* Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". *
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
#include "
details.h
"
13
#include "
utilities.h
"
14
#include <
GaudiKernel/AlgTool.h
>
15
#include <
GaudiKernel/IBinder.h
>
16
17
namespace
Gaudi::Functional
{
18
namespace
details
{
19
template
<
typename
Signature,
typename
Traits>
20
class
ToolBinder
;
21
22
template
<
typename
IFace,
typename
... Args,
typename
Traits
>
23
class
ToolBinder
<
Gaudi
::
Interface::Bind::Box
<IFace>( Args const&... ),
Traits
>
24
:
public
extends
<details::BaseClass_t<Traits, AlgTool>, Gaudi::Interface::Bind::IBinder<IFace>> {
25
26
public
:
27
constexpr
static
std::size_t
N
=
sizeof
...( Args );
28
using
KeyValue
=
LocationSpec::KeyValue
;
29
using
KeyValues
=
LocationSpec::KeyValues
;
30
using
InputSpecTuple
=
LocationSpecs_t
<Args...>;
31
using
InputSpecs
=
LocationSpecs<InputSpecTuple>
;
32
using
Creator
=
Gaudi::Interface::Bind::Box<IFace>
( * )(
void
const
*, Args
const
&... );
33
34
template
<
size_t
... I>
35
ToolBinder
( std::string type, std::string name,
const
IInterface
* parent,
InputSpecTuple
const
& args,
36
Creator
creator, std::index_sequence<I...> )
37
:
extends
<
details
::
BaseClass_t
<
Traits
,
AlgTool
>,
Gaudi
::
Interface
::Bind::IBinder<IFace>>{ std::move( type ),
38
std::move( name ),
39
parent }
40
, m_handles{ std::tuple_cat( std::forward_as_tuple(
this
), std::get<I>( args ) )... }
41
, m_creator{ creator } {}
42
43
private
:
44
std::tuple<details::InputHandle_t<Traits, Args>...>
m_handles
;
45
Creator
m_creator
;
46
47
public
:
48
ToolBinder
( std::string type, std::string name,
const
IInterface
* parent,
InputSpecs
const
& inputs,
49
Creator
creator )
50
:
ToolBinder
{
std
::move( type ),
std
::move( name ), parent,
51
inputs.tuple(), creator,
std
::make_index_sequence<
N
>{} } {}
52
53
Gaudi::Interface::Bind::Box<IFace>
bind
(
EventContext
const
& ctx )
const
final
{
54
return
std::apply(
55
[&](
auto
const
&... arg ) {
56
using namespace
details
;
57
return
std::invoke(
m_creator
,
this
,
get
( arg, *
this
, ctx )... );
58
},
59
m_handles
);
60
}
61
62
template
<std::
size_t
N = 0>
63
decltype
( auto )
inputLocation
()
const
{
64
using namespace
details
;
65
return
getKey
( std::get<N>(
m_handles
) );
66
}
67
template
<
typename
T>
68
decltype
( auto )
inputLocation
()
const
{
69
using namespace
details
;
70
return
getKey
( std::get<
InputHandle_t
<
Traits
, std::decay_t<T>>>(
m_handles
) );
71
}
72
73
// TODO: make this a callable instance?
74
template
<
typename
BoundInstance,
typename
Self>
75
static
auto
construct
( Self* ) {
76
static_assert
( std::is_base_of_v<ToolBinder, Self> );
77
return
+[](
void
const
* ptr,
const
Args&... args ) {
78
return
Gaudi::Interface::Bind::Box<IFace>
{ std::in_place_type<BoundInstance>,
79
static_cast<
std::add_const_t<Self>*
>
( ptr ), args... };
80
};
81
}
82
};
83
}
// namespace details
84
85
template
<
typename
Signature,
typename
Traits_ = Traits::use_<Traits::BaseClass_t<AlgTool>>>
86
using
ToolBinder
=
details::ToolBinder<Signature, Traits_>
;
87
88
}
// namespace Gaudi::Functional
AlgTool.h
IBinder.h
AlgTool
Base class from which all the concrete tool classes should be derived.
Definition
AlgTool.h:55
EventContext
This class represents an entry point to all the event specific data.
Definition
EventContext.h:35
Gaudi::Functional::details::LocationSpecs
Definition
details.h:606
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::bind
Gaudi::Interface::Bind::Box< IFace > bind(EventContext const &ctx) const final
Definition
ToolBinder.h:53
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::m_creator
Creator m_creator
Definition
ToolBinder.h:45
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::N
static constexpr std::size_t N
Definition
ToolBinder.h:27
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::Creator
Gaudi::Interface::Bind::Box< IFace >(*)(void const *, Args const &...) Creator
Definition
ToolBinder.h:32
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::construct
static auto construct(Self *)
Definition
ToolBinder.h:75
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::KeyValues
LocationSpec::KeyValues KeyValues
Definition
ToolBinder.h:29
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::inputLocation
decltype(auto) inputLocation() const
Definition
ToolBinder.h:63
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::KeyValue
LocationSpec::KeyValue KeyValue
Definition
ToolBinder.h:28
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::InputSpecs
LocationSpecs< InputSpecTuple > InputSpecs
Definition
ToolBinder.h:31
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::ToolBinder
ToolBinder(std::string type, std::string name, const IInterface *parent, InputSpecTuple const &args, Creator creator, std::index_sequence< I... >)
Definition
ToolBinder.h:35
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::m_handles
std::tuple< details::InputHandle_t< Traits, Args >... > m_handles
Definition
ToolBinder.h:44
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::ToolBinder
ToolBinder(std::string type, std::string name, const IInterface *parent, InputSpecs const &inputs, Creator creator)
Definition
ToolBinder.h:48
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::InputSpecTuple
LocationSpecs_t< Args... > InputSpecTuple
Definition
ToolBinder.h:30
Gaudi::Functional::details::ToolBinder
Definition
ToolBinder.h:20
Gaudi::Interface::Bind::Box
Definition
IBinder.h:22
IInterface
Definition of the basic interface.
Definition
IInterface.h:225
extends
Base class used to extend a class implementing other interfaces.
Definition
extends.h:19
details.h
Gaudi::Functional::Traits
Definition
utilities.h:17
Gaudi::Functional::details
Definition
Consumer.h:17
Gaudi::Functional::details::InputHandle_t
typename detail2::InputHandle< T, Tr, detail2::DefaultInputHandle_t >::type InputHandle_t
Definition
details.h:499
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition
details.h:652
Gaudi::Functional::details::getKey
auto getKey(const Handle &h) -> decltype(h.objKey())
Definition
details.h:677
Gaudi::Functional::details::LocationSpecs_t
std::tuple< LocationSpec_t< Args >... > LocationSpecs_t
Definition
details.h:550
Gaudi::Functional::details::BaseClass_t
detail2::BaseClass< Tr, Default >::type BaseClass_t
Definition
details.h:490
Gaudi::Functional
Definition
Consumer.h:15
Gaudi::Functional::ToolBinder
details::ToolBinder< Signature, Traits_ > ToolBinder
Definition
ToolBinder.h:86
Gaudi::Interface
Definition
IBinder.h:19
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition
__init__.py:1
details
Definition
AnyDataWrapper.h:19
std
STL namespace.
Gaudi::Functional::details::LocationSpec::KeyValue
std::pair< std::string, std::string > KeyValue
Definition
details.h:505
Gaudi::Functional::details::LocationSpec::KeyValues
std::pair< std::string, std::vector< std::string > > KeyValues
Definition
details.h:506
utilities.h
GaudiFunctional
include
Gaudi
Functional
ToolBinder.h
Generated on
for The Gaudi Framework by
1.17.0