forked from sPHENIX-Collaboration/acts
/
full_parameter_set.hpp
66 lines (52 loc) · 2 KB
/
full_parameter_set.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// This file is part of the Acts project.
//
// Copyright (C) 2016-2020 CERN for the benefit of the Acts project
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#pragma once
#include "Acts/EventData/detail/ParameterTraits.hpp"
#include <type_traits>
#include <utility>
namespace Acts {
// forward declaration
template <typename parameter_indices_t, parameter_indices_t... params>
class ParameterSet;
namespace detail {
/// @brief generate ParameterSet type containing all defined parameters
///
/// @return full_parset<Policy>::type is equivalent to
/// `ParameterSet<Policy,ID_t(0),ID_t(1),...,ID_t(N-1)>` where @c ID_t
/// is a @c typedef to `Policy::par_id_type` and @c N is the total
/// number of parameters
template <typename parameter_indices_t>
struct full_parset {
template <parameter_indices_t v, typename C>
struct add_to_value_container;
template <parameter_indices_t v, parameter_indices_t... others>
struct add_to_value_container<
v, std::integer_sequence<parameter_indices_t, others...>> {
using type = std::integer_sequence<parameter_indices_t, others..., v>;
};
template <typename T, unsigned int N>
struct tparam_generator {
using type = typename add_to_value_container<
static_cast<T>(N), typename tparam_generator<T, N - 1>::type>::type;
};
template <typename T>
struct tparam_generator<T, 0> {
using type = std::integer_sequence<T, static_cast<T>(0)>;
};
template <typename T>
struct converter;
template <parameter_indices_t... values>
struct converter<std::integer_sequence<parameter_indices_t, values...>> {
using type = ParameterSet<parameter_indices_t, values...>;
};
using type = typename converter<typename tparam_generator<
parameter_indices_t,
kParametersSize<parameter_indices_t> - 1>::type>::type;
};
} // namespace detail
} // namespace Acts