Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:42:12

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Propagator/detail/actor_list_implementation.hpp"
0012 #include "Acts/Utilities/TypeList.hpp"
0013 
0014 namespace Acts {
0015 /// @brief Extract the result type of an actor
0016 template <typename T>
0017 struct ActorResultTypeExtractor {
0018   /// Type alias for the result type of an actor
0019   using type = typename T::result_type;
0020 };
0021 
0022 /// @brief ActorList implementation to be used with the propagator
0023 ///
0024 /// This is the ActorList struct that is used in the propagator
0025 /// to define a list of different actors_t that are each
0026 /// executed during the stepping procedure
0027 template <typename... actors_t>
0028   requires((std::is_default_constructible_v<actors_t> && ...) &&
0029            (std::is_copy_constructible_v<actors_t> && ...) &&
0030            (std::is_move_constructible_v<actors_t> && ...) &&
0031            ((Types::count<actors_t, TypeList<actors_t...>>::value == 1) && ...))
0032 struct ActorList {
0033   /// @cond
0034   // This uses the type collector and unpacks using the `R` meta function
0035   // template <template <typename...> class R>
0036   template <template <typename...> class R>
0037   using result_type = typename Types::apply<
0038       R, typename Types::map<ActorResultTypeExtractor,
0039                              typename Types::filter<ActorHasResultStruct,
0040                                                     actors_t...>::type>::type>::
0041       type;
0042   /// @endcond
0043 
0044   /// Default constructor
0045   ActorList() = default;
0046 
0047   /// Default copy constructor
0048   ///
0049   /// @param actors The source action list
0050   ActorList(const ActorList<actors_t...>& actors) = default;
0051 
0052   /// Default move constructor
0053   ///
0054   /// @param actors The source action list
0055   ActorList(ActorList<actors_t...>&& actors) noexcept = default;
0056 
0057   /// Default move assignment operator
0058   ///
0059   /// @param actors The source action list
0060   /// @return Reference to this ActorList after copy assignment
0061   ActorList<actors_t...>& operator=(const ActorList<actors_t...>& actors) =
0062       default;
0063 
0064   /// Default move assignment operator
0065   ///
0066   /// @param actors The source action list
0067   /// @return Reference to this ActorList after move assignment
0068   ActorList<actors_t...>& operator=(ActorList<actors_t...>&& actors) noexcept =
0069       default;
0070 
0071   /// Constructor from tuple
0072   ///
0073   /// @param actors Source extensions tuple
0074   explicit ActorList(const std::tuple<actors_t...>& actors)
0075       : m_actors(actors) {}
0076 
0077   /// Constructor from tuple move
0078   ///
0079   /// @param actors Source extensions tuple
0080   explicit ActorList(std::tuple<actors_t...>&& actors)
0081       : m_actors(std::move(actors)) {}
0082 
0083   /// Const retrieval of an actor of a specific type
0084   ///
0085   /// @tparam actor_t Type of the Actor to be retrieved
0086   /// @return Const reference to the requested actor
0087   template <typename actor_t>
0088   const actor_t& get() const {
0089     return std::get<actor_t>(m_actors);
0090   }
0091 
0092   /// Non-const retrieval of an actor of a specific type
0093   ///
0094   /// @tparam actor_t Type of the Actor to be retrieved
0095   /// @return Reference to the requested actor
0096   template <typename actor_t>
0097   actor_t& get() {
0098     return std::get<actor_t>(m_actors);
0099   }
0100 
0101   /// Append new entries and return a new condition
0102   ///
0103   /// @tparam appendices_t Types of appended entries to the tuple
0104   ///
0105   /// @param aps The actors to be appended to the new ActorList
0106   ///
0107   /// @return A new ActorList with the appended actors
0108   template <typename... appendices_t>
0109   ActorList<actors_t..., appendices_t...> append(appendices_t... aps) const {
0110     auto catTuple =
0111         std::tuple_cat(m_actors, std::tuple<appendices_t...>(aps...));
0112     return ActorList<actors_t..., appendices_t...>(std::move(catTuple));
0113   }
0114 
0115   /// Act call which broadcasts the call to the tuple() members of the list
0116   ///
0117   /// @tparam propagator_state_t is the state type of the propagator
0118   /// @tparam stepper_t Type of the stepper used for the propagation
0119   /// @tparam navigator_t Type of the navigator used for the propagation
0120   ///
0121   /// @param [in,out] state This is the propagator state object
0122   /// @param [in] stepper The stepper in use
0123   /// @param [in] navigator The navigator in use
0124   /// @param [in] args The arguments to be passed to the actions
0125   template <typename propagator_state_t, typename stepper_t,
0126             typename navigator_t, typename... Args>
0127   void act(propagator_state_t& state, const stepper_t& stepper,
0128            const navigator_t& navigator, Args&&... args) const {
0129     using impl = detail::actor_list_impl<actors_t...>;
0130     impl::act(m_actors, state, stepper, navigator, std::forward<Args>(args)...);
0131   }
0132 
0133   /// Check call which broadcasts the call to the tuple() members of the list
0134   ///
0135   /// @tparam propagator_state_t is the state type of the propagator
0136   /// @tparam stepper_t Type of the stepper
0137   /// @tparam navigator_t Type of the navigator
0138   ///
0139   /// @param [in,out] state is the state object from the propagator
0140   /// @param [in] stepper Stepper used for the propagation
0141   /// @param [in] navigator Navigator used for the propagation
0142   /// @param [in] args are the arguments to be passed to the aborters
0143   /// @return True if propagation should be aborted, false otherwise
0144   template <typename propagator_state_t, typename stepper_t,
0145             typename navigator_t, typename... Args>
0146   bool checkAbort(propagator_state_t& state, const stepper_t& stepper,
0147                   const navigator_t& navigator, Args&&... args) const {
0148     using impl = detail::actor_list_impl<actors_t...>;
0149     return impl::checkAbort(m_actors, state, stepper, navigator,
0150                             std::forward<Args>(args)...);
0151   }
0152 
0153  private:
0154   std::tuple<actors_t...> m_actors;
0155 };
0156 
0157 }  // namespace Acts