v2.0.0
Loading...
Searching...
No Matches
mna_graph_executor.h
Go to the documentation of this file.
1//=============================================================================================================
34
35#ifndef MNA_GRAPH_EXECUTOR_H
36#define MNA_GRAPH_EXECUTOR_H
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
42#include "mna_global.h"
43#include "mna_node.h"
44
45//=============================================================================================================
46// QT INCLUDES
47//=============================================================================================================
48
49#include <QString>
50#include <QMap>
51#include <QVariant>
52#include <QVariantMap>
53#include <QObject>
54#include <functional>
55
56//=============================================================================================================
57// FORWARD DECLARATIONS
58//=============================================================================================================
59
60namespace MNALIB
61{
62class MnaGraph;
63}
64
65//=============================================================================================================
66// DEFINE NAMESPACE MNALIB
67//=============================================================================================================
68
69namespace MNALIB
70{
71
72//=============================================================================================================
80{
81public:
85 struct Context
86 {
88 QMap<QString, QVariant> results;
89
91 QVariantMap graphInputs;
92 };
93
94 //=========================================================================================================
103 {
104 MnaGraph* graph = nullptr;
105 QMap<QString, QObject*> livePlugins;
106 bool running = false;
107 QStringList executionOrder;
108 };
109
116 static Context execute(MnaGraph& graph, const QVariantMap& graphInputs);
117
124 static Context executeIncremental(MnaGraph& graph, Context& existing);
125
132 static QVariantMap executeNode(const MnaNode& node,
133 const QVariantMap& inputs);
134
136 using ProgressCallback = std::function<void(const QString& nodeId,
137 int current, int total)>;
138
143
144 //=========================================================================================================
145 // Stream-mode execution
146 //=========================================================================================================
147
150 using PluginFactory = std::function<QObject*(const QString& opType)>;
151
169 static StreamContext startStream(MnaGraph& graph, PluginFactory factory);
170
177 static void stopStream(StreamContext& ctx);
178
179private:
180 static ProgressCallback s_progressCallback;
181};
182
183} // namespace MNALIB
184
185#endif // MNA_GRAPH_EXECUTOR_H
mna library export/import macros.
#define MNASHARED_EXPORT
Definition mna_global.h:55
MnaNode struct declaration — one operation in the computational graph.
MNE Analysis Container Format (mna/mnx).
MNA computational graph.
Definition mna_graph.h:71
Graph executor for MNA pipelines.
static void setProgressCallback(ProgressCallback cb)
static Context executeIncremental(MnaGraph &graph, Context &existing)
static StreamContext startStream(MnaGraph &graph, PluginFactory factory)
static QVariantMap executeNode(const MnaNode &node, const QVariantMap &inputs)
std::function< QObject *(const QString &opType)> PluginFactory
static void stopStream(StreamContext &ctx)
static Context execute(MnaGraph &graph, const QVariantMap &graphInputs)
std::function< void(const QString &nodeId, int current, int total)> ProgressCallback
Progress callback type.
QMap< QString, QVariant > results
nodeId::portName → data (QVariant wrapping domain objects or file paths)
QVariantMap graphInputs
Graph-level inputs (populated before execution).
QStringList executionOrder
Topological order used for startup/shutdown.
bool running
Whether the stream is active.
MnaGraph * graph
The pipeline graph (owned externally).
QMap< QString, QObject * > livePlugins
nodeId → live plugin instance (QObject* avoids scan dependency)
Graph node representing a processing step.
Definition mna_node.h:75