File indexing completed on 2025-01-18 09:10:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Navigation/INavigationPolicy.hpp"
0012
0013 namespace Acts {
0014
0015
0016 class MultiNavigationPolicyBase : public INavigationPolicy {};
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027 template <NavigationPolicyConcept... Policies>
0028 requires(sizeof...(Policies) > 0)
0029 class MultiNavigationPolicy final : public MultiNavigationPolicyBase {
0030 public:
0031
0032
0033 explicit MultiNavigationPolicy(Policies&&... policies)
0034 : m_policies{std::move(policies)...} {}
0035
0036
0037
0038
0039
0040 void connect(NavigationDelegate& delegate) const override {
0041 auto factory = add(DelegateChainBuilder{delegate},
0042 std::index_sequence_for<Policies...>{});
0043
0044 factory.store(delegate);
0045 }
0046
0047
0048
0049 const std::tuple<Policies...>& policies() const { return m_policies; }
0050
0051 private:
0052
0053 template <std::size_t... Is>
0054 constexpr auto add(
0055 auto factory,
0056 std::integer_sequence<std::size_t, Is...> ) const {
0057 return add<Is...>(factory);
0058 }
0059
0060
0061 template <std::size_t I, std::size_t... Is>
0062 constexpr auto add(auto factory) const {
0063 using policy_type = std::tuple_element_t<I, decltype(m_policies)>;
0064 auto* policy = &std::get<I>(m_policies);
0065
0066 auto added =
0067 factory.template add<&policy_type::initializeCandidates>(policy);
0068
0069 if constexpr (sizeof...(Is) > 0) {
0070 return add<Is...>(added);
0071 } else {
0072 return added;
0073 }
0074 }
0075
0076 std::tuple<Policies...> m_policies;
0077 };
0078 }