11
11
#include " detray/definitions/containers.hpp"
12
12
#include " detray/definitions/detail/qualifiers.hpp"
13
13
#include " detray/propagator/base_actor.hpp"
14
+ #include " detray/utils/tuple.hpp"
14
15
#include " detray/utils/tuple_helpers.hpp"
15
16
16
17
// System include(s)
@@ -32,11 +33,14 @@ class actor_chain {
32
33
33
34
public:
34
35
// / Types of the actors that are registered in the chain
35
- using actor_list_type = dtuple<actors_t ...>;
36
- // Tuple of actor states
37
- using state_tuple = dtuple<typename actors_t ::state...>;
38
- // Type of states tuple that is used in the propagator
39
- using state = dtuple<typename actors_t ::state &...>;
36
+ using actor_tuple = dtuple<actors_t ...>;
37
+
38
+ // Tuple of actor states (including states of observing actors, if present)
39
+ using state_tuple = detail::tuple_cat_t <detail::state_tuple_t <actors_t >...>;
40
+
41
+ // Tuple of state references that is used in the propagator
42
+ using state_ref_tuple =
43
+ detail::tuple_cat_t <detail::state_ref_tuple_t <actors_t >...>;
40
44
41
45
// / Call all actors in the chain.
42
46
// /
@@ -50,27 +54,26 @@ class actor_chain {
50
54
}
51
55
52
56
// / @returns the actor list
53
- DETRAY_HOST_DEVICE const actor_list_type &actors () const {
57
+ DETRAY_HOST_DEVICE constexpr const actor_tuple &actors () const {
54
58
return m_actors;
55
59
}
56
60
57
61
// / @returns a tuple of default constructible actor states
58
62
DETRAY_HOST_DEVICE
59
- static constexpr auto make_actor_states () {
63
+ static constexpr auto make_default_actor_states () {
60
64
// Only possible if each state is default initializable
61
- if constexpr ((std::default_initializable<typename actors_t ::state> &&
62
- ...)) {
63
- return dtuple<typename actors_t ::state...>{};
65
+ if constexpr (std::default_initializable<state_tuple>) {
66
+ return state_tuple{};
64
67
} else {
65
68
return std::nullopt;
66
69
}
67
70
}
68
71
69
72
// / @returns a tuple of reference for every state in the tuple @param t
70
- DETRAY_HOST_DEVICE static constexpr state setup_actor_states (
71
- dtuple< typename actors_t ::state...> &t) {
73
+ DETRAY_HOST_DEVICE static constexpr state_ref_tuple setup_actor_states (
74
+ state_tuple &t) {
72
75
return setup_actor_states (
73
- t, std::make_index_sequence<sizeof ...( actors_t ) >{});
76
+ t, std::make_index_sequence<detail::tuple_size_v<state_tuple> >{});
74
77
}
75
78
76
79
private:
@@ -99,7 +102,7 @@ class actor_chain {
99
102
100
103
// / Resolve the actor calls.
101
104
// /
102
- // / @param states states of all actors (only bare actors)
105
+ // / @param states states of all actors
103
106
// / @param p_state the state of the propagator (stepper and navigator)
104
107
template <typename actor_states_t , typename propagator_state_t ,
105
108
std::size_t ... indices>
@@ -111,22 +114,24 @@ class actor_chain {
111
114
112
115
// / @returns a tuple of reference for every state in the tuple @param t
113
116
template <std::size_t ... indices>
114
- DETRAY_HOST_DEVICE static constexpr state setup_actor_states (
115
- dtuple<typename actors_t ::state...> &t,
116
- std::index_sequence<indices...> /* ids*/ ) {
117
+ DETRAY_HOST_DEVICE static constexpr state_ref_tuple setup_actor_states (
118
+ state_tuple &t, std::index_sequence<indices...> /* ids*/ ) {
117
119
return detray::tie (detail::get<indices>(t)...);
118
120
}
119
121
120
122
// / Tuple of actors
121
- actor_list_type m_actors = {};
123
+ [[no_unique_address]] actor_tuple m_actors = {};
122
124
};
123
125
124
126
// / Empty actor chain (placeholder)
125
127
template <>
126
128
class actor_chain <> {
127
129
128
130
public:
131
+ using actor_tuple = dtuple<>;
129
132
using state_tuple = dtuple<>;
133
+ using state_ref_tuple = dtuple<>;
134
+
130
135
// / Empty states replaces a real actor states container
131
136
struct state {};
132
137
@@ -135,13 +140,13 @@ class actor_chain<> {
135
140
// / @param states the states of the actors.
136
141
// / @param p_state the propagation state.
137
142
template <typename actor_states_t , typename propagator_state_t >
138
- DETRAY_HOST_DEVICE void operator ()(actor_states_t & /* states */ ,
139
- propagator_state_t & /* p_state*/ ) const {
143
+ DETRAY_HOST_DEVICE constexpr void operator ()(
144
+ actor_states_t & /* states */ , propagator_state_t & /* p_state*/ ) const {
140
145
/* Do nothing*/
141
146
}
142
147
143
148
// / @returns an empty state
144
- DETRAY_HOST_DEVICE static constexpr state setup_actor_states (
149
+ DETRAY_HOST_DEVICE static constexpr state_ref_tuple setup_actor_states (
145
150
const state_tuple &) {
146
151
return {};
147
152
}
0 commit comments