Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-23 08:06:56

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