Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:27:44

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2016-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/Propagator/detail/abort_list_implementation.hpp"
0012 #include "Acts/Utilities/detail/Extendable.hpp"
0013 #include "Acts/Utilities/detail/MPL/has_duplicates.hpp"
0014 #include "Acts/Utilities/detail/MPL/type_collector.hpp"
0015 
0016 #include <boost/hana/type.hpp>
0017 #include <boost/hana/unpack.hpp>
0018 
0019 namespace hana = boost::hana;
0020 
0021 namespace Acts {
0022 
0023 /// @brief AbortList object to be used in the propagation
0024 ///
0025 /// The abort list is a list of structs or classes that
0026 /// is called at each propagation step and can trigger the abort
0027 /// of the current propagation.
0028 ///
0029 /// It can (optionally) depend on a result of an Actor from
0030 /// the actor list.
0031 template <typename... aborters_t>
0032 struct AbortList : public detail::Extendable<aborters_t...> {
0033  private:
0034   static_assert(!detail::has_duplicates_v<aborters_t...>,
0035                 "same aborter type specified several times");
0036 
0037   using detail::Extendable<aborters_t...>::tuple;
0038 
0039  public:
0040   /// @cond
0041   // This uses the type collector
0042   using result_type = typename decltype(hana::unpack(
0043       detail::type_collector_t<detail::action_type_extractor, aborters_t...>,
0044       hana::template_<AbortList>))::type;
0045   /// @endcond
0046 
0047   using detail::Extendable<aborters_t...>::get;
0048 
0049   /// Default constructor
0050   AbortList() = default;
0051 
0052   /// Default copy constructor
0053   ///
0054   /// @param aborters The source action list
0055   AbortList(const AbortList<aborters_t...>& aborters) = default;
0056 
0057   /// Default move constructor
0058   ///
0059   /// @param aborters The source action list
0060   AbortList(AbortList<aborters_t...>&& aborters) = default;
0061 
0062   /// Default move assignment operator
0063   ///
0064   /// @param aborters The source action list
0065   AbortList<aborters_t...>& operator=(
0066       const AbortList<aborters_t...>& aborters) = default;
0067 
0068   /// Default move assignment operator
0069   ///
0070   /// @param aborters The source action list
0071   AbortList<aborters_t...>& operator=(AbortList<aborters_t...>&& aborters) =
0072       default;
0073 
0074   /// Constructor from tuple
0075   ///
0076   /// @param aborters Source extensions tuple
0077   AbortList(const std::tuple<aborters_t...>& aborters)
0078       : detail::Extendable<aborters_t...>(aborters) {}
0079 
0080   /// Constructor from tuple move
0081   ///
0082   /// @param aborters Source extensions tuple
0083   AbortList(std::tuple<aborters_t...>&& aborters)
0084       : detail::Extendable<aborters_t...>(std::move(aborters)) {}
0085 
0086   /// Append new entries and return a new condition
0087   template <typename... appendices_t>
0088   AbortList<aborters_t..., appendices_t...> append(appendices_t... aps) const {
0089     auto catTuple =
0090         std::tuple_cat(tuple(), std::tuple<appendices_t...>(aps...));
0091     return AbortList<aborters_t..., appendices_t...>(std::move(catTuple));
0092   }
0093 
0094   /// This is the call signature for the abort list, it broadcasts the call
0095   /// to the tuple() members of the list
0096   ///
0097   /// @tparam propagator_state_t is the state type of the propagator
0098   /// @tparam stepper_t Type of the stepper
0099   /// @tparam navigator_t Type of the navigator
0100   ///
0101   /// @param [in,out] state is the state object from the propagator
0102   /// @param [in] stepper Stepper used for the propagation
0103   /// @param [in] navigator Navigator used for the propagation
0104   /// @param [in] args are the arguments to be passed to the aborters
0105   template <typename propagator_state_t, typename stepper_t,
0106             typename navigator_t, typename... Args>
0107   bool operator()(propagator_state_t& state, const stepper_t& stepper,
0108                   const navigator_t& navigator, Args&&... args) const {
0109     using impl = detail::abort_list_impl<aborters_t...>;
0110     return impl::check(tuple(), state, stepper, navigator,
0111                        std::forward<Args>(args)...);
0112   }
0113 };
0114 
0115 }  // namespace Acts