v2.0.0
Loading...
Searching...
No Matches
mna_graph_executor.h
Go to the documentation of this file.
1//=============================================================================================================
30
31#ifndef MNA_GRAPH_EXECUTOR_H
32#define MNA_GRAPH_EXECUTOR_H
33
34//=============================================================================================================
35// INCLUDES
36//=============================================================================================================
37
38#include "mna_global.h"
39#include "mna_node.h"
40
41//=============================================================================================================
42// QT INCLUDES
43//=============================================================================================================
44
45#include <QString>
46#include <QMap>
47#include <QVariant>
48#include <QVariantMap>
49#include <QObject>
50#include <functional>
51#include <memory>
52#include <map>
53
54//=============================================================================================================
55// FORWARD DECLARATIONS
56//=============================================================================================================
57
58namespace MNALIB
59{
60class MnaGraph;
61}
62
63//=============================================================================================================
64// DEFINE NAMESPACE MNALIB
65//=============================================================================================================
66
67namespace MNALIB
68{
69
70//=============================================================================================================
80{
81public:
85 struct Context
86 {
88 QMap<QString, QVariant> results;
89
91 QVariantMap graphInputs;
92
94 QString abortedNode;
95 };
96
97 //=========================================================================================================
106 {
107 MnaGraph* graph = nullptr;
108 std::map<QString, std::unique_ptr<QObject>> livePlugins;
109 bool running = false;
110 QStringList executionOrder;
111 };
112
119 static Context execute(MnaGraph& graph, const QVariantMap& graphInputs);
120
127 static Context executeIncremental(MnaGraph& graph, Context& existing);
128
135 static QVariantMap executeNode(const MnaNode& node,
136 const QVariantMap& inputs);
137
139 using ProgressCallback = std::function<void(const QString& nodeId,
140 int current, int total)>;
141
147
148 //=========================================================================================================
149 // Stream-mode execution
150 //=========================================================================================================
151
154 using PluginFactory = std::function<std::unique_ptr<QObject>(const QString& opType)>;
155
173 static StreamContext startStream(MnaGraph& graph, PluginFactory factory);
174
181 static void stopStream(StreamContext& ctx);
182
183private:
185 static void applyParamTree(MnaGraph& graph);
186
191 static bool runNode(MnaGraph& graph, MnaNode& node, Context& ctx);
192
194 static QList<MnaVerificationResult> runChecks(const MnaGraph& graph, const MnaNode& node, const QString& phase, const QVariantMap& scope);
195
196 static ProgressCallback s_progressCallback;
197};
198
199} // namespace MNALIB
200
201#endif // MNA_GRAPH_EXECUTOR_H
Export/import macros, build-info accessors, and MNALIB namespace anchor for the MNE Analysis Containe...
#define MNASHARED_EXPORT
Definition mna_global.h:47
One operation in an MNA graph — opType, typed I/O ports, attributes, execution mode (Batch / Stream /...
MNE Analysis Container Format (mna/mnx).
In-memory DAG of MnaNode operations with validation, topological sort and JSON/CBOR persistence.
Definition mna_graph.h:68
Stateless batch and stream-mode runner for an MnaGraph.
static void setProgressCallback(ProgressCallback cb)
static Context executeIncremental(MnaGraph &graph, Context &existing)
static StreamContext startStream(MnaGraph &graph, PluginFactory factory)
std::function< std::unique_ptr< QObject >(const QString &opType)> PluginFactory
static QVariantMap executeNode(const MnaNode &node, const QVariantMap &inputs)
std::function< void(const QString &nodeId, int current, int total)> ProgressCallback
Progress callback type.
static void stopStream(StreamContext &ctx)
static Context execute(MnaGraph &graph, const QVariantMap &graphInputs)
QMap< QString, QVariant > results
nodeId::portName → data (QVariant wrapping domain objects or file paths)
QVariantMap graphInputs
Graph-level inputs (populated before execution).
QString abortedNode
Node whose failed "error" check stopped the run (empty if it ran to the end).
QStringList executionOrder
Topological order used for startup/shutdown.
std::map< QString, std::unique_ptr< QObject > > livePlugins
nodeId → owned live plugin (QObject avoids a scan dependency)
bool running
Whether the stream is active.
MnaGraph * graph
The pipeline graph (owned externally).
Single executable step in an MNA pipeline graph, with attributes, typed ports, exec mode,...
Definition mna_node.h:77