Maki
Formally verfied low-code orchestration
Loading...
Searching...
No Matches
node_info.h
1#pragma once
2
3#include <QMap>
4#include <QPixmap>
5#include <QPointF>
6#include <QSizeF>
7#include <QString>
8#include <QVector>
9
10#include "config.h"
11#include "property_info.h"
12
16class NodeSaveInfo : public INode
17{
18public:
23 NodeSaveInfo(const NodeConfig& config);
24
29 QString getid() const override;
30
35 QString getnodeId() const override;
36
41 QPointF getposition() const override;
42
47 QVector<std::shared_ptr<IParameter>> getfields() const override;
48
53 QVector<std::shared_ptr<IParameter>> getproperties() const override;
54
59 QVector<std::shared_ptr<IFlow>> getflows() const override;
60
65 QVector<std::shared_ptr<IFlow>> getevents() const override;
66
71 QString getparentId() const override;
72
77 QVector<std::shared_ptr<INode>> getchildren() const override;
78
83 qreal getScale() const;
84
89 QSizeF getSize() const;
90
95 QPixmap getPixmap() const;
96
101 QString getIcon() const;
102
107 void setId(const QString& arg);
108
113 void setNodeId(const QString& arg);
114
119 void setParentId(const QString& arg);
120
125 void setPosition(const QPointF& arg);
126
131 void setPixmap(const QPixmap& arg);
132
137 void setIcon(const QString& iconPath);
138
143 void setSize(const QSizeF& arg);
144
149 void setScale(qreal arg);
150
156 const PropertyInfo* getProperty(const QString& key) const;
157
163 void addProperty(std::shared_ptr<PropertyInfo> parameter);
164
165 void setProperty(const QString& key, const maki::Value& parameter);
166
171 void removeProperty(const QString& key);
172
178 PropertyInfo getField(const QString& key) const;
179
185 void setField(const QString& key, std::shared_ptr<IParameter> property);
186
191 void addField(std::shared_ptr<IParameter> property);
192
197 void removeField(const QString& key);
198
203 void addFlow(std::shared_ptr<IFlow> flow);
204
209 void removeFlow(std::shared_ptr<IFlow> flow);
210
215 void removeFlow(const QString& flowId);
216
221 void addEvent(std::shared_ptr<IFlow> event);
222
227 void removeEvent(std::shared_ptr<IFlow> event);
228
233 void addChild(std::shared_ptr<INode> child);
234
239 void removeChild(const QString& childId);
240
244 void clearChildren();
245
250 QJsonObject toJson() const;
251
257 static NodeSaveInfo fromJson(const QJsonObject& data);
258
259 friend QDataStream& operator<<(QDataStream& out, const NodeSaveInfo& info);
260 friend QDataStream& operator>>(QDataStream& in, NodeSaveInfo& info);
261
262private:
263 QString mId;
264 QString mNodeId;
265 QString mParentId;
266
267 QPointF mPosition;
268 QSizeF mSize;
269 qreal mScale;
270
271 QPixmap mPixmap;
272 QString mIconPath;
273
274 QVector<std::shared_ptr<IParameter>> mProperties;
275 QVector<std::shared_ptr<INode>> mChildren;
276 QVector<std::shared_ptr<IFlow>> mFlows;
277 QVector<std::shared_ptr<IFlow>> mEvents;
278 QVector<std::shared_ptr<ITransition>> mTransitions;
279 QVector<std::shared_ptr<IParameter>> mFields;
280};
281
288QDataStream& operator<<(QDataStream& out, const QVector<std::shared_ptr<INode>>& nodes);
289
296QDataStream& operator>>(QDataStream& in, QVector<std::shared_ptr<INode>>& nodes);
297
304QDataStream& operator<<(QDataStream& out, const QVector<std::shared_ptr<NodeSaveInfo>>& nodes);
305
312QDataStream& operator>>(QDataStream& in, QVector<std::shared_ptr<NodeSaveInfo>>& nodes);
Configuration for a node.
Definition config.h:209
void removeEvent(std::shared_ptr< IFlow > event)
Removes a flow from the node by reference.
Definition node_info.cpp:247
const PropertyInfo * getProperty(const QString &key) const
Gets a property by key.
Definition node_info.cpp:157
QPointF getposition() const override
Gets the position of the node.
Definition node_info.cpp:67
QString getIcon() const
Gets the icon path of the node.
Definition node_info.cpp:87
void setParentId(const QString &arg)
Sets the parent ID of the node.
Definition node_info.cpp:127
QVector< std::shared_ptr< IFlow > > mFlows
A vector of children nodes.
Definition node_info.h:276
void removeProperty(const QString &key)
Removes a property from the node.
Definition node_info.cpp:186
void removeField(const QString &key)
Removes a field from the node.
Definition node_info.cpp:222
NodeSaveInfo()
Constructs a new NodeSaveInfo object.
Definition node_info.cpp:15
QVector< std::shared_ptr< IParameter > > getproperties() const override
Gets the properties of the node.
Definition node_info.cpp:97
static NodeSaveInfo fromJson(const QJsonObject &data)
Creates a NodeSaveInfo object from a JSON object.
Definition node_info.cpp:319
void addFlow(std::shared_ptr< IFlow > flow)
Adds a flow to the node.
Definition node_info.cpp:227
QPointF mPosition
The parent ID of the node.
Definition node_info.h:267
void setPixmap(const QPixmap &arg)
Sets the pixmap of the node.
Definition node_info.cpp:137
void addField(std::shared_ptr< IParameter > property)
Adds a field to the node.
Definition node_info.cpp:217
QSizeF getSize() const
Gets the size of the node.
Definition node_info.cpp:77
void setNodeId(const QString &arg)
Sets the node ID.
Definition node_info.cpp:122
PropertyInfo getField(const QString &key) const
Gets a field by key.
Definition node_info.cpp:192
void setScale(qreal arg)
Sets the scale of the node.
Definition node_info.cpp:152
QVector< std::shared_ptr< INode > > mChildren
A vector of properties for the node.
Definition node_info.h:275
qreal getScale() const
Gets the scale of the node.
Definition node_info.cpp:72
QVector< std::shared_ptr< IParameter > > mProperties
The icon path of the node.
Definition node_info.h:274
void addEvent(std::shared_ptr< IFlow > event)
Adds a flow to the node.
Definition node_info.cpp:242
void setId(const QString &arg)
Sets the ID of the node.
Definition node_info.cpp:117
void addChild(std::shared_ptr< INode > child)
Adds a child to the node.
Definition node_info.cpp:252
QVector< std::shared_ptr< IFlow > > getevents() const override
Gets the events of the node.
Definition node_info.cpp:107
void setIcon(const QString &iconPath)
Sets the icon path of the node.
Definition node_info.cpp:142
void addProperty(std::shared_ptr< PropertyInfo > parameter)
Adds a property to the node.
Definition node_info.cpp:166
QString getnodeId() const override
Gets the node ID.
Definition node_info.cpp:57
qreal mScale
The size of the node.
Definition node_info.h:269
void removeFlow(std::shared_ptr< IFlow > flow)
Removes a flow from the node by reference.
Definition node_info.cpp:232
QPixmap mPixmap
The scale of the node.
Definition node_info.h:271
void setField(const QString &key, std::shared_ptr< IParameter > property)
Sets a field for the node.
Definition node_info.cpp:201
QString getid() const override
Gets the ID of the node.
Definition node_info.cpp:52
void setSize(const QSizeF &arg)
Sets the size of the node.
Definition node_info.cpp:147
QSizeF mSize
The position of the node.
Definition node_info.h:268
QString mParentId
The node ID.
Definition node_info.h:265
QString mNodeId
The ID of the node.
Definition node_info.h:264
void setPosition(const QPointF &arg)
Sets the position of the node.
Definition node_info.cpp:132
QVector< std::shared_ptr< IFlow > > getflows() const override
Gets the flows of the node.
Definition node_info.cpp:102
QVector< std::shared_ptr< ITransition > > mTransitions
A vector of flows associated with the node.
Definition node_info.h:278
QVector< std::shared_ptr< IParameter > > getfields() const override
Gets the fields of the node.
Definition node_info.cpp:92
QVector< std::shared_ptr< INode > > getchildren() const override
Gets the children of the node.
Definition node_info.cpp:112
QVector< std::shared_ptr< IParameter > > mFields
A vector of transitions for the node.
Definition node_info.h:279
QVector< std::shared_ptr< IFlow > > mEvents
A vector of flows associated with the node.
Definition node_info.h:277
QJsonObject toJson() const
Converts the node to a JSON object.
Definition node_info.cpp:269
QString mIconPath
The pixmap of the node.
Definition node_info.h:272
QPixmap getPixmap() const
Gets the pixmap of the node.
Definition node_info.cpp:82
void removeChild(const QString &childId)
Removes a child from the node by ID.
Definition node_info.cpp:257
QString getparentId() const override
Gets the parent ID of the node.
Definition node_info.cpp:62
void clearChildren()
Clears all children from the node.
Definition node_info.cpp:262
Represents a property with configuration and options.
Definition property_info.h:16