Analysis Software
Documentation for sPHENIX simulation 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
10 
12 
13 #include <utility>
14 
15 namespace Acts {
16 namespace detail {
17 
18 namespace {
19 
23 template <bool has_result = true>
24 struct action_caller {
25  template <typename actor_t, typename result_t, typename propagator_state_t,
26  typename stepper_t, typename navigator_t, typename... Args>
27  static void action(const actor_t& act, propagator_state_t& state,
28  const stepper_t& stepper, const navigator_t& navigator,
29  result_t& result, Args&&... args) {
30  act(state, stepper, navigator,
31  result.template get<detail::result_type_t<actor_t>>(),
32  std::forward<Args>(args)...);
33  }
34 };
35 
37 template <>
38 struct action_caller<false> {
39  template <typename actor_t, typename result_t, typename propagator_state_t,
40  typename stepper_t, typename navigator_t, typename... Args>
41  static void action(const actor_t& act, propagator_state_t& state,
42  const stepper_t& stepper, const navigator_t& navigator,
43  result_t& /*result*/, Args&&... args) {
44  act(state, stepper, navigator, std::forward<Args>(args)...);
45  }
46 };
47 } // end of anonymous namespace
48 
50 template <typename... actors>
52 
56 template <typename first, typename... others>
57 struct action_list_impl<first, others...> {
58  template <typename T, typename propagator_state_t, typename stepper_t,
59  typename navigator_t, typename result_t, typename... Args>
60  static void action(const T& actors_tuple, propagator_state_t& state,
61  const stepper_t& stepper, const navigator_t& navigator,
62  result_t& result, Args&&... args) {
63  constexpr bool has_result = has_result_type_v<first>;
64  const auto& this_actor = std::get<first>(actors_tuple);
65  action_caller<has_result>::action(this_actor, state, stepper, navigator,
66  result, args...);
67  action_list_impl<others...>::action(actors_tuple, state, stepper, navigator,
68  result, args...);
69  }
70 };
71 
74 template <typename last>
75 struct action_list_impl<last> {
76  template <typename T, typename propagator_state_t, typename stepper_t,
77  typename navigator_t, typename result_t, typename... Args>
78  static void action(const T& actors_tuple, propagator_state_t& state,
79  const stepper_t& stepper, const navigator_t& navigator,
80  result_t& result, Args&&... args) {
81  constexpr bool has_result = has_result_type_v<last>;
82  const auto& this_actor = std::get<last>(actors_tuple);
83  action_caller<has_result>::action(this_actor, state, stepper, navigator,
84  result, std::forward<Args>(args)...);
85  }
86 };
87 
89 template <>
90 struct action_list_impl<> {
91  template <typename T, typename propagator_state_t, typename stepper_t,
92  typename navigator_t, typename result_t, typename... Args>
93  static void action(const T& /*actors_tuple*/, propagator_state_t& /*state*/,
94  const stepper_t& /*stepper*/,
95  const navigator_t& /*navigator*/, result_t& /*result*/,
96  Args&&... /*args*/) {}
97 };
98 
99 } // namespace detail
100 } // namespace Acts