Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Acts/Propagator/detail/action_list_implementation.hpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2018 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Utilities/detail/MPL/type_collector.hpp"
0012 
0013 #include <utility>
0014 
0015 namespace Acts::detail {
0016 
0017 namespace {
0018 
0019 /// The action caller struct, it's called with the the right result object,
0020 /// which is taken out from the result tuple
0021 template <bool has_result = true>
0022 struct action_caller {
0023   template <typename actor_t, typename propagator_state_t, typename stepper_t,
0024             typename navigator_t, typename... Args>
0025   static void action(const actor_t& act, propagator_state_t& state,
0026                      const stepper_t& stepper, const navigator_t& navigator,
0027                      Args&&... args) {
0028     act(state, stepper, navigator,
0029         state.template get<detail::result_type_t<actor_t>>(),
0030         std::forward<Args>(args)...);
0031   }
0032 };
0033 
0034 /// The action caller struct, without result object
0035 template <>
0036 struct action_caller<false> {
0037   template <typename actor_t, typename propagator_state_t, typename stepper_t,
0038             typename navigator_t, typename... Args>
0039   static void action(const actor_t& act, propagator_state_t& state,
0040                      const stepper_t& stepper, const navigator_t& navigator,
0041                      Args&&... args) {
0042     act(state, stepper, navigator, std::forward<Args>(args)...);
0043   }
0044 };
0045 }  // end of anonymous namespace
0046 
0047 /// The dummy list call implementation
0048 template <typename... actors>
0049 struct action_list_impl;
0050 
0051 /// The action list call implementation
0052 /// - it calls 'action' on the current entry of the tuple
0053 /// - then broadcasts the action call to the remaining tuple
0054 template <typename first, typename... others>
0055 struct action_list_impl<first, others...> {
0056   template <typename T, typename propagator_state_t, typename stepper_t,
0057             typename navigator_t, typename... Args>
0058   static void action(const T& actors_tuple, propagator_state_t& state,
0059                      const stepper_t& stepper, const navigator_t& navigator,
0060                      Args&&... args) {
0061     constexpr bool has_result = has_result_type_v<first>;
0062     const auto& this_actor = std::get<first>(actors_tuple);
0063     action_caller<has_result>::action(this_actor, state, stepper, navigator,
0064                                       args...);
0065     action_list_impl<others...>::action(actors_tuple, state, stepper, navigator,
0066                                         args...);
0067   }
0068 };
0069 
0070 /// The action list call implementation
0071 /// - it calls 'action' on the last entry of the tuple
0072 template <typename last>
0073 struct action_list_impl<last> {
0074   template <typename T, typename propagator_state_t, typename stepper_t,
0075             typename navigator_t, typename... Args>
0076   static void action(const T& actors_tuple, propagator_state_t& state,
0077                      const stepper_t& stepper, const navigator_t& navigator,
0078                      Args&&... args) {
0079     constexpr bool has_result = has_result_type_v<last>;
0080     const auto& this_actor = std::get<last>(actors_tuple);
0081     action_caller<has_result>::action(this_actor, state, stepper, navigator,
0082                                       std::forward<Args>(args)...);
0083   }
0084 };
0085 
0086 /// The empty action list call implementation
0087 template <>
0088 struct action_list_impl<> {
0089   template <typename T, typename propagator_state_t, typename stepper_t,
0090             typename navigator_t, typename... Args>
0091   static void action(const T& /*actors_tuple*/, propagator_state_t& /*state*/,
0092                      const stepper_t& /*stepper*/,
0093                      const navigator_t& /*navigator*/, Args&&... /*args*/) {}
0094 };
0095 
0096 }  // namespace Acts::detail