10#include "introspect.hpp"
11#include "processor.hpp"
20template <
typename Event,
typename Downstream>
21 requires processor<Downstream, Event>
23 static_assert(std::move_constructible<Event>,
24 "prepend requires Event to be move-constructible (the event "
25 "is stored and moved into the stream)");
27 bool prepended =
false;
28 Downstream downstream;
34 explicit prepend(Event event, Downstream downstream)
35 : downstream(std::move(downstream)), evt(std::move(event)) {}
37 [[nodiscard]]
auto introspect_node() const -> processor_info {
38 return processor_info(
this,
"prepend");
41 [[nodiscard]]
auto introspect_graph() const -> processor_graph {
42 return downstream.introspect_graph().push_entry_point(
this);
45 template <
typename AnyEvent>
46 requires handler_for<Downstream, std::remove_cvref_t<AnyEvent>>
47 void handle(AnyEvent &&event) {
49 downstream.handle(std::move(evt));
52 downstream.handle(std::forward<AnyEvent>(event));
55 void flush() { downstream.flush(); }
58template <
typename Event,
typename Downstream>
59 requires processor<Downstream, Event>
61 static_assert(std::move_constructible<Event>,
62 "append requires Event to be move-constructible (the event "
63 "is stored and moved into the stream)");
65 Downstream downstream;
71 explicit append(Event event, Downstream downstream)
72 : downstream(std::move(downstream)), evt(std::move(event)) {}
74 [[nodiscard]]
auto introspect_node() const -> processor_info {
75 return processor_info(
this,
"append");
78 [[nodiscard]]
auto introspect_graph() const -> processor_graph {
79 return downstream.introspect_graph().push_entry_point(
this);
82 template <
typename AnyEvent>
83 requires handler_for<Downstream, std::remove_cvref_t<AnyEvent>>
84 void handle(AnyEvent &&event) {
85 downstream.handle(std::forward<AnyEvent>(event));
89 downstream.handle(std::move(evt));
120template <
typename Event,
typename Downstream>
121auto prepend(Event event, Downstream downstream) {
122 return internal::prepend<Event, Downstream>(std::move(event),
123 std::move(downstream));
153template <
typename Event,
typename Downstream>
154auto append(Event event, Downstream downstream) {
155 return internal::append<Event, Downstream>(std::move(event),
156 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:154
auto prepend(Event event, Downstream downstream)
Create a processor that inserts an event at the beginning of the stream.
Definition prepend_append.hpp:121
libtcspc namespace.
Definition acquire.hpp:30