Skip to main content

MnaGraphExecutor

Namespace: MNALIB  ·  Library: MNA Library

#include <mna/mna_graph_executor.h>

class MNALIB::MnaGraphExecutor

Executes a computational graph by traversing nodes in topological order and invoking registered operation functions.

Stateless batch and stream-mode runner for an MnaGraph.

src/examples/ex_mna/main.cpp
MnaGraphExecutor::Context ctx = MnaGraphExecutor::execute(graph, {});
const double first = ctx.results.value("shift::out").toDouble(); // "nodeId::port"
const double gainAfterFirst = graph.paramTree.param("scale/gain").toDouble();

graph.node("source").attributes["value"] = 1.0;
graph.node("source").dirty = true; // only source and its downstream nodes run again
const double second = MnaGraphExecutor::executeIncremental(graph, ctx).results.value("shift::out").toDouble();

Static Methods​

execute(graph, graphInputs)​

Execute the full graph (all nodes in topological order).

Parameters:

  • graph : MnaGraph & The graph to execute.

  • graphInputs : const QVariantMap & Named inputs fed into graph-level input ports.

Returns:

  • Context — Execution context with all results.

executeIncremental(graph, existing)​

Execute only dirty nodes and their downstream dependents.

Parameters:

  • graph : MnaGraph & The graph to execute.

  • existing : Context & Existing context with prior results.

Returns:

  • Context — Updated context.

executeNode(node, inputs)​

Execute a single node (for testing/debugging).

Parameters:

  • node : const MnaNode & The node to execute.

  • inputs : const QVariantMap & Input data keyed by port name.

Returns:

  • QVariantMap — Output data keyed by port name.

setProgressCallback(cb)​

Set a progress callback invoked for each node execution.

Parameters:

  • cb : ProgressCallback Callback receiving the node id and its 1-based index out of the total; an empty callback disables reporting.

startStream(graph, factory)​

Start stream-mode execution of a graph.

Validates the graph

Performs topological sort

For each node, calls factory to instantiate a live plugin

Applies MnaParamTree values to node attributes

Wires connections based on port dataKind matching

The mna library does NOT depend on MNE Scan — the host app provides the factory and is responsible for wiring Qt signal/slot connections between the returned QObject* instances.

Parameters:

  • graph : MnaGraph & The pipeline graph.

  • factory : PluginFactory Callback that maps opType → live QObject* plugin.

Returns:

  • StreamContext — Stream context. Check ctx.running to see if startup succeeded.

stopStream(ctx)​

Stop a running stream.

Iterates nodes in reverse topological order and deletes the live plugin objects.

Parameters:

  • ctx : StreamContext & The stream context to stop.

Example​

Used in examples​

ex_mna​

MNA library: register operations, build and run a graph, bind parameters and save a project.

src/examples/ex_mna/main.cpp, line 159
MnaGraphExecutor::Context ctx = MnaGraphExecutor::execute(graph, {});
const double first = ctx.results.value("shift::out").toDouble(); // "nodeId::port"
const double gainAfterFirst = graph.paramTree.param("scale/gain").toDouble();

Authors of this file​