9#include "arg_wrappers.hpp"
11#include "introspect.hpp"
12#include "processor.hpp"
13#include "type_list.hpp"
22template <
typename GatedEventList,
typename OpenEvent,
typename CloseEvent,
25 static_assert(type_list_like<GatedEventList>);
27 static_assert(handler_for<Downstream, OpenEvent, CloseEvent>);
31 Downstream downstream;
34 explicit gate(arg::initially_open<bool> initially_open,
35 Downstream downstream)
36 : open(initially_open.value), downstream(std::move(downstream)) {}
38 [[nodiscard]]
auto introspect_node() const -> processor_info {
39 return processor_info(
this,
"gate");
42 [[nodiscard]]
auto introspect_graph() const -> processor_graph {
43 return downstream.introspect_graph().push_entry_point(
this);
47 requires handler_for<Downstream, std::remove_cvref_t<E>>
48 void handle(E &&event) {
49 if constexpr (std::is_convertible_v<std::remove_cvref_t<E>,
52 downstream.handle(std::forward<E>(event));
53 }
else if constexpr (std::is_convertible_v<std::remove_cvref_t<E>,
56 downstream.handle(std::forward<E>(event));
57 }
else if constexpr (convertible_to_type_list_member<
58 std::remove_cvref_t<E>, GatedEventList>) {
60 downstream.handle(std::forward<E>(event));
62 downstream.handle(std::forward<E>(event));
66 void flush() { downstream.flush(); }
109template <
typename GatedEventList,
typename OpenEvent,
typename CloseEvent,
112 return internal::gate<GatedEventList, OpenEvent, CloseEvent, Downstream>(
113 initially_open, std::move(downstream));
auto gate(arg::initially_open< bool > initially_open, Downstream downstream)
Create a processor that gates events depending on current state.
Definition gate.hpp:111
libtcspc namespace.
Definition acquire.hpp:29
Function argument wrapper for initially open parameter.
Definition arg_wrappers.hpp:157