Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:13:41

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           auto fill = [&policyPtrs](auto& policy) {
0028             policyPtrs.push_back(std::move(policy));
0029           };
0030 
0031           (fill(args), ...);
0032 
0033           return policyPtrs;
0034         }(std::move(policies)...)} {}
0035 
0036   /// Constructor from a vector of navigation policies
0037   /// @param policies Vector of unique pointers to navigation policies
0038   explicit MultiNavigationPolicy(
0039       std::vector<std::unique_ptr<INavigationPolicy>>&& policies);
0040 
0041   /// Connect this policy to a navigation delegate
0042   /// @param delegate The navigation delegate to connect to
0043   void connect(NavigationDelegate& delegate) const override;
0044 
0045   /// Access the contained navigation policies
0046   /// @return Span of const unique pointers to the navigation policies
0047   std::span<const std::unique_ptr<INavigationPolicy>> policies() const;
0048 
0049   /// Visit this policy first, and then all child policies one by one.
0050   /// @param visitor The function to call for each policy
0051   void visit(const std::function<void(const INavigationPolicy&)>& visitor)
0052       const override;
0053 
0054  private:
0055   /// Initialize navigation candidates by calling all contained policies
0056   /// @param args The navigation arguments
0057   /// @param stream The navigation stream to populate
0058   /// @param logger Logger for debug output
0059   void initializeCandidates(const NavigationArguments& args,
0060                             AppendOnlyNavigationStream& stream,
0061                             const Logger& logger) const;
0062 
0063   /// Vector of unique pointers to the contained navigation policies
0064   std::vector<std::unique_ptr<INavigationPolicy>> m_policyPtrs;
0065 
0066   /// Vector of navigation delegates, one for each policy
0067   std::vector<NavigationDelegate> m_delegates;
0068 };
0069 }  // namespace Acts