event-sequence-transformation/nodes/tee.c

53 lines
1.1 KiB
C
Raw Permalink Normal View History

2024-08-15 23:12:23 +03:00
#include "../graph.h"
#include "../module_registry.h"
static bool
handle_event(EventPositionBase * self, EventNode * event)
{
GraphNode *node = DOWNCAST(GraphNode, EventPositionBase, self);
graph_node_broadcast_forward_event(node, event);
2024-08-15 23:12:23 +03:00
return true;
}
static GraphNode *
create(GraphNodeSpecification * spec, GraphNodeConfig * config, InitializationEnvironment * env)
2024-08-15 23:12:23 +03:00
{
(void) config;
(void) env;
2024-08-15 23:12:23 +03:00
GraphNode * node = T_ALLOC(1, GraphNode);
if (!node) {
return node;
}
*node = (GraphNode) {
.as_EventPositionBase = {
.handle_event = &handle_event,
.waiting_new_event = false,
},
.specification = spec,
.inputs = EMPTY_GRAPH_CHANNEL_LIST,
.outputs = EMPTY_GRAPH_CHANNEL_LIST,
};
return node;
}
static void destroy
(GraphNodeSpecification * self, GraphNode * target)
{
(void) self;
free(target);
}
GraphNodeSpecification nodespec_tee = (GraphNodeSpecification) {
.create = &create,
.destroy = &destroy,
.register_io = NULL,
.name = "tee",
.documentation = "Copies the received events\nAccepts events on any connector\nSends events on all connectors"
,
2024-08-15 23:12:23 +03:00
};
MODULE_CONSTRUCTOR(init)
{
register_graph_node_specification(&nodespec_tee);
}