|
|
|||
File indexing completed on 2025-11-05 08:53:45
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 0013 namespace Acts { 0014 0015 /// Combined navigation policy that calls all contained other navigation 0016 /// policies. This class manages multiple navigation policies and executes 0017 /// them sequentially to populate the navigation stream with candidates. 0018 class MultiNavigationPolicy final : public INavigationPolicy { 0019 public: 0020 /// Constructor from multiple unique_ptr policies 0021 /// @tparam Policies The types of the navigation policies 0022 /// @param policies Unique pointers to navigation policies 0023 template <typename... Policies> 0024 explicit MultiNavigationPolicy(std::unique_ptr<Policies>... policies) 0025 : MultiNavigationPolicy{[](auto... args) { 0026 std::vector<std::unique_ptr<INavigationPolicy>> policyPtrs; 0027 0028 if constexpr (sizeof...(args) > 0) { 0029 auto fill = [&policyPtrs](auto& policy) { 0030 policyPtrs.push_back(std::move(policy)); 0031 }; 0032 0033 (fill(args), ...); 0034 } 0035 0036 return policyPtrs; 0037 }(std::move(policies)...)} {} 0038 0039 /// Constructor from a vector of navigation policies 0040 /// @param policies Vector of unique pointers to navigation policies 0041 explicit MultiNavigationPolicy( 0042 std::vector<std::unique_ptr<INavigationPolicy>>&& policies); 0043 0044 /// Connect this policy to a navigation delegate 0045 /// @param delegate The navigation delegate to connect to 0046 void connect(NavigationDelegate& delegate) const override; 0047 0048 /// Access the contained navigation policies 0049 /// @return Span of const unique pointers to the navigation policies 0050 std::span<const std::unique_ptr<INavigationPolicy>> policies() const; 0051 0052 /// Visit this policy first, and then all child policies one by one. 0053 /// @param visitor The function to call for each policy 0054 void visit(const std::function<void(const INavigationPolicy&)>& visitor) 0055 const override; 0056 0057 private: 0058 /// Initialize navigation candidates by calling all contained policies 0059 /// @param args The navigation arguments 0060 /// @param stream The navigation stream to populate 0061 /// @param logger Logger for debug output 0062 void initializeCandidates(const NavigationArguments& args, 0063 AppendOnlyNavigationStream& stream, 0064 const Logger& logger) const; 0065 0066 /// Vector of unique pointers to the contained navigation policies 0067 std::vector<std::unique_ptr<INavigationPolicy>> m_policyPtrs; 0068 0069 /// Vector of navigation delegates, one for each policy 0070 std::vector<NavigationDelegate> m_delegates; 0071 }; 0072 } // 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 |
|