File indexing completed on 2025-01-18 09:10:48
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Geometry/GeometryIdentifier.hpp"
0012 #include "Acts/Utilities/Any.hpp"
0013 #include "Acts/Utilities/Delegate.hpp"
0014
0015 #include <cassert>
0016 #include <concepts>
0017 #include <type_traits>
0018 #include <utility>
0019
0020 #if !defined(ACTS_SOURCELINK_SBO_SIZE)
0021
0022 #define ACTS_SOURCELINK_SBO_SIZE 16
0023 #endif
0024
0025 namespace Acts {
0026
0027 class SourceLink final {
0028 using any_type = AnyBase<ACTS_SOURCELINK_SBO_SIZE>;
0029
0030 public:
0031 SourceLink(const SourceLink& other) = default;
0032 SourceLink(SourceLink&& other) = default;
0033 SourceLink& operator=(const SourceLink& other) = default;
0034 SourceLink& operator=(SourceLink&& other) = default;
0035
0036
0037
0038
0039 template <typename T>
0040 explicit SourceLink(T&& upstream)
0041 requires(!std::same_as<std::decay_t<T>, SourceLink>)
0042 : m_upstream(std::forward<T>(upstream)) {
0043 static_assert(!std::is_same_v<std::decay_t<T>, SourceLink>,
0044 "Cannot wrap SourceLink in SourceLink");
0045 }
0046
0047
0048
0049
0050 template <typename T>
0051 T& get() {
0052 return m_upstream.as<T>();
0053 }
0054
0055
0056
0057
0058 template <typename T>
0059 const T& get() const {
0060 return m_upstream.as<T>();
0061 }
0062
0063 private:
0064 any_type m_upstream{};
0065 };
0066
0067 template <typename T>
0068 struct SourceLinkAdapterIterator {
0069 using BaseIterator = T;
0070
0071 using iterator_category = typename BaseIterator::iterator_category;
0072 using value_type = typename BaseIterator::value_type;
0073 using difference_type = typename BaseIterator::difference_type;
0074 using pointer = typename BaseIterator::pointer;
0075 using reference = typename BaseIterator::reference;
0076
0077 explicit SourceLinkAdapterIterator(T iterator) : m_iterator{iterator} {}
0078
0079 SourceLinkAdapterIterator& operator++() {
0080 ++m_iterator;
0081 return *this;
0082 }
0083
0084 bool operator==(const SourceLinkAdapterIterator& other) const {
0085 return m_iterator == other.m_iterator;
0086 }
0087
0088 Acts::SourceLink operator*() const { return Acts::SourceLink{*m_iterator}; }
0089
0090 auto operator-(const SourceLinkAdapterIterator& other) const {
0091 return m_iterator - other.m_iterator;
0092 }
0093
0094 BaseIterator m_iterator;
0095 };
0096
0097
0098 using SourceLinkSurfaceAccessor = Delegate<const Surface*(const SourceLink&)>;
0099
0100 }