Maki
Formally verified low-code orchestration
Loading...
Searching...
No Matches
node_info.h
1#pragma once
2
3#include <QMap>
4#include <QPointF>
5#include <QSizeF>
6#include <QString>
7#include <QVector>
8
9#include "config.h"
10#include "property_info.h"
11
15class NodeSaveInfo : public INode
16{
17public:
21 explicit NodeSaveInfo();
22 explicit NodeSaveInfo(const NodeConfig& config);
23
24 void print(const QString& indent = "") const;
25
30 QString getid() const override;
31
36 QString getnodeId() const override;
37
42 QString getNodeName() const;
43
48 QPointF getposition() const override;
49
54 QVector<std::shared_ptr<IParameter>> getfields() const override;
55
60 QVector<std::shared_ptr<IParameter>> getproperties() const override;
61
62 std::shared_ptr<IParameter> getproperty(const QString& key) const;
63
68 QVector<std::shared_ptr<IFlow>> getflows() const override;
69
74 QVector<std::shared_ptr<IFlow>> getevents() const override;
75
80 QString getparentId() const override;
81
86 QVector<std::shared_ptr<INode>> getchildren() const override;
87
92 qreal getScale() const;
93
98 QSizeF getSize() const;
99
104 QString getIcon() const;
105
110 void setId(const QString& arg);
111
116 void setNodeId(const QString& arg);
117
122 void setParentId(const QString& arg);
123
128 void setPosition(const QPointF& arg);
129
134 void setIcon(const QString& iconPath);
135
140 void setSize(const QSizeF& arg);
141
146 void setScale(qreal arg);
147
153 const PropertyInfo* getProperty(const QString& key) const;
154
160 void addProperty(std::shared_ptr<PropertyInfo> parameter);
161
167 void setProperty(const QString& key, const maki::Value& parameter);
168
173 void removeProperty(const QString& key);
174
180 PropertyInfo getField(const QString& key) const;
181
187 void setField(const QString& key, std::shared_ptr<IParameter> property);
188
193 void addField(std::shared_ptr<IParameter> property);
194
199 void removeField(const QString& key);
200
201 void addPort(const PortConfig& port);
202 QVector<PortConfig> ports() const;
203
204 QString getParentSubFlow() const;
205 void setParentSubFlow(const QString& subFlowId);
210 void addFlow(std::shared_ptr<IFlow> flow);
211
216 void removeFlow(const QString& flowId);
217
222 void addEvent(std::shared_ptr<IFlow> event);
223
228 void removeEvent(std::shared_ptr<IFlow> event);
229
234 void addChild(std::shared_ptr<INode> child);
235
240 void removeChild(const QString& childId);
241
245 void clearChildren();
246
251 QJsonObject toJson() const;
252
258 static NodeSaveInfo fromJson(const QJsonObject& data);
259
260 friend QDataStream& operator<<(QDataStream& out, const NodeSaveInfo& info);
261 friend QDataStream& operator>>(QDataStream& in, NodeSaveInfo& info);
262
263private:
264 friend class DocumentCloner;
265
266 QString mId;
267 QString mNodeId;
268 QString mParentId;
270
271 QPointF mPosition;
272 QSizeF mSize;
273 qreal mScale;
274
275 QString mIconPath;
276
277 QVector<std::shared_ptr<IParameter>> mProperties;
278 QVector<std::shared_ptr<INode>> mChildren;
279 QVector<std::shared_ptr<IFlow>> mFlows;
280 QVector<std::shared_ptr<IFlow>> mEvents;
281 QVector<std::shared_ptr<ITransition>> mTransitions;
282 QVector<std::shared_ptr<IParameter>> mFields;
283 QVector<PortConfig> mPorts;
284};
285
292QDataStream& operator<<(QDataStream& out, const QVector<std::shared_ptr<INode>>& nodes);
293
300QDataStream& operator>>(QDataStream& in, QVector<std::shared_ptr<INode>>& nodes);
301
308QDataStream& operator<<(QDataStream& out, const QVector<std::shared_ptr<NodeSaveInfo>>& nodes);
309
316QDataStream& operator>>(QDataStream& in, QVector<std::shared_ptr<NodeSaveInfo>>& nodes);
317
318typedef std::shared_ptr<NodeSaveInfo> PNodeSaveInfo;
Configuration for a node.
Definition config.h:236
void removeEvent(std::shared_ptr< IFlow > event)
Removes a flow from the node by reference.
Definition node_info.cpp:315
const PropertyInfo * getProperty(const QString &key) const
Gets a property by key.
Definition node_info.cpp:196
void setProperty(const QString &key, const maki::Value &parameter)
Sets a property to the node.
Definition node_info.cpp:213
QPointF getposition() const override
Gets the position of the node.
Definition node_info.cpp:107
QString getIcon() const
Gets the icon path of the node.
Definition node_info.cpp:122
void setParentId(const QString &arg)
Sets the parent ID of the node.
Definition node_info.cpp:171
void removeFlow(const QString &flowId)
Removes a flow from the node by ID.
Definition node_info.cpp:289
QVector< std::shared_ptr< IFlow > > mFlows
A vector of children nodes.
Definition node_info.h:279
void removeProperty(const QString &key)
Removes a property from the node.
Definition node_info.cpp:234
void removeField(const QString &key)
Removes a field from the node.
Definition node_info.cpp:274
QString mParentSubFlow
The parent ID of the node.
Definition node_info.h:269
QString getNodeName() const
Gets the node name.
Definition node_info.cpp:94
NodeSaveInfo()
Constructs a new NodeSaveInfo object.
Definition node_info.cpp:18
QVector< std::shared_ptr< IParameter > > getproperties() const override
Gets the properties of the node.
Definition node_info.cpp:132
static NodeSaveInfo fromJson(const QJsonObject &data)
Creates a NodeSaveInfo object from a JSON object.
Definition node_info.cpp:412
void addFlow(std::shared_ptr< IFlow > flow)
Adds a flow to the node.
Definition node_info.cpp:279
QPointF mPosition
The subflow ID of this node.
Definition node_info.h:271
void addField(std::shared_ptr< IParameter > property)
Adds a field to the node.
Definition node_info.cpp:269
QSizeF getSize() const
Gets the size of the node.
Definition node_info.cpp:117
void setNodeId(const QString &arg)
Sets the node ID.
Definition node_info.cpp:166
PropertyInfo getField(const QString &key) const
Gets a field by key.
Definition node_info.cpp:244
void setScale(qreal arg)
Sets the scale of the node.
Definition node_info.cpp:191
QVector< std::shared_ptr< INode > > mChildren
A vector of properties for the node.
Definition node_info.h:278
qreal getScale() const
Gets the scale of the node.
Definition node_info.cpp:112
QVector< std::shared_ptr< IParameter > > mProperties
The icon path of the node.
Definition node_info.h:277
void addEvent(std::shared_ptr< IFlow > event)
Adds a flow to the node.
Definition node_info.cpp:310
void setId(const QString &arg)
Sets the ID of the node.
Definition node_info.cpp:161
void addChild(std::shared_ptr< INode > child)
Adds a child to the node.
Definition node_info.cpp:320
QVector< std::shared_ptr< IFlow > > getevents() const override
Gets the events of the node.
Definition node_info.cpp:151
void setIcon(const QString &iconPath)
Sets the icon path of the node.
Definition node_info.cpp:181
void addProperty(std::shared_ptr< PropertyInfo > parameter)
Adds a property to the node.
Definition node_info.cpp:205
QString getnodeId() const override
Gets the node ID.
Definition node_info.cpp:89
qreal mScale
The size of the node.
Definition node_info.h:273
void setField(const QString &key, std::shared_ptr< IParameter > property)
Sets a field for the node.
Definition node_info.cpp:253
QString getid() const override
Gets the ID of the node.
Definition node_info.cpp:84
void setSize(const QSizeF &arg)
Sets the size of the node.
Definition node_info.cpp:186
QSizeF mSize
The position of the node.
Definition node_info.h:272
QString mParentId
The node ID.
Definition node_info.h:268
QString mNodeId
The ID of the node.
Definition node_info.h:267
void setPosition(const QPointF &arg)
Sets the position of the node.
Definition node_info.cpp:176
QVector< std::shared_ptr< IFlow > > getflows() const override
Gets the flows of the node.
Definition node_info.cpp:146
QVector< std::shared_ptr< ITransition > > mTransitions
A vector of flows associated with the node.
Definition node_info.h:281
QVector< std::shared_ptr< IParameter > > getfields() const override
Gets the fields of the node.
Definition node_info.cpp:127
QVector< std::shared_ptr< INode > > getchildren() const override
Gets the children of the node.
Definition node_info.cpp:156
QVector< std::shared_ptr< IParameter > > mFields
A vector of transitions for the node.
Definition node_info.h:282
QVector< PortConfig > mPorts
A vector of fields for the node.
Definition node_info.h:283
QVector< std::shared_ptr< IFlow > > mEvents
A vector of flows associated with the node.
Definition node_info.h:280
QJsonObject toJson() const
Converts the node to a JSON object.
Definition node_info.cpp:357
QString mIconPath
The scale of the node.
Definition node_info.h:275
void removeChild(const QString &childId)
Removes a child from the node by ID.
Definition node_info.cpp:325
QString getparentId() const override
Gets the parent ID of the node.
Definition node_info.cpp:102
void clearChildren()
Clears all children from the node.
Definition node_info.cpp:330
Configuration for port information.
Definition config.h:147
Represents a property with configuration and options.
Definition property_info.h:16