Graph — the assembly stage that takes Nodes and turns them into a runnable Run. More...
Namespaces Index
Classes Index
Description
Graph — the assembly stage that takes Nodes and turns them into a runnable Run.
Graph is the central concept of the framework. It collects Nodes and reusable Graph fragments, validates them against built-in contracts, compiles them into a deterministic GStreamer pipeline string, instantiates the pipeline, negotiates caps between adjacent elements, and returns a Run handle for push/pull execution. Model is internally a Graph wrapper: the same composition, validation, and runtime machinery powers Model underneath. New users typically use Model::run(); advanced users compose their own Graphs with graph.add(model) plus extra Nodes for input sources, custom processing, side branches, or RTSP server output.
- See Also
Run for the runtime handle a built Graph produces
- See Also
RtspServerHandle for server-mode Graphs
- See Also
"Graphs: the assembly contract" (§0.12 of the design deep dive)
File Listing
The file content with the documentation metadata removed is:
21#include "builder/Node.h"
24#include "builder/GraphPrinter.h"
53#include <opencv2/core/mat.hpp>
63namespace pipeline_internal {
64struct InputRouteProcessor;
70#ifdef SIMA_NEAT_INTERNAL
72struct ExecutionGraphPlan;
73struct FragmentBoundaryHints;
76ExecutionGraphPlan compile_public_graph(const Graph& graph, const RunOptions& opt,
77 std::optional<Sample> seed);
108 const std::string& url() const {
124 void* impl_ = nullptr;
125 std::shared_ptr<void> guard_;
184 const std::string& name() const noexcept;
218 Graph& connect(std::string_view from_endpoint, std::string_view to_endpoint);
229#ifdef SIMA_NEAT_INTERNAL
231 std::size_t append_pipeline_vertex_for_internal_graph_(std::shared_ptr<Node> node);
234 append_runtime_vertex_for_internal_graph_(std::shared_ptr<simaai::neat::graph::Node> node);
236 void connect_runtime_port_for_internal_graph_(std::size_t from, std::string_view from_port,
237 std::size_t to, std::string_view to_port);
330 std::string describe(const GraphPrinter::Options& opt = {}) const;
348 void save(const std::string& path) const;
363 return last_pipeline_;
374 struct CompositionGraph;
375 enum class CompositionEdgeKind {
380 struct EndpointEdgeMeta {
381 std::string from_endpoint;
382 std::string to_endpoint;
384 struct CompositionEdge {
385 std::size_t from = static_cast<std::size_t>(-1);
386 std::size_t to = static_cast<std::size_t>(-1);
387 CompositionEdgeKind kind = CompositionEdgeKind::ImplicitLinear;
388 std::string from_port;
390 std::optional<EndpointEdgeMeta> endpoint;
393 struct NamedFragment;
395#ifdef SIMA_NEAT_INTERNAL
396 struct CompositionView {
397 std::vector<std::shared_ptr<Node>> linear_nodes;
398 std::vector<std::shared_ptr<Node>> vertices;
399 std::vector<std::shared_ptr<simaai::neat::graph::Node>> runtime_vertices;
400 std::span<const CompositionEdge> edges;
401 std::span<const GroupMeta> groups;
402 std::span<const runtime::FragmentPlan> fragments;
403 std::span<const NamedFragment> named_fragments;
404 GraphOptions options;
405 std::string graph_name;
406 bool graph_user_named = false;
407 std::uint64_t graph_id = 0;
408 std::uint64_t graph_version = 0;
414 struct PreparedSource;
415 enum class SinkRequirement : int { Required, OptionalIfPresent };
417#ifdef SIMA_NEAT_INTERNAL
418 CompositionView composition_view_for_internal_compile() const;
419 friend runtime::ExecutionGraphPlan runtime::compile_public_graph(const Graph& graph,
420 const RunOptions& opt,
421 std::optional<Sample> seed);
426 void invalidate_built_() noexcept;
432 PreparedSource prepare_source_(RunMode mode, const RunOptions& opt, SinkRequirement sink_req,
444 std::size_t start = 0;
446 NodeCapsBehavior caps_behavior = NodeCapsBehavior::Dynamic;
450 struct NamedFragment {
451 std::size_t start = 0;
454 bool user_named = false;
457 std::unique_ptr<CompositionGraph> composition_;
458 std::vector<GroupMeta> groups_;
459 std::string last_pipeline_;
460 std::shared_ptr<void> guard_;
461 std::shared_ptr<void> verbose_guard_;
463 std::string endpoint_name_;
465 uint64_t graph_id_ = 0;
466 std::atomic<uint64_t> nodes_version_{0};
467 std::unique_ptr<BuiltState> built_;
468 std::unique_ptr<RunCache> run_cache_;
469 uint64_t built_version_ = 0;
470 std::shared_ptr<const pipeline_internal::InputRouteProcessor> input_route_processor_;
472 void mark_composition_changed();
473 std::pair<std::size_t, std::size_t> append_linear_fragment_(const Graph& fragment,
475 std::pair<std::size_t, std::size_t> import_composition_fragment_(const Graph& fragment,
477 std::pair<std::size_t, std::size_t> import_or_reuse_composition_fragment_(const Graph& fragment,
479 bool is_output_collection_fragment_(const Graph& fragment) const;
480 std::pair<std::size_t, std::size_t> import_output_collection_fragment_(const Graph& fragment,
482 std::pair<std::size_t, std::size_t>
483 import_or_reuse_output_collection_fragment_(const Graph& fragment, const char* where);
484 std::pair<std::size_t, std::size_t> import_or_reuse_node_fragment_(std::shared_ptr<Node> node,
486 std::pair<std::size_t, std::size_t> import_or_reuse_model_fragment_(const Model& model,
488 void connect_imported_ranges_(std::pair<std::size_t, std::size_t> from_range,
489 std::string_view from_name,
490 std::pair<std::size_t, std::size_t> to_range,
491 std::string_view to_name, const char* where);
492#ifdef SIMA_NEAT_INTERNAL
493 void attach_fragment_boundary_hints_(std::size_t start, std::size_t end,
494 runtime::FragmentBoundaryHints hints);
495 void attach_fragment_boundary_hints_(std::size_t start, std::size_t end,
496 runtime::FragmentBoundaryHints hints,
497 runtime::Provenance provenance);
499 std::vector<std::shared_ptr<Node>> linear_nodes_snapshot(const char* where) const;
500 void build_cached_source();
Generated via doxygen2docusaurus 2.0.0 by Doxygen 1.9.8.