1#ifndef KOKKOS_UTILS_CALLBACKS_RECORDERLISTENER_HPP
2#define KOKKOS_UTILS_CALLBACKS_RECORDERLISTENER_HPP
24template <
typename MatcherType,
Event... EventTypes>
25requires Matcher<MatcherType, Kokkos::Impl::type_list<EventTypes...>>
35 template <
typename T>
requires std::same_as<std::remove_cvref_t<T>, MatcherType>
37 : matcher(std::forward<T>(matcher_)) {}
39 template <EventOneOf<event_type_list_t> EventType>
52 void report(std::ostream& out = std::cout)
const
54 out <<
"Number of events recorded: " <<
recorded_events.size() << std::endl;
56 std::visit([&out] (
const auto& arg) { out <<
"- " << arg << std::endl; }, recorded_event);
61 template <
typename Callable>
62 static auto record(Callable&& callable)
64 const auto recorder_listener = std::make_shared<RecorderListener>();
68 std::invoke(std::forward<Callable>(callable));
72 return std::move(recorder_listener->recorded_events);
83 MatcherType matcher {};
86template <
typename MatcherType, Event... EventTypes>
91template <
Event... EventTypes>
94template <
Event... EventTypes>
static void unregister_listener(const Callable *const callable)
Unregister a callable object as a listener.
static listener_list_const_iter_t register_listener(std::shared_ptr< Callable > callable)
Register a callable object, passed as a shared pointer, as a listener.
static auto record(Callable &&callable)
Returns the events of the types EventTypes... that occur during the execution of callable.
RecorderListener(T &&matcher_)
RecorderListener()=default
void operator()(const EventType &event)
std::deque< std::variant< EventTypes... > > recorded_events
void report(std::ostream &out=std::cout) const
Report the recorded events.
Kokkos::Impl::type_list< EventTypes... > event_type_list_t
Concept that models that a callable object is a matcher for the event types in EventTypeSubList if it...