ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
action_list_implementation.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file action_list_implementation.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
11 
12 namespace Acts {
13 
14 namespace detail {
15 
16 namespace {
17 
21 template <bool has_result = true>
22 struct action_caller {
23  template <typename actor, typename result_t, typename propagator_state_t,
24  typename stepper_t>
25  static void action(const actor& act, propagator_state_t& state,
26  const stepper_t& stepper, result_t& result) {
27  act(state, stepper, result.template get<detail::result_type_t<actor>>());
28  }
29 };
30 
32 template <>
33 struct action_caller<false> {
34  template <typename actor, typename result_t, typename propagator_state_t,
35  typename stepper_t>
36  static void action(const actor& act, propagator_state_t& state,
37  const stepper_t& stepper, result_t& /*unused*/) {
38  act(state, stepper);
39  }
40 };
41 } // end of anonymous namespace
42 
44 template <typename... actors>
46 
50 template <typename first, typename... others>
51 struct action_list_impl<first, others...> {
52  template <typename T, typename result_t, typename propagator_state_t,
53  typename stepper_t>
54  static void action(const T& obs_tuple, propagator_state_t& state,
55  const stepper_t& stepper, result_t& result) {
56  constexpr bool has_result = has_result_type_v<first>;
57  const auto& this_action = std::get<first>(obs_tuple);
58  action_caller<has_result>::action(this_action, state, stepper, result);
59  action_list_impl<others...>::action(obs_tuple, state, stepper, result);
60  }
61 };
62 
65 template <typename last>
66 struct action_list_impl<last> {
67  template <typename T, typename result_t, typename propagator_state_t,
68  typename stepper_t>
69  static void action(const T& obs_tuple, propagator_state_t& state,
70  const stepper_t& stepper, result_t& result) {
71  constexpr bool has_result = has_result_type_v<last>;
72  const auto& this_action = std::get<last>(obs_tuple);
73  action_caller<has_result>::action(this_action, state, stepper, result);
74  }
75 };
76 
78 template <>
79 struct action_list_impl<> {
80  template <typename T, typename result_t, typename propagator_state_t,
81  typename stepper_t>
82  static void action(const T& /*unused*/, propagator_state_t& /*unused*/,
83  const stepper_t& /*unused*/, result_t& /*unused*/) {}
84 };
85 
86 } // namespace detail
87 } // namespace Acts