The Gaudi Framework  v36r3 (83a1ddab)
FunctionalTool.h
Go to the documentation of this file.
1 /*****************************************************************************\
2 * (c) Copyright 2021 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 \*****************************************************************************/
12 #include "GaudiKernel/IBinder.h"
13 
14 namespace Gaudi::Functional {
15  namespace details {
16  // add a baseclass in case it isn't defined yet...
17  template <typename Tr, typename Base = FixTESPath<AlgTool>>
18  using add_base_t = std::conditional_t<Gaudi::cpp17::is_detected_v<detail2::BaseClass_t, Tr>, Tr,
20 
21  template <typename Signature, typename Traits>
22  class ToolBinder;
23 
24  template <typename IFace, typename... Args, typename Traits>
25  class ToolBinder<Gaudi::Interface::Bind::Box<IFace>( Args const&... ), Traits>
26  : public extends<details::BaseClass_t<Traits, AlgTool>, Gaudi::Interface::Bind::IBinder<IFace>> {
27 
28  constexpr static std::size_t N = sizeof...( Args );
29 
30  template <typename IArgs, std::size_t... I>
32  std::index_sequence<I...> )
33  : extends<details::BaseClass_t<Traits>, Gaudi::Interface::Bind::IBinder<IFace>>{ std::move( type ),
34  std::move( name ), parent }
35  , m_handles{ std::tuple_cat( std::forward_as_tuple( this ), std::get<I>( args ) )... } {}
36 
38 
39  public:
43  : ToolBinder{ std::move( type ), std::move( name ), parent, inputs, std::make_index_sequence<N>{} } {}
44 
45  virtual Gaudi::Interface::Bind::Box<IFace> operator()( const Args&... args ) const = 0;
46 
48  return std::apply(
49  [&]( auto const&... arg ) {
50  using namespace details;
51  return std::invoke( *this, get( arg, *this, ctx )... );
52  },
53  m_handles );
54  }
55 
56  template <std::size_t N = 0>
57  decltype( auto ) inputLocation() const {
58  using namespace details;
59  return getKey( std::get<N>( m_handles ) );
60  }
61  template <typename T>
62  decltype( auto ) inputLocation() const {
63  using namespace details;
64  return getKey( std::get<InputHandle_t<Traits, std::decay_t<T>>>( m_handles ) );
65  }
66  };
67  } // namespace details
68 
69  template <typename Signature, typename Traits_ = Traits::use_<Traits::BaseClass_t<AlgTool>>>
71 
72 } // namespace Gaudi::Functional
Gaudi::Functional::details::add_base_t
std::conditional_t< Gaudi::cpp17::is_detected_v< detail2::BaseClass_t, Tr >, Tr, Traits::use_< Tr, BaseClass_t< Base > >> add_base_t
Definition: FunctionalTool.h:19
std::string
STL class.
std::move
T move(T... args)
Gaudi::Functional::details::InputHandle_t
Gaudi::cpp17::detected_or_t< detail2::DefaultInputHandle< T >, detail2::InputHandle_t, Tr, T > InputHandle_t
Definition: FunctionalDetails.h:392
std::pair< std::string, std::string >
Gaudi::Interface::Bind::Box
Definition: IBinder.h:23
IOTest.N
int N
Definition: IOTest.py:115
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: FunctionalTool.h:47
std::tuple
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: FunctionalDetails.h:412
TimingHistograms.name
name
Definition: TimingHistograms.py:25
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:588
details
Definition: AnyDataWrapper.h:18
Gaudi::Functional::Traits::use_
Definition: FunctionalUtilities.h:68
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::m_handles
std::tuple< details::InputHandle_t< Traits, Args >... > m_handles
Definition: FunctionalTool.h:37
Gaudi::Functional
Definition: Consumer.h:19
std::forward_as_tuple
T forward_as_tuple(T... args)
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
IBinder.h
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::ToolBinder
ToolBinder(std::string type, std::string name, const IInterface *parent, Gaudi::Functional::details::RepeatValues_< KeyValue, N > const &inputs)
Definition: FunctionalTool.h:41
gaudirun.type
type
Definition: gaudirun.py:160
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::ToolBinder
ToolBinder(std::string type, std::string name, const IInterface *parent, IArgs &&args, std::index_sequence< I... >)
Definition: FunctionalTool.h:31
gaudirun.args
args
Definition: gaudirun.py:336
IInterface
Definition: IInterface.h:237
EventContext
Definition: EventContext.h:34
Gaudi::Functional::details::RepeatValues_
decltype(get_values_helper< Value >(std::make_index_sequence< N >())) RepeatValues_
Definition: FunctionalDetails.h:156
Gaudi::Functional::details::ToolBinder
Definition: FunctionalTool.h:22
std::tuple_cat
T tuple_cat(T... args)
std::size_t
Gaudi::Functional::details::BaseClass_t
Gaudi::cpp17::detected_or_t< Base, detail2::BaseClass_t, Tr > BaseClass_t
Definition: FunctionalDetails.h:383
FunctionalDetails.h
Gaudi::Functional::details::ToolBinder< Gaudi::Interface::Bind::Box< IFace >(Args const &...), Traits >::operator()
virtual Gaudi::Interface::Bind::Box< IFace > operator()(const Args &... args) const =0
Gaudi::Functional::details::getKey
auto getKey(const Handle &h) -> decltype(h.objKey())
Definition: FunctionalDetails.h:424