Skip to main content

StageExecutor.h File

Actor-like stage executor interface (multi-port). More...

Included Headers

#include "graph/GraphTypes.h" #include "pipeline/SessionOptions.h" #include <cstdint> #include <string> #include <unordered_map> #include <vector>

Namespaces Index

namespacesimaai
namespaceneat
namespacegraph

Classes Index

structStageMsg
structStageOutMsg
structStagePorts
classStageExecutor

Description

Actor-like stage executor interface (multi-port).

File Listing

The file content with the documentation metadata removed is:

1
6#pragma once
7
8#include "graph/GraphTypes.h"
10
11#include <cstdint>
12#include <string>
13#include <unordered_map>
14#include <vector>
15
16namespace simaai::neat::graph {
17
18struct StageMsg {
19 PortId in_port = kInvalidPort;
21};
22
23struct StageOutMsg {
24 PortId out_port = kInvalidPort;
26};
27
28struct StagePorts {
29 std::unordered_map<std::string, PortId> in;
30 std::unordered_map<std::string, PortId> out;
31
32 PortId in_port(const std::string& name) const {
33 auto it = in.find(name);
34 return it == in.end() ? kInvalidPort : it->second;
35 }
36
37 PortId out_port(const std::string& name) const {
38 auto it = out.find(name);
39 return it == out.end() ? kInvalidPort : it->second;
40 }
41
42 PortId only_input() const {
43 return in.size() == 1 ? in.begin()->second : kInvalidPort;
44 }
45
47 return out.size() == 1 ? out.begin()->second : kInvalidPort;
48 }
49};
50
52public:
53 virtual ~StageExecutor() = default;
54
55 // Optional: provide port IDs for routing (StageExecutor can cache).
56 virtual void set_ports(const StagePorts& /*ports*/) {}
57
58 virtual void start() {}
59 virtual void stop() {}
60
61 // Called when an input arrives on any port.
62 virtual void on_input(StageMsg&& msg, std::vector<StageOutMsg>& out) = 0;
63
64 // Optional periodic tick for timeout-based stages.
65 virtual void on_tick(std::int64_t /*now_ns*/, std::vector<StageOutMsg>& /*out*/) {}
66};
67
68} // namespace simaai::neat::graph

Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.1.