1111#include " detray/definitions/containers.hpp"
1212#include " detray/definitions/detail/qualifiers.hpp"
1313#include " detray/propagator/base_actor.hpp"
14+ #include " detray/utils/tuple.hpp"
1415#include " detray/utils/tuple_helpers.hpp"
1516
1617// System include(s)
@@ -32,11 +33,14 @@ class actor_chain {
3233
3334 public:
3435 // / 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 >...>;
4044
4145 // / Call all actors in the chain.
4246 // /
@@ -50,27 +54,26 @@ class actor_chain {
5054 }
5155
5256 // / @returns the actor list
53- DETRAY_HOST_DEVICE const actor_list_type &actors () const {
57+ DETRAY_HOST_DEVICE constexpr const actor_tuple &actors () const {
5458 return m_actors;
5559 }
5660
5761 // / @returns a tuple of default constructible actor states
5862 DETRAY_HOST_DEVICE
59- static constexpr auto make_actor_states () {
63+ static constexpr auto make_default_actor_states () {
6064 // 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{};
6467 } else {
6568 return std::nullopt ;
6669 }
6770 }
6871
6972 // / @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) {
7275 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> >{});
7477 }
7578
7679 private:
@@ -99,7 +102,7 @@ class actor_chain {
99102
100103 // / Resolve the actor calls.
101104 // /
102- // / @param states states of all actors (only bare actors)
105+ // / @param states states of all actors
103106 // / @param p_state the state of the propagator (stepper and navigator)
104107 template <typename actor_states_t , typename propagator_state_t ,
105108 std::size_t ... indices>
@@ -111,14 +114,13 @@ class actor_chain {
111114
112115 // / @returns a tuple of reference for every state in the tuple @param t
113116 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*/ ) {
117119 return detray::tie (detail::get<indices>(t)...);
118120 }
119121
120122 // / Tuple of actors
121- actor_list_type m_actors = {};
123+ [[no_unique_address]] actor_tuple m_actors = {};
122124};
123125
124126// / Empty actor chain (placeholder)
@@ -127,6 +129,8 @@ class actor_chain<> {
127129
128130 public:
129131 using state_tuple = dtuple<>;
132+ using state_ref_tuple = dtuple<>;
133+
130134 // / Empty states replaces a real actor states container
131135 struct state {};
132136
@@ -141,7 +145,7 @@ class actor_chain<> {
141145 }
142146
143147 // / @returns an empty state
144- DETRAY_HOST_DEVICE static constexpr state setup_actor_states (
148+ DETRAY_HOST_DEVICE static constexpr state_ref_tuple setup_actor_states (
145149 const state_tuple &) {
146150 return {};
147151 }
0 commit comments