v2.0.0
Loading...
Searching...
No Matches
mna_graph.h
Go to the documentation of this file.
1//=============================================================================================================
34
35#ifndef MNA_GRAPH_H
36#define MNA_GRAPH_H
37
38//=============================================================================================================
39// INCLUDES
40//=============================================================================================================
41
42#include "mna_global.h"
43#include "mna_node.h"
44#include "mna_port.h"
45#include "mna_param_tree.h"
46
47//=============================================================================================================
48// QT INCLUDES
49//=============================================================================================================
50
51#include <QString>
52#include <QStringList>
53#include <QList>
54#include <QJsonObject>
55#include <QCborMap>
56
57//=============================================================================================================
58// DEFINE NAMESPACE MNALIB
59//=============================================================================================================
60
61namespace MNALIB
62{
63
64//=============================================================================================================
71{
72public:
73 MnaGraph();
74
75 //=========================================================================================================
76 // Node management
77 //=========================================================================================================
78
79 void addNode(const MnaNode& node);
80 void removeNode(const QString& nodeId);
81 MnaNode& node(const QString& nodeId);
82 const MnaNode& node(const QString& nodeId) const;
83 QList<MnaNode>& nodes();
84 const QList<MnaNode>& nodes() const;
85 bool hasNode(const QString& nodeId) const;
86
87 //=========================================================================================================
88 // Graph-level ports
89 //=========================================================================================================
90
91 QList<MnaPort> graphInputs;
92 QList<MnaPort> graphOutputs;
93
94 //=========================================================================================================
95 // Parameter tree
96 //=========================================================================================================
97
99
100 //=========================================================================================================
101 // Connection helper
102 //=========================================================================================================
103
109 bool connect(const QString& srcNodeId, const QString& srcPortName,
110 const QString& dstNodeId, const QString& dstPortName);
111
112 //=========================================================================================================
113 // Validation
114 //=========================================================================================================
115
122 bool validate(QStringList* errors = nullptr) const;
123
124 //=========================================================================================================
125 // Topological sort
126 //=========================================================================================================
127
128 QStringList topologicalSort() const;
129
130 //=========================================================================================================
131 // Dependency queries
132 //=========================================================================================================
133
134 QStringList upstreamNodes(const QString& nodeId) const;
135 QStringList downstreamNodes(const QString& nodeId) const;
136 QStringList dirtyNodes() const;
137
138 //=========================================================================================================
139 // Serialization
140 //=========================================================================================================
141
142 QJsonObject toJson() const;
143 static MnaGraph fromJson(const QJsonObject& json);
144 QCborMap toCbor() const;
145 static MnaGraph fromCbor(const QCborMap& cbor);
146
147private:
148 QList<MnaNode> m_nodes;
149};
150
151} // namespace MNALIB
152
153#endif // MNA_GRAPH_H
MnaParamTree class declaration — hierarchical parameter store with formula-driven bindings.
MnaPort struct declaration — typed input/output slot on a graph node.
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).
MnaNode & node(const QString &nodeId)
Definition mna_graph.cpp:84
void addNode(const MnaNode &node)
Definition mna_graph.cpp:65
bool validate(QStringList *errors=nullptr) const
QStringList dirtyNodes() const
bool hasNode(const QString &nodeId) const
QStringList downstreamNodes(const QString &nodeId) const
QCborMap toCbor() const
void removeNode(const QString &nodeId)
Definition mna_graph.cpp:72
QList< MnaPort > graphInputs
Named, typed entry points.
Definition mna_graph.h:91
QList< MnaPort > graphOutputs
Named, typed exit points.
Definition mna_graph.h:92
MnaParamTree paramTree
Hierarchical parameter store with formula-driven bindings.
Definition mna_graph.h:98
QList< MnaNode > & nodes()
QJsonObject toJson() const
QStringList topologicalSort() const
static MnaGraph fromJson(const QJsonObject &json)
QStringList upstreamNodes(const QString &nodeId) const
bool connect(const QString &srcNodeId, const QString &srcPortName, const QString &dstNodeId, const QString &dstPortName)
static MnaGraph fromCbor(const QCborMap &cbor)
Graph node representing a processing step.
Definition mna_node.h:75
Parameter tree with formula-driven dynamic bindings.