|
|
|||
File indexing completed on 2026-05-04 07:59:19
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/Navigation/INavigationPolicy.hpp" 0012 #include "Acts/Utilities/Zip.hpp" 0013 0014 namespace Acts { 0015 0016 /// Combined navigation policy that calls all contained other navigation 0017 /// policies. This class manages multiple navigation policies and executes 0018 /// them sequentially to populate the navigation stream with candidates. 0019 class MultiNavigationPolicy final : public INavigationPolicy { 0020 public: 0021 /// Constructor from multiple unique_ptr policies 0022 /// @tparam Policies The types of the navigation policies 0023 /// @param policies Unique pointers to navigation policies 0024 template <typename... Policies> 0025 explicit MultiNavigationPolicy(std::unique_ptr<Policies>... policies) 0026 : MultiNavigationPolicy{[](auto... args) { 0027 std::vector<std::unique_ptr<INavigationPolicy>> policyPtrs; 0028 0029 if constexpr (sizeof...(args) > 0) { 0030 auto fill = [&policyPtrs](auto& policy) { 0031 policyPtrs.push_back(std::move(policy)); 0032 }; 0033 0034 (fill(args), ...); 0035 } 0036 0037 return policyPtrs; 0038 }(std::move(policies)...)} {} 0039 0040 /// Constructor from a vector of navigation policies 0041 /// @param policies Vector of unique pointers to navigation policies 0042 explicit MultiNavigationPolicy( 0043 std::vector<std::unique_ptr<INavigationPolicy>>&& policies); 0044 0045 /// Connect this policy to a navigation delegate 0046 /// @param delegate The navigation delegate to connect to 0047 void connect(NavigationDelegate& delegate) const override; 0048 0049 /// Access the contained navigation policies 0050 /// @return Span of const unique pointers to the navigation policies 0051 std::span<const std::unique_ptr<INavigationPolicy>> policies() const; 0052 0053 /// Visit this policy first, and then all child policies one by one. 0054 /// @param visitor The function to call for each policy 0055 void visit(const std::function<void(const INavigationPolicy&)>& visitor) 0056 const override; 0057 0058 /// State structure for MultiNavigationPolicy 0059 /// Holds the states for all contained child policies 0060 struct State { 0061 /// Vector of navigation policy states, one for each child policy 0062 std::vector<NavigationPolicyState> policyStates; 0063 }; 0064 0065 /// Check if all child policies are in a valid state 0066 /// @param gctx The geometry context 0067 /// @param args The navigation arguments 0068 /// @param state The navigation policy state to check 0069 /// @param logger Logger for debug output 0070 /// @return True if all child policy states are valid, false otherwise 0071 bool isValid(const GeometryContext& gctx, const NavigationArguments& args, 0072 NavigationPolicyState& state, 0073 const Logger& logger) const override; 0074 0075 /// Create and initialize states for this policy and all child policies 0076 /// @param gctx The geometry context 0077 /// @param args The navigation arguments 0078 /// @param stateManager The state manager to push the new states onto 0079 /// @param logger Logger for debug output 0080 void createState(const GeometryContext& gctx, const NavigationArguments& args, 0081 NavigationPolicyStateManager& stateManager, 0082 const Logger& logger) const override; 0083 0084 /// Remove the states for this policy and all child policies from the state 0085 /// manager 0086 /// @param stateManager The state manager to pop the states from 0087 /// @param logger Logger for debug output 0088 void popState(NavigationPolicyStateManager& stateManager, 0089 const Logger& logger) const override; 0090 0091 private: 0092 /// Initialize navigation candidates by calling all contained policies 0093 /// @param gctx The geometry context 0094 /// @param args The navigation arguments 0095 /// @param state The navigation policy state 0096 /// @param stream The navigation stream to populate 0097 /// @param logger Logger for debug output 0098 void initializeCandidates(const GeometryContext& gctx, 0099 const NavigationArguments& args, 0100 NavigationPolicyState& state, 0101 AppendOnlyNavigationStream& stream, 0102 const Logger& logger) const; 0103 0104 /// Vector of unique pointers to the contained navigation policies 0105 std::vector<std::unique_ptr<INavigationPolicy>> m_policyPtrs; 0106 0107 /// Vector of navigation delegates, one for each policy 0108 std::vector<NavigationDelegate> m_delegates; 0109 }; 0110 } // namespace Acts
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|