The Gaudi Framework  v33r1 (b1225454)
FunctionalDetails.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 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 #ifndef FUNCTIONAL_DETAILS_H
12 #define FUNCTIONAL_DETAILS_H
13 
14 #include <cassert>
15 #include <sstream>
16 #include <stdexcept>
17 #include <type_traits>
18 
19 // TODO: fwd declare instead?
21 #include "GaudiKernel/Algorithm.h"
25 #include "GaudiKernel/detected.h"
26 
27 // Range V3
28 #include <range/v3/version.hpp>
29 #include <range/v3/view/const.hpp>
30 #include <range/v3/view/zip.hpp>
31 // upstream has renamed namespace ranges::view ranges::views
32 #if RANGE_V3_VERSION < 900
33 namespace ranges::views {
34  using namespace ranges::view;
35 }
36 #endif
37 
38 #if defined( __clang__ ) && ( __clang_major__ < 9 ) || defined( __APPLE__ ) && ( __clang_major__ < 12 )
39 # define GF_SUPPRESS_SPURIOUS_CLANG_WARNING_BEGIN \
40  _Pragma( "clang diagnostic push" ) _Pragma( "clang diagnostic ignored \"-Wunused-lambda-capture\"" )
41 # define GF_SUPPRESS_SPURIOUS_CLANG_WARNING_END _Pragma( "clang diagnostic pop" )
42 #else
43 # define GF_SUPPRESS_SPURIOUS_CLANG_WARNING_BEGIN
44 # define GF_SUPPRESS_SPURIOUS_CLANG_WARNING_END
45 #endif
46 
48 
49  // CRJ : Stuff for zipping
50  namespace zip {
51 
53  template <typename OS, typename Arg>
54  void printSizes( OS& out, Arg&& arg ) {
55  out << "SizeOf'" << System::typeinfoName( typeid( Arg ) ) << "'=" << std::forward<Arg>( arg ).size();
56  }
57 
59  template <typename OS, typename Arg, typename... Args>
60  void printSizes( OS& out, Arg&& arg, Args&&... args ) {
61  printSizes( out, arg );
62  out << ", ";
63  printSizes( out, args... );
64  }
65 
67  template <typename A>
68  inline bool check_sizes( const A& ) noexcept {
69  return true;
70  }
71 
73  template <typename A, typename B>
74  inline bool check_sizes( const A& a, const B& b ) noexcept {
75  return a.size() == b.size();
76  }
77 
79  template <typename A, typename B, typename... C>
80  inline bool check_sizes( const A& a, const B& b, const C&... c ) noexcept {
81  return ( check_sizes( a, b ) && check_sizes( b, c... ) );
82  }
83 
85  template <typename... Args>
86  inline decltype( auto ) verifySizes( Args&... args ) {
87  if ( UNLIKELY( !check_sizes( args... ) ) ) {
88  std::ostringstream mess;
89  mess << "Zipped containers have different sizes : ";
90  printSizes( mess, args... );
91  throw GaudiException( mess.str(), "Gaudi::Functional::details::zip::verifySizes", StatusCode::FAILURE );
92  }
93  }
94 
96  template <typename... Args>
97  inline decltype( auto ) range( Args&&... args ) {
98 #ifndef NDEBUG
99  verifySizes( args... );
100 #endif
101  return ranges::views::zip( std::forward<Args>( args )... );
102  }
103 
105  template <typename... Args>
106  inline decltype( auto ) const_range( Args&&... args ) {
107 #ifndef NDEBUG
108  verifySizes( args... );
109 #endif
110  return ranges::views::const_( ranges::views::zip( std::forward<Args>( args )... ) );
111  }
112  } // namespace zip
113 
115  namespace details2 {
116  // note: boost::optional in boost 1.66 does not have 'has_value()'...
117  // that requires boost 1.68 or later... so for now, use operator bool() instead ;-(
118  template <typename T>
119  using is_optional_ = decltype( bool{std::declval<T>()}, std::declval<T>().value() );
120  } // namespace details2
121  template <typename Arg>
122  constexpr bool is_optional_v = Gaudi::cpp17::is_detected_v<details2::is_optional_, Arg>;
123 
124  template <typename Arg>
125  using require_is_optional = std::enable_if_t<is_optional_v<Arg>>;
126 
127  template <typename Arg>
128  using require_is_not_optional = std::enable_if_t<!is_optional_v<Arg>>;
129 
130  template <typename T>
131  using remove_optional_t = std::conditional_t<is_optional_v<T>, typename T::value_type, T>;
132 
133  constexpr struct invoke_optionally_t {
134  template <typename F, typename Arg, typename = require_is_not_optional<Arg>>
135  decltype( auto ) operator()( F&& f, Arg&& arg ) const {
136  return std::invoke( std::forward<F>( f ), std::forward<Arg>( arg ) );
137  }
138  template <typename F, typename Arg, typename = require_is_optional<Arg>>
139  void operator()( F&& f, Arg&& arg ) const {
140  if ( arg ) std::invoke( std::forward<F>( f ), *std::forward<Arg>( arg ) );
141  }
142  } invoke_optionally{};
144 
145  template <typename Out1, typename Out2,
146  typename = std::enable_if_t<std::is_constructible_v<Out1, Out2> && std::is_base_of_v<DataObject, Out1>>>
147  Out1* put( const DataObjectHandle<Out1>& out_handle, Out2&& out ) {
148  return out_handle.put( std::make_unique<Out1>( std::forward<Out2>( out ) ) );
149  }
150 
151  template <typename Out1, typename Out2, typename = std::enable_if_t<std::is_constructible_v<Out1, Out2>>>
152  void put( const DataObjectHandle<AnyDataWrapper<Out1>>& out_handle, Out2&& out ) {
153  out_handle.put( std::forward<Out2>( out ) );
154  }
155 
156  // optional put
157  template <typename OutHandle, typename OptOut, typename = require_is_optional<OptOut>>
158  void put( const OutHandle& out_handle, OptOut&& out ) {
159  if ( out ) put( out_handle, *std::forward<OptOut>( out ) );
160  }
162  // adapt to differences between eg. std::vector (which has push_back) and KeyedContainer (which has insert)
163  // adapt to getting a T, and a container wanting T* by doing new T{ std::move(out) }
164  // adapt to getting a optional<T>
165 
166  constexpr struct insert_t {
167  // for Container<T*>, return T
168  template <typename Container>
169  using c_remove_ptr_t = std::remove_pointer_t<typename Container::value_type>;
170 
171  template <typename Container, typename Value>
172  auto operator()( Container& c, Value&& v ) const -> decltype( c.push_back( v ) ) {
173  return c.push_back( std::forward<Value>( v ) );
174  }
175 
176  template <typename Container, typename Value>
177  auto operator()( Container& c, Value&& v ) const -> decltype( c.insert( v ) ) {
178  return c.insert( std::forward<Value>( v ) );
179  }
180 
181  // Container<T*> with T&& as argument
182  template <typename Container, typename Value,
183  typename = std::enable_if_t<std::is_pointer_v<typename Container::value_type>>,
184  typename = std::enable_if_t<std::is_convertible_v<Value, c_remove_ptr_t<Container>>>>
185  auto operator()( Container& c, Value&& v ) const {
186  return operator()( c, new c_remove_ptr_t<Container>{std::forward<Value>( v )} );
187  }
188 
189  } insert{};
190 
192 
193  constexpr struct deref_t {
194  template <typename In, typename = std::enable_if_t<!std::is_pointer_v<In>>>
195  const In& operator()( const In& in ) const {
196  return in;
197  }
198 
199  template <typename In, typename = std::enable_if_t<!std::is_pointer_v<std::decay_t<In>>>>
200  In operator()( In&& in ) const {
201  return std::forward<In>( in );
202  }
203 
204  template <typename In>
205  const In& operator()( const In* in ) const {
206  assert( in != nullptr );
207  return *in;
208  }
209  } deref{};
210 
212  // if Container is a pointer, then we're optional items
213  namespace details2 {
214  template <typename Container, typename Value>
215  void push_back( Container& c, const Value& v, std::true_type ) {
216  c.push_back( v );
217  }
218  template <typename Container, typename Value>
219  void push_back( Container& c, const Value& v, std::false_type ) {
220  c.push_back( &v );
221  }
222 
223  template <typename In>
225  template <template <typename> class Handle, typename I, typename = std::enable_if_t<std::is_convertible_v<I, In>>>
226  auto operator()( const Handle<I>& h ) -> const In& {
227  return *h.get();
228  }
229  template <template <typename> class Handle, typename I,
230  typename = std::enable_if_t<std::is_convertible_v<I*, In>>>
231  auto operator()( const Handle<I>& h ) -> const In {
232  return h.getIfExists();
233  } // In is-a pointer
234  };
235 
236  template <typename T>
237  T* deref_if( T* const t, std::false_type ) {
238  return t;
239  }
240  template <typename T>
241  T& deref_if( T* const t, std::true_type ) {
242  return *t;
243  }
244  } // namespace details2
245 
246  template <typename Container>
248  static constexpr bool is_pointer = std::is_pointer_v<Container>;
249  using val_t = std::add_const_t<std::remove_pointer_t<Container>>;
250  using ptr_t = std::add_pointer_t<val_t>;
251  using ref_t = std::add_lvalue_reference_t<val_t>;
254 
255  public:
256  using value_type = std::conditional_t<is_pointer, ptr_t, val_t>;
257  using size_type = typename ContainerVector::size_type;
258  class iterator {
259  using it_t = typename ContainerVector::const_iterator;
261  friend class vector_of_const_;
262  iterator( it_t iter ) : m_i( iter ) {}
263  using ret_t = std::conditional_t<is_pointer, ptr_t, ref_t>;
264 
265  public:
266  using iterator_category = typename it_t::iterator_category;
267  using value_type = typename it_t::iterator_category;
268  using reference = typename it_t::reference;
269  using pointer = typename it_t::pointer;
270  using difference_type = typename it_t::difference_type;
271 
272  friend bool operator!=( const iterator& lhs, const iterator& rhs ) { return lhs.m_i != rhs.m_i; }
273  friend bool operator==( const iterator& lhs, const iterator& rhs ) { return lhs.m_i == rhs.m_i; }
274  friend auto operator-( const iterator& lhs, const iterator& rhs ) { return lhs.m_i - rhs.m_i; }
275  ret_t operator*() const { return details2::deref_if( *m_i, std::bool_constant<!is_pointer>{} ); }
277  ++m_i;
278  return *this;
279  }
281  --m_i;
282  return *this;
283  }
284  bool is_null() const { return !*m_i; }
285  explicit operator bool() const { return !is_null(); }
286  };
287  vector_of_const_() = default;
288  void reserve( size_type size ) { m_containers.reserve( size ); }
289  template <typename T> // , typename = std::is_convertible<T,std::conditional_t<is_pointer,ptr_t,val_t>>
290  void push_back( T&& container ) {
291  details2::push_back( m_containers, std::forward<T>( container ), std::bool_constant<is_pointer>{} );
292  } // note: does not copy its argument, so we're not really a container...
293  iterator begin() const { return m_containers.begin(); }
294  iterator end() const { return m_containers.end(); }
295  size_type size() const { return m_containers.size(); }
296 
297  template <typename X = Container>
298  std::enable_if_t<!std::is_pointer_v<X>, ref_t> operator[]( size_type i ) const {
299  return *m_containers[i];
300  }
301 
302  template <typename X = Container>
303  std::enable_if_t<std::is_pointer_v<X>, ptr_t> operator[]( size_type i ) const {
304  return m_containers[i];
305  }
306 
307  template <typename X = Container>
308  std::enable_if_t<!std::is_pointer_v<X>, ref_t> at( size_type i ) const {
309  return *m_containers[i];
310  }
311 
312  template <typename X = Container>
313  std::enable_if_t<std::is_pointer_v<X>, ptr_t> at( size_type i ) const {
314  return m_containers[i];
315  }
316 
317  bool is_null( size_type i ) const { return !m_containers[i]; }
318  };
319 
321  namespace detail2 { // utilities for detected_or_t{,_} usage
322  template <typename Tr>
323  using BaseClass_t = typename Tr::BaseClass;
324  template <typename Tr, typename T>
325  using OutputHandle_t = typename Tr::template OutputHandle<T>;
326  template <typename Tr, typename T>
327  using InputHandle_t = typename Tr::template InputHandle<T>;
328  } // namespace detail2
329 
330  // check whether Traits::BaseClass is a valid type,
331  // if so, define BaseClass_t<Traits> as being Traits::BaseClass
332  // else define as being GaudiAlgorithm
333  template <typename Tr>
334  using BaseClass_t = Gaudi::cpp17::detected_or_t<GaudiAlgorithm, detail2::BaseClass_t, Tr>;
335 
336  // check whether Traits::{Input,Output}Handle<T> is a valid type,
337  // if so, define {Input,Output}Handle_t<Traits,T> as being Traits::{Input,Output}Handle<T>
338  // else define as being DataObject{Read,,Write}Handle<T>
339  template <typename Tr, typename T>
340  using OutputHandle_t = Gaudi::cpp17::detected_or_t<DataObjectWriteHandle<T>, detail2::OutputHandle_t, Tr, T>;
341  template <typename Tr, typename T>
342  using InputHandle_t = Gaudi::cpp17::detected_or_t<DataObjectReadHandle<T>, detail2::InputHandle_t, Tr, T>;
343 
344  template <typename Traits>
345  inline constexpr bool isLegacy =
346  std::is_base_of_v<Gaudi::details::LegacyAlgorithmAdapter, details::BaseClass_t<Traits>>;
347 
349 
350  template <typename Handles>
352  Handles handles;
353  handles.reserve( init.size() );
355  init.begin(), init.end(),
356  std::back_inserter( handles ), [&]( const std::string& loc ) -> typename Handles::value_type {
357  return {loc, owner};
358  } );
359  return handles;
360  }
361 
362  template <typename Handle, typename Algo>
363  auto get( const Handle& handle, const Algo&, const EventContext& )
364  -> decltype( details::deref( handle.get() ) ) // make it SFINAE friendly...
365  {
366  return details::deref( handle.get() );
367  }
368 
369  template <typename Handle>
370  auto getKey( const Handle& h ) -> decltype( h.objKey() ) {
371  return h.objKey();
372  }
373 
375  // given a pack, return a corresponding tuple
376  template <typename... In>
378  using type = std::tuple<In...>;
379 
380  static_assert( !std::disjunction_v<std::is_same<EventContext, In>...>,
381  "EventContext can only appear as first argument" );
382 
383  template <typename Algorithm, typename Handles>
384  static auto apply( const Algorithm& algo, Handles& handles ) {
385  return std::apply(
386  [&]( const auto&... handle ) { return algo( get( handle, algo, Gaudi::Hive::currentContext() )... ); },
387  handles );
388  }
389  template <typename Algorithm, typename Handles>
390  static auto apply( const Algorithm& algo, const EventContext& ctx, Handles& handles ) {
391  return std::apply( [&]( const auto&... handle ) { return algo( get( handle, algo, ctx )... ); }, handles );
392  }
393  };
394 
395  // except when it starts with EventContext, then drop it
396  template <typename... In>
398  using type = std::tuple<In...>;
399 
400  static_assert( !std::disjunction_v<std::is_same<EventContext, In>...>,
401  "EventContext can only appear as first argument" );
402 
403  template <typename Algorithm, typename Handles>
404  static auto apply( const Algorithm& algo, const EventContext& ctx, Handles& handles ) {
405  return std::apply( [&]( const auto&... handle ) { return algo( ctx, get( handle, algo, ctx )... ); }, handles );
406  }
407 
408  template <typename Algorithm, typename Handles>
409  static auto apply( const Algorithm& algo, Handles& handles ) {
410  return apply( algo, Gaudi::Hive::currentContext(), handles );
411  }
412  };
413 
414  template <typename... In>
416 
417  template <typename OutputSpec, typename InputSpec, typename Traits_>
419 
420  template <typename Out, typename In, typename Tr>
422  const std::string& newLoc ) {
423  auto sc = parent.setProperty( prop, newLoc );
424  if ( sc.isFailure() ) throw GaudiException( "Could not set Property", prop + " -> " + newLoc, sc );
425  }
426 
427  template <typename Out, typename In, typename Tr>
429  const std::vector<std::string>& newLocs ) {
432  ss << '[', newLocs, ", ", []( std::ostream & os, const auto& i ) -> auto& { return os << "'" << i << "'"; } )
433  << ']';
434  auto sc = parent.setProperty( prop, ss.str() );
435  if ( sc.isFailure() ) throw GaudiException( "Could not set Property", prop + " -> " + ss.str(), sc );
436  }
437 
438  template <typename... Out, typename... In, typename Traits_>
439  class DataHandleMixin<std::tuple<Out...>, std::tuple<In...>, Traits_> : public BaseClass_t<Traits_> {
440  static_assert( std::is_base_of_v<Algorithm, BaseClass_t<Traits_>>, "BaseClass must inherit from Algorithm" );
441 
442  template <typename IArgs, typename OArgs, std::size_t... I, std::size_t... J>
443  DataHandleMixin( std::string name, ISvcLocator* pSvcLocator, const IArgs& inputs, std::index_sequence<I...>,
444  const OArgs& outputs, std::index_sequence<J...> )
445  : BaseClass_t<Traits_>( std::move( name ), pSvcLocator )
446  , m_inputs( std::tuple_cat( std::forward_as_tuple( this ), std::get<I>( inputs ) )... )
447  , m_outputs( std::tuple_cat( std::forward_as_tuple( this ), std::get<J>( outputs ) )... ) {
448  // make sure this algorithm is seen as reentrant by Gaudi
449  this->setProperty( "Cardinality", 0 ).ignore();
450  }
451 
452  public:
453  constexpr static std::size_t N_in = sizeof...( In );
454  constexpr static std::size_t N_out = sizeof...( Out );
455 
458 
459  // generic constructor: N -> M
461  const std::array<KeyValue, N_out>& outputs )
462  : DataHandleMixin( std::move( name ), pSvcLocator, inputs, std::index_sequence_for<In...>{}, outputs,
463  std::index_sequence_for<Out...>{} ) {}
464 
465  // special cases: forward to the generic case...
466  // 1 -> 1
468  : DataHandleMixin( std::move( name ), locator, std::array<KeyValue, 1>{input},
470  // 1 -> N
472  const std::array<KeyValue, N_out>& outputs )
473  : DataHandleMixin( std::move( name ), locator, std::array<KeyValue, 1>{input}, outputs ) {}
474  // N -> 1
476  const KeyValue& output )
477  : DataHandleMixin( std::move( name ), locator, inputs, std::array<KeyValue, 1>{output} ) {}
478 
479  template <std::size_t N = 0>
480  decltype( auto ) inputLocation() const {
481  return getKey( std::get<N>( m_inputs ) );
482  }
483  template <typename T>
484  decltype( auto ) inputLocation() const {
485  return getKey( std::get<details::InputHandle_t<Traits_, std::decay_t<T>>>( m_inputs ) );
486  }
487  constexpr unsigned int inputLocationSize() const { return N_in; }
488 
489  template <std::size_t N = 0>
490  decltype( auto ) outputLocation() const {
491  return getKey( std::get<N>( m_outputs ) );
492  }
493  template <typename T>
494  decltype( auto ) outputLocation() const {
495  return getKey( std::get<details::OutputHandle_t<Traits_, std::decay_t<T>>>( m_outputs ) );
496  }
497  constexpr unsigned int outputLocationSize() const { return N_out; }
498 
499  protected:
500  bool isReEntrant() const override { return true; }
501 
504  };
505 
506  template <typename Traits_>
507  class DataHandleMixin<std::tuple<>, std::tuple<>, Traits_> : public BaseClass_t<Traits_> {
508  static_assert( std::is_base_of_v<Algorithm, BaseClass_t<Traits_>>, "BaseClass must inherit from Algorithm" );
509 
510  public:
512  : BaseClass_t<Traits_>( std::move( name ), pSvcLocator ) {
513  // make sure this algorithm is seen as reentrant by Gaudi
514  this->setProperty( "Cardinality", 0 ).ignore();
515  }
516 
517  protected:
518  bool isReEntrant() const override { return true; }
519 
521  };
522 
523  template <typename... In, typename Traits_>
524  class DataHandleMixin<std::tuple<>, std::tuple<In...>, Traits_> : public BaseClass_t<Traits_> {
525  static_assert( std::is_base_of_v<Algorithm, BaseClass_t<Traits_>>, "BaseClass must inherit from Algorithm" );
526 
527  template <typename IArgs, std::size_t... I>
528  DataHandleMixin( std::string name, ISvcLocator* pSvcLocator, const IArgs& inputs, std::index_sequence<I...> )
529  : BaseClass_t<Traits_>( std::move( name ), pSvcLocator )
530  , m_inputs( std::tuple_cat( std::forward_as_tuple( this ), std::get<I>( inputs ) )... ) {
531  // make sure this algorithm is seen as reentrant by Gaudi
532  this->setProperty( "Cardinality", 0 ).ignore();
533  }
534 
535  public:
538  constexpr static std::size_t N_in = sizeof...( In );
539 
540  // generic constructor: N -> 0
542  : DataHandleMixin( std::move( name ), pSvcLocator, inputs, std::index_sequence_for<In...>{} ) {}
543 
544  // special cases: forward to the generic case...
545  // 1 -> 0
547  : DataHandleMixin( std::move( name ), locator, std::array<KeyValue, 1>{input} ) {}
548 
549  template <std::size_t N = 0>
550  decltype( auto ) inputLocation() const {
551  return getKey( std::get<N>( m_inputs ) );
552  }
553  template <typename T>
554  decltype( auto ) inputLocation() const {
555  return getKey( std::get<details::InputHandle_t<Traits_, std::decay_t<T>>>( m_inputs ) );
556  }
557  constexpr unsigned int inputLocationSize() const { return N_in; }
558 
559  protected:
560  bool isReEntrant() const override { return true; }
561 
563  };
564 
565  template <typename... Out, typename Traits_>
566  class DataHandleMixin<std::tuple<Out...>, std::tuple<>, Traits_> : public BaseClass_t<Traits_> {
567  static_assert( std::is_base_of_v<Algorithm, BaseClass_t<Traits_>>, "BaseClass must inherit from Algorithm" );
568 
569  template <typename OArgs, std::size_t... J>
570  DataHandleMixin( std::string name, ISvcLocator* pSvcLocator, const OArgs& outputs, std::index_sequence<J...> )
571  : BaseClass_t<Traits_>( std::move( name ), pSvcLocator )
572  , m_outputs( std::tuple_cat( std::forward_as_tuple( this ), std::get<J>( outputs ) )... ) {
573  // make sure this algorithm is seen as reentrant by Gaudi
574  this->setProperty( "Cardinality", 0 ).ignore();
575  }
576 
577  public:
578  constexpr static std::size_t N_out = sizeof...( Out );
581 
582  // generic constructor: 0 -> N
584  : DataHandleMixin( std::move( name ), pSvcLocator, outputs, std::index_sequence_for<Out...>{} ) {}
585 
586  // 0 -> 1
588  : DataHandleMixin( std::move( name ), locator, std::array<KeyValue, 1>{output} ) {}
589 
590  template <std::size_t N = 0>
591  decltype( auto ) outputLocation() const {
592  return getKey( std::get<N>( m_outputs ) );
593  }
594  constexpr unsigned int outputLocationSize() const { return N_out; }
595 
596  protected:
597  bool isReEntrant() const override { return true; }
598 
600  };
601 
603  template <typename Fun, typename Container, typename... Args>
604  constexpr void applyPostProcessing( const Fun&, Container&, Args... ) {
605  static_assert( sizeof...( Args ) == 0, "Args should not be used!" );
606  }
607 
608  template <typename Fun, typename Container>
609  auto applyPostProcessing( const Fun& fun, Container& c ) -> decltype( fun.postprocess( c ), void() ) {
610  fun.postprocess( c );
611  }
612 
613 } // namespace Gaudi::Functional::details
614 
615 #endif
auto operator()(Container &c, Value &&v) const -> decltype(c.insert(v))
auto operator()(Container &c, Value &&v) const
bool check_sizes(const A &a, const B &b, const C &... c) noexcept
Compare sizes of 3 or more containers.
DataHandleMixin(std::string name, ISvcLocator *pSvcLocator, const std::array< KeyValue, N_in > &inputs, const std::array< KeyValue, N_out > &outputs)
DataHandleMixin(std::string name, ISvcLocator *pSvcLocator, const IArgs &inputs, std::index_sequence< I... >)
#define UNLIKELY(x)
Definition: Kernel.h:106
constexpr auto size(const T &, Args &&...) noexcept
auto applyPostProcessing(const Fun &fun, Container &c) -> decltype(fun.postprocess(c), void())
Gaudi::cpp17::detected_or_t< DataObjectWriteHandle< T >, detail2::OutputHandle_t, Tr, T > OutputHandle_t
void printSizes(OS &out, Arg &&arg, Args &&... args)
Print the parameters.
std::add_const_t< std::remove_pointer_t< Container > > val_t
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
decltype(bool{std::declval< T >()}, std::declval< T >().value()) is_optional_
std::enable_if_t< is_optional_v< Arg > > require_is_optional
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:308
Header file for class GaudiAlgorithm.
DataHandleMixin(std::string name, ISvcLocator *pSvcLocator, const std::array< KeyValue, N_out > &outputs)
T * put(std::unique_ptr< T > object) const
Register object in transient store.
static auto apply(const Algorithm &algo, Handles &handles)
void push_back(Container &c, const Value &v, std::false_type)
STL namespace.
DataHandleMixin(std::string name, ISvcLocator *pSvcLocator, const std::array< KeyValue, N_in > &inputs)
T end(T... args)
void put(const OutHandle &out_handle, OptOut &&out)
std::conditional_t< is_optional_v< T >, typename T::value_type, T > remove_optional_t
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
This class represents an entry point to all the event specific data.
Definition: EventContext.h:34
auto operator *(const std::chrono::duration< Rep1, Period > &lhs, const std::chrono::duration< Rep2, Period > &rhs)
Multiplication of two std::chrono::duration objects with same Period.
Definition: Counters.h:40
STL class.
typename Tr::template InputHandle< T > InputHandle_t
DataObjectHandle.h GaudiKernel/DataObjectHandle.h.
Definition: AlgTool.h:36
decltype(auto) verifySizes(Args &... args)
Verify the data container sizes have the same sizes.
decltype(auto) const_range(Args &&... args)
Zips multiple containers together to form a single const range.
typename filter_evtcontext_t< In... >::type filter_evtcontext
T & deref_if(T *const t, std::true_type)
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
Definition: Bootstrap.cpp:243
typename Tr::template OutputHandle< T > OutputHandle_t
GAUDI_API const EventContext & currentContext()
T str(T... args)
void updateHandleLocation(DataHandleMixin< Out, In, Tr > &parent, const std::string &prop, const std::string &newLoc)
std::enable_if_t<!is_optional_v< Arg > > require_is_not_optional
std::conditional_t< is_pointer, ptr_t, val_t > value_type
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Definition: SerializeSTL.h:47
friend bool operator==(const iterator &lhs, const iterator &rhs)
std::enable_if_t<!std::is_pointer_v< X >, ref_t > at(size_type i) const
DataHandleMixin(std::string name, ISvcLocator *locator, const KeyValue &input, const KeyValue &output)
static auto apply(const Algorithm &algo, const EventContext &ctx, Handles &handles)
Alias for backward compatibility.
Definition: Algorithm.h:58
T size(T... args)
DataHandleMixin(std::string name, ISvcLocator *pSvcLocator, const OArgs &outputs, std::index_sequence< J... >)
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
std::enable_if_t<!std::is_pointer_v< X >, ref_t > operator[](size_type i) const
std::enable_if_t< std::is_pointer_v< X >, ptr_t > at(size_type i) const
T begin(T... args)
T back_inserter(T... args)
std::enable_if_t< std::is_pointer_v< X >, ptr_t > operator[](size_type i) const
constexpr struct ranges::Gaudi::Functional::details::insert_t insert
void updateHandleLocations(DataHandleMixin< Out, In, Tr > &parent, const std::string &prop, const std::vector< std::string > &newLocs)
std::conditional_t< is_pointer, ptr_t, ref_t > ret_t
std::remove_pointer_t< typename Container::value_type > c_remove_ptr_t
DataHandleMixin(std::string name, ISvcLocator *locator, const std::array< KeyValue, N_in > &inputs, const KeyValue &output)
STL class.
auto operator()(Container &c, Value &&v) const -> decltype(c.push_back(v))
constexpr static const auto FAILURE
Definition: StatusCode.h:101
const Gaudi::Algorithm & parent
const In & operator()(const In &in) const
friend auto operator-(const iterator &lhs, const iterator &rhs)
Handles make_vector_of_handles(IDataHandleHolder *owner, const std::vector< std::string > &init)
T transform(T... args)
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
constexpr struct ranges::Gaudi::Functional::details::deref_t deref
DataHandleMixin(std::string name, ISvcLocator *locator, const KeyValue &input, const std::array< KeyValue, N_out > &outputs)
auto getKey(const Handle &h) -> decltype(h.objKey())
friend bool operator!=(const iterator &lhs, const iterator &rhs)
const In & operator()(const In *in) const
STL class.
constexpr struct ranges::Gaudi::Functional::details::invoke_optionally_t invoke_optionally
Gaudi::cpp17::detected_or_t< DataObjectReadHandle< T >, detail2::InputHandle_t, Tr, T > InputHandle_t
DataHandleMixin(std::string name, ISvcLocator *pSvcLocator, const IArgs &inputs, std::index_sequence< I... >, const OArgs &outputs, std::index_sequence< J... >)
static auto apply(const Algorithm &algo, const EventContext &ctx, Handles &handles)
T reserve(T... args)
Gaudi::cpp17::detected_or_t< GaudiAlgorithm, detail2::BaseClass_t, Tr > BaseClass_t