Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SourceLinkAccessorConcept.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file SourceLinkAccessorConcept.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2021 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
14 
15 namespace Acts {
16 
17 class Surface;
18 
19 namespace Concepts {
20 namespace SourceLinkAccessor {
21 
22 template <typename T>
23 using container_t = typename T::Container;
24 template <typename T>
25 using key_t = typename T::Key;
26 template <typename T>
27 using value_t = typename T::Value;
28 template <typename T>
29 using iterator_t = typename T::Iterator;
30 
31 METHOD_TRAIT(count_t, count);
32 METHOD_TRAIT(range_t, range);
33 METHOD_TRAIT(at_t, at);
34 
35 // clang-format off
36  template <typename S>
38  constexpr static bool container_exists = exists<container_t, S>;
39  static_assert(container_exists, "Container type not found");
40  constexpr static bool key_exists = exists<key_t, S>;
41  static_assert(key_exists, "Key type not found");
42  constexpr static bool value_exists = exists<value_t, S>;
43  static_assert(value_exists, "Value type not found");
44  constexpr static bool iterator_exists = exists<iterator_t, S>;
45  static_assert(iterator_exists, "Iterator type not found");
46 
47  constexpr static bool container_pointer_exists =
48  std::is_same_v<std::decay_t<decltype(*(std::declval<S>().container))>, container_t<S>>;
49  static_assert(container_pointer_exists, "Pointer to container not found");
50 
51  constexpr static bool count_exists = has_method<const S,
52  size_t, count_t, const Surface&>;
53  static_assert(count_exists, "count method not found");
54  constexpr static bool range_exists = has_method<const S,
55  std::pair<typename S::Iterator, typename S::Iterator>,
56  range_t, const Surface&>;
57  static_assert(range_exists, "range method not found");
58  constexpr static bool at_exists = has_method<const S,
59  const typename S::Value&, at_t, const typename S::Iterator&>;
60  static_assert(at_exists, "at method not found");
61 
62  constexpr static bool value = require<container_exists,
63  key_exists,
69  at_exists>;
70  };
71 // clang-format on
72 } // namespace SourceLinkAccessor
73 } // namespace Concepts
74 
75 template <typename accessor>
76 constexpr bool SourceLinkAccessorConcept =
78  accessor>::value;
79 
80 } // namespace Acts