Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-27 07:23:57

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 // Project include(s)
0012 #include "detray/core/detail/compact_device_vector.hpp"
0013 #include "detray/definitions/detail/qualifiers.hpp"
0014 #include "detray/utils/tuple.hpp"
0015 
0016 // Vecmem include(s)
0017 #include <vecmem/containers/jagged_vector.hpp>
0018 #include <vecmem/containers/vector.hpp>
0019 
0020 // System include(s)
0021 #include <map>
0022 #include <type_traits>
0023 #include <vector>
0024 
0025 namespace detray {
0026 
0027 template <typename value_t, std::size_t kDIM>
0028 using darray = std::array<value_t, kDIM>;
0029 
0030 template <typename value_t>
0031 using dvector = vecmem::vector<value_t>;
0032 
0033 template <typename value_t>
0034 using djagged_vector = vecmem::jagged_vector<value_t>;
0035 
0036 template <typename key_t, typename value_t>
0037 using dmap = std::map<key_t, value_t>;
0038 
0039 template <class... types>
0040 using dtuple = detray::tuple<types...>;
0041 
0042 /// @brief Bundle container type definitions
0043 template <template <typename...> class vector_t = dvector,
0044           template <typename...> class jagged_vector_t = djagged_vector,
0045           template <typename, typename> class map_t = dmap>
0046 struct container_types {
0047   template <typename T>
0048   using vector_type = vector_t<T>;
0049 
0050   template <class... T>
0051   using tuple_type = dtuple<T...>;
0052 
0053   template <typename T, std::size_t kDIM>
0054   using array_type = darray<T, kDIM>;
0055 
0056   template <typename T>
0057   using jagged_vector_type = jagged_vector_t<T>;
0058 
0059   template <typename K, typename T>
0060   using map_type = map_t<K, T>;
0061 };
0062 
0063 /// Defining some common types
0064 using host_container_types = container_types<>;
0065 
0066 namespace detail {
0067 
0068 // make std::get available in detray detail namespace, where also the thrust and
0069 // index specific overloads live.
0070 using std::get;
0071 
0072 /// Trait class to figure out if a given type has a @c reserve(...) function
0073 template <typename T>
0074 struct has_reserve {
0075  private:
0076   /// Function returning @c std::true_type for types that do have a @c
0077   /// reserve(...) function
0078   template <typename C>
0079   static constexpr auto check(C*) ->
0080       typename std::is_void<decltype(std::declval<C>().reserve(
0081           std::declval<typename C::size_type>()))>::type;
0082 
0083   /// Function returning @c std::false_type for types that fair the previous
0084   /// function
0085   template <typename>
0086   static constexpr std::false_type check(...);
0087 
0088   /// Declare the value type of this trait class
0089   using type = decltype(check<T>(nullptr));
0090 
0091  public:
0092   /// Value of the check
0093   static constexpr bool value = type::value;
0094 };
0095 
0096 /// @name Functions calling or not calling reserve(...) based on whether it's
0097 /// available
0098 /// @{
0099 template <typename T>
0100   requires has_reserve<T>::value
0101 DETRAY_HOST_DEVICE void call_reserve(T& obj, std::size_t newsize) {
0102   obj.reserve(newsize);
0103 }
0104 
0105 template <typename T>
0106   requires(!has_reserve<T>::value)
0107 DETRAY_HOST_DEVICE void call_reserve(T& /*obj*/, std::size_t /*newsize*/) {
0108   /*Not defined*/
0109 }
0110 /// @}
0111 
0112 }  // namespace detail
0113 
0114 }  // namespace detray