Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-06 08:10:12

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2021 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 http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Definitions/Algebra.hpp"
0012 #include "Acts/Utilities/Result.hpp"
0013 #include "Acts/Utilities/TypeTraits.hpp"
0014 
0015 namespace Acts {
0016 
0017 class Surface;
0018 
0019 namespace Concepts::SourceLinkAccessor {
0020 
0021 template <typename T>
0022 using container_t = typename T::Container;
0023 template <typename T>
0024 using key_t = typename T::Key;
0025 template <typename T>
0026 using value_t = typename T::Value;
0027 template <typename T>
0028 using iterator_t = typename T::Iterator;
0029 
0030 METHOD_TRAIT(count_t, count);
0031 METHOD_TRAIT(range_t, range);
0032 METHOD_TRAIT(at_t, at);
0033 
0034 // clang-format off
0035     template <typename S>
0036       struct SourceLinkAccessorConcept {
0037         constexpr static bool container_exists = exists<container_t, S>;
0038         static_assert(container_exists, "Container type not found");
0039         constexpr static bool key_exists = exists<key_t, S>;
0040         static_assert(key_exists, "Key type not found");
0041         constexpr static bool value_exists = exists<value_t, S>;
0042         static_assert(value_exists, "Value type not found");
0043         constexpr static bool iterator_exists = exists<iterator_t, S>;
0044         static_assert(iterator_exists, "Iterator type not found");
0045 
0046         constexpr static bool container_pointer_exists =
0047           std::is_same_v<std::decay_t<decltype(*(std::declval<S>().container))>, container_t<S>>;
0048         static_assert(container_pointer_exists, "Pointer to container not found");
0049 
0050         constexpr static bool count_exists = has_method<const S,
0051           std::size_t, count_t, const Surface&>;
0052         static_assert(count_exists, "count method not found");
0053         constexpr static bool range_exists = has_method<const S,
0054           std::pair<typename S::Iterator, typename S::Iterator>,
0055           range_t, const Surface&>;
0056         static_assert(range_exists, "range method not found");
0057         constexpr static bool at_exists = has_method<const S,
0058           const typename S::Value&, at_t, const typename S::Iterator&>;
0059         static_assert(at_exists, "at method not found");
0060 
0061         constexpr static bool value = require<container_exists,
0062                                               key_exists,
0063                                               value_exists,
0064                                               container_pointer_exists,
0065                                               iterator_exists,
0066                                               count_exists,
0067                                               range_exists,
0068                                               at_exists>;
0069       };
0070 // clang-format on
0071 }  // namespace Concepts::SourceLinkAccessor
0072 
0073 template <typename accessor>
0074 constexpr bool SourceLinkAccessorConcept =
0075     Acts::Concepts ::SourceLinkAccessor::SourceLinkAccessorConcept<
0076         accessor>::value;
0077 
0078 }  // namespace Acts