@@ -56,32 +56,38 @@ struct aggregate_inspector {
56
56
57
57
// / Inspector interface
58
58
template <unsigned int current_id = 0 , typename state_type,
59
- concepts::point3D point3_t , concepts::vector3D vector3_t >
59
+ concepts::point3D point3_t , concepts::vector3D vector3_t ,
60
+ typename ... Args>
60
61
DETRAY_HOST_DEVICE auto operator ()(state_type &state,
61
62
const navigation::config &cfg,
62
63
const point3_t &pos,
63
64
const vector3_t &dir,
64
- const char *message) {
65
+ const char *message, Args &&... args ) {
65
66
// Call inspector
66
- std::get<current_id>(_inspectors)(state, cfg, pos, dir, message);
67
+ std::get<current_id>(_inspectors)(state, cfg, pos, dir, message,
68
+ std::forward<Args>(args)...);
67
69
68
70
// Next inspector
69
71
if constexpr (current_id <
70
72
std::tuple_size<inspector_tuple_t >::value - 1 ) {
71
- return operator ()<current_id + 1 >(state, cfg, pos, dir, message);
73
+ return operator ()<current_id + 1 >(state, cfg, pos, dir, message,
74
+ std::forward<Args>(args)...);
72
75
}
73
76
}
74
77
75
78
// / Inspector interface
76
- template <unsigned int current_id = 0 , typename state_type>
77
- DETRAY_HOST_DEVICE auto operator ()(state_type &state, const char *message) {
79
+ template <unsigned int current_id = 0 , typename state_type,
80
+ typename ... Args>
81
+ DETRAY_HOST_DEVICE auto operator ()(state_type &state, const char *message,
82
+ Args &&... args) {
78
83
// Call inspector
79
84
std::get<current_id>(_inspectors)(state, message);
80
85
81
86
// Next inspector
82
87
if constexpr (current_id <
83
88
std::tuple_size<inspector_tuple_t >::value - 1 ) {
84
- return operator ()<current_id + 1 >(state, message);
89
+ return operator ()<current_id + 1 >(state, message,
90
+ std::forward<Args>(args)...);
85
91
}
86
92
}
87
93
@@ -191,12 +197,12 @@ struct object_tracer {
191
197
192
198
// / Inspector interface
193
199
template <typename state_type, concepts::point3D point3_t ,
194
- concepts::vector3D vector3_t >
200
+ concepts::vector3D vector3_t , typename ... Args >
195
201
DETRAY_HOST_DEVICE auto operator ()(const state_type &state,
196
202
const navigation::config &,
197
203
const point3_t &pos,
198
204
const vector3_t &dir,
199
- const char * /* message*/ ) {
205
+ const char * /* message*/ , Args &&... ) {
200
206
201
207
// Record the candidate of an encountered object
202
208
if ((is_status (state.status (), navigation_status) || ...)) {
@@ -245,6 +251,8 @@ struct print_inspector {
245
251
using view_type = dvector_view<char >;
246
252
using const_view_type = dvector_view<const char >;
247
253
254
+ struct void_generator {};
255
+
248
256
// / Default constructor
249
257
print_inspector () = default ;
250
258
@@ -272,17 +280,24 @@ struct print_inspector {
272
280
// / Move assignemten operator
273
281
print_inspector &operator =(print_inspector &&other) = default ;
274
282
275
- // / Gathers navigation information accross navigator update calls
276
- std::stringstream debug_stream{};
277
-
278
283
// / Inspector interface. Gathers detailed information during navigation
279
284
template <typename state_type, concepts::point3D point3_t ,
280
- concepts::vector3D vector3_t >
285
+ concepts::vector3D vector3_t ,
286
+ typename message_generator_t = void_generator>
281
287
auto operator ()(const state_type &state, const navigation::config &cfg,
282
288
const point3_t &track_pos, const vector3_t &track_dir,
283
- const char *message) {
289
+ const char *message,
290
+ const message_generator_t &msg_gen = {}) {
284
291
std::string msg (message);
285
- debug_stream << msg << std::endl;
292
+ debug_stream << msg;
293
+ if constexpr (!std::same_as<message_generator_t , void_generator>) {
294
+ debug_stream << msg_gen ();
295
+
296
+ if (state.status () == navigation::status::e_abort) {
297
+ fata_error_msg = msg_gen ();
298
+ }
299
+ }
300
+ debug_stream << std::endl;
286
301
debug_stream << " ----------------------------------------" << std::endl;
287
302
288
303
debug_stream << navigation::print_state (state);
@@ -293,10 +308,20 @@ struct print_inspector {
293
308
}
294
309
295
310
// / Inspector interface. Print basic state information
296
- template <typename state_type>
297
- auto operator ()(const state_type &state, const char *message) {
311
+ template <typename state_type,
312
+ typename message_generator_t = void_generator>
313
+ auto operator ()(const state_type &state, const char *message,
314
+ const message_generator_t &msg_gen = {}) {
298
315
std::string msg (message);
299
- debug_stream << msg << std::endl;
316
+ debug_stream << msg;
317
+ if constexpr (!std::same_as<message_generator_t , void_generator>) {
318
+ debug_stream << msg_gen ();
319
+
320
+ if (state.status () == navigation::status::e_abort) {
321
+ fata_error_msg = msg_gen ();
322
+ }
323
+ }
324
+ debug_stream << std::endl;
300
325
debug_stream << " ----------------------------------------" << std::endl;
301
326
302
327
debug_stream << navigation::print_state (state);
@@ -306,6 +331,11 @@ struct print_inspector {
306
331
307
332
// / @returns a string representation of the gathered information
308
333
std::string to_string () const { return debug_stream.str (); }
334
+
335
+ // / Gathers navigation information accross navigator update calls
336
+ std::stringstream debug_stream{};
337
+ // / Special message that is collected if the navigator hits a fatal error
338
+ std::string fata_error_msg{" " };
309
339
};
310
340
311
341
} // namespace navigation
0 commit comments