Skip to content

Commit

Permalink
refactor the inspector calls (#501)
Browse files Browse the repository at this point in the history
Removes the if constexpr code from the navigator and puts it into the run_inspector method of the navigation state
  • Loading branch information
niermann999 authored Jun 27, 2023
1 parent 0ac71c8 commit 6d62da7
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions core/include/detray/propagator/navigator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,11 @@ class navigator {

/// Call the navigation inspector
DETRAY_HOST_DEVICE
inline void run_inspector(const char *message) {
_inspector(*this, message);
inline void run_inspector([[maybe_unused]] const char *message) {
if constexpr (not std::is_same_v<inspector_t,
navigation::void_inspector>) {
_inspector(*this, message);
}
}

/// Helper method to set common state values during naviagtion
Expand Down Expand Up @@ -529,12 +532,7 @@ class navigator {
if (navigation.trust_level() != navigation::trust_level::e_full) {
navigation._heartbeat = false;
}

// Run inspection when needed
if constexpr (not std::is_same_v<inspector_t,
navigation::void_inspector>) {
navigation.run_inspector("Init complete: ");
}
navigation.run_inspector("Init complete: ");

return navigation._heartbeat;
}
Expand Down Expand Up @@ -576,10 +574,7 @@ class navigator {
return navigation._heartbeat;
}
// Run inspection when needed (keep for debugging)
/*if constexpr (not std::is_same_v<inspector_t,
navigation::void_inspector>) {
navigation.run_inspector("Volume switch: ");
}*/
// navigation.run_inspector("Volume switch: ");
}
// If no trust could be restored for the current state, (local)
// navigation might be exhausted or we switched volumes:
Expand Down Expand Up @@ -632,11 +627,7 @@ class navigator {
// Update navigation flow on the new candidate information
update_navigation_state(track, propagation);

// Run high trust inspection
if constexpr (not std::is_same_v<inspector_t,
navigation::void_inspector>) {
navigation.run_inspector("Update complete: high trust: ");
}
navigation.run_inspector("Update complete: high trust: ");

// The work is done if: the track has not reached a surface yet or
// trust is gone (portal was reached or the cache is broken).
Expand Down Expand Up @@ -678,11 +669,8 @@ class navigator {
// Update navigation flow on the new candidate information
update_navigation_state(track, propagation);

// Run fair trust inspection
if constexpr (not std::is_same_v<inspector_t,
navigation::void_inspector>) {
navigation.run_inspector("Update complete: fair trust: ");
}
navigation.run_inspector("Update complete: fair trust: ");

return;
}

Expand Down

0 comments on commit 6d62da7

Please sign in to comment.