File indexing completed on 2025-01-18 09:27:55
0001
0002
0003
0004
0005
0006
0007
0008
0009 #pragma once
0010
0011 #include "Acts/Utilities/detail/MPL/all_of.hpp"
0012
0013 #include <tuple>
0014 #include <type_traits>
0015
0016 namespace Acts::detail {
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026 template <typename... extensions_t>
0027 struct Extendable {
0028
0029 static_assert(detail::all_of_v<std::is_default_constructible<extensions_t>::value...>,
0030 "all extensions must be default constructible");
0031 static_assert(detail::all_of_v<std::is_copy_constructible<extensions_t>::value...>,
0032 "all extensions must be copy constructible");
0033 static_assert(detail::all_of_v<std::is_move_constructible<extensions_t>::value...>,
0034 "all extensions must be move constructible");
0035
0036
0037
0038 Extendable() = default;
0039
0040
0041 Extendable(const Extendable<extensions_t...>& extendable) = default;
0042
0043
0044 Extendable(Extendable<extensions_t...>&& extendable) = default;
0045
0046
0047
0048
0049 Extendable(const std::tuple<extensions_t...>& extensions)
0050 : m_extensions(extensions) {}
0051
0052
0053
0054
0055 Extendable(std::tuple<extensions_t...>&& extensions)
0056 : m_extensions(std::move(extensions)) {}
0057
0058
0059
0060
0061 Extendable<extensions_t...>& operator=(
0062 const Extendable<extensions_t...>& extendable) = default;
0063
0064
0065
0066
0067 Extendable<extensions_t...>& operator=(
0068 Extendable<extensions_t...>&& extendable) = default;
0069
0070
0071
0072
0073
0074
0075 template <typename... appendices_t>
0076 Extendable<extensions_t..., appendices_t...> append(
0077 appendices_t... aps) const {
0078 auto catTuple =
0079 std::tuple_cat(m_extensions, std::tuple<appendices_t...>(aps...));
0080 return Extendable<extensions_t..., appendices_t...>(std::move(catTuple));
0081 }
0082
0083
0084
0085
0086 template <typename extension_t>
0087 const extension_t& get() const {
0088 return std::get<extension_t>(m_extensions);
0089 }
0090
0091
0092
0093
0094 template <typename extension_t>
0095 extension_t& get() {
0096 return std::get<extension_t>(m_extensions);
0097 }
0098
0099
0100
0101
0102 const std::tuple<extensions_t...>& tuple() const { return m_extensions; }
0103
0104
0105
0106
0107 std::tuple<extensions_t...>& tuple() { return m_extensions; }
0108
0109 private:
0110 std::tuple<extensions_t...> m_extensions;
0111 };
0112
0113 }