10#include "introspect.hpp"
11#include "processor.hpp"
19template <
typename Event,
typename Downstream>
class prepend {
20 static_assert(processor<Downstream, Event>);
22 bool prepended =
false;
23 Downstream downstream;
29 explicit prepend(Event event, Downstream downstream)
30 : downstream(std::move(downstream)), evt(std::move(event)) {}
32 [[nodiscard]]
auto introspect_node() const -> processor_info {
33 return processor_info(
this,
"prepend");
36 [[nodiscard]]
auto introspect_graph() const -> processor_graph {
37 return downstream.introspect_graph().push_entry_point(
this);
40 template <
typename AnyEvent>
41 requires handler_for<Downstream, std::remove_cvref_t<AnyEvent>>
42 void handle(AnyEvent &&event) {
44 downstream.handle(std::move(evt));
47 downstream.handle(std::forward<AnyEvent>(event));
50 void flush() { downstream.flush(); }
53template <
typename Event,
typename Downstream>
class append {
54 static_assert(processor<Downstream, Event>);
56 Downstream downstream;
62 explicit append(Event event, Downstream downstream)
63 : downstream(std::move(downstream)), evt(std::move(event)) {}
65 [[nodiscard]]
auto introspect_node() const -> processor_info {
66 return processor_info(
this,
"append");
69 [[nodiscard]]
auto introspect_graph() const -> processor_graph {
70 return downstream.introspect_graph().push_entry_point(
this);
73 template <
typename AnyEvent>
74 requires handler_for<Downstream, std::remove_cvref_t<AnyEvent>>
75 void handle(AnyEvent &&event) {
76 downstream.handle(std::forward<AnyEvent>(event));
80 downstream.handle(std::move(evt));
110template <
typename Event,
typename Downstream>
111auto prepend(Event event, Downstream downstream) {
112 return internal::prepend<Event, Downstream>(std::move(event),
113 std::move(downstream));
142template <
typename Event,
typename Downstream>
143auto append(Event event, Downstream downstream) {
144 return internal::append<Event, Downstream>(std::move(event),
145 std::move(downstream));
auto append(Event event, Downstream downstream)
Create a processor that inserts an event at the end of the stream.
Definition prepend_append.hpp:143
auto prepend(Event event, Downstream downstream)
Create a processor that inserts an event at the beginning of the stream.
Definition prepend_append.hpp:111
libtcspc namespace.
Definition acquire.hpp:29