1 | // Copyright (C) 2018 basysKom GmbH, opensource@basyskom.com |
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #include "qopcuanodecreationattributes.h" |
5 | #include "qopcuaaddnodeitem.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | /*! |
10 | \class QOpcUaAddNodeItem |
11 | \inmodule QtOpcUa |
12 | \brief This class stores the necessary information to create a new node on the server. |
13 | |
14 | \sa QOpcUaClient::addNode() |
15 | */ |
16 | |
17 | class QOpcUaAddNodeItemData : public QSharedData |
18 | { |
19 | public: |
20 | QOpcUaExpandedNodeId parentNodeId; |
21 | QString referenceTypeId; |
22 | QOpcUaExpandedNodeId requestedNewNodeId; |
23 | QOpcUaQualifiedName browseName; |
24 | QOpcUa::NodeClass nodeClass {QOpcUa::NodeClass::Object}; |
25 | QOpcUaNodeCreationAttributes nodeAttributes; |
26 | QOpcUaExpandedNodeId typeDefinition; |
27 | }; |
28 | |
29 | /*! |
30 | Default constructs an add node item with no parameters set. |
31 | */ |
32 | QOpcUaAddNodeItem::QOpcUaAddNodeItem() |
33 | : data(new QOpcUaAddNodeItemData) |
34 | { |
35 | } |
36 | |
37 | /*! |
38 | Constructs a add node item from \a other. |
39 | */ |
40 | QOpcUaAddNodeItem::QOpcUaAddNodeItem(const QOpcUaAddNodeItem &other) |
41 | : data(other.data) |
42 | { |
43 | } |
44 | |
45 | /*! |
46 | Assigns the values from \a rhs to this add node item. |
47 | */ |
48 | QOpcUaAddNodeItem &QOpcUaAddNodeItem::operator=(const QOpcUaAddNodeItem &rhs) |
49 | { |
50 | if (this != &rhs) |
51 | data.operator=(o: rhs.data); |
52 | return *this; |
53 | } |
54 | |
55 | QOpcUaAddNodeItem::~QOpcUaAddNodeItem() |
56 | { |
57 | } |
58 | |
59 | /*! |
60 | Returns the node id of the type definition node. |
61 | */ |
62 | QOpcUaExpandedNodeId QOpcUaAddNodeItem::typeDefinition() const |
63 | { |
64 | return data->typeDefinition; |
65 | } |
66 | |
67 | /*! |
68 | Sets the node id of the type definition node to \a typeDefinition. This value shall be set if the node class |
69 | is not Object or Variable. |
70 | */ |
71 | void QOpcUaAddNodeItem::setTypeDefinition(const QOpcUaExpandedNodeId &typeDefinition) |
72 | { |
73 | data->typeDefinition = typeDefinition; |
74 | } |
75 | |
76 | /*! |
77 | Returns the values for the node attributes of the new node. |
78 | */ |
79 | QOpcUaNodeCreationAttributes QOpcUaAddNodeItem::nodeAttributes() const |
80 | { |
81 | return data->nodeAttributes; |
82 | } |
83 | |
84 | /*! |
85 | Returns a reference to the values for the node attributes of the new node. |
86 | */ |
87 | QOpcUaNodeCreationAttributes &QOpcUaAddNodeItem::nodeAttributesRef() |
88 | { |
89 | return data->nodeAttributes; |
90 | } |
91 | |
92 | /*! |
93 | Sets the values for the node attributes of the new node to \a nodeAttributes. |
94 | Only the attributes supported by the node class of the new node will be used. |
95 | */ |
96 | void QOpcUaAddNodeItem::setNodeAttributes(const QOpcUaNodeCreationAttributes &nodeAttributes) |
97 | { |
98 | data->nodeAttributes = nodeAttributes; |
99 | } |
100 | |
101 | /*! |
102 | Returns the node class of the new node. |
103 | */ |
104 | QOpcUa::NodeClass QOpcUaAddNodeItem::nodeClass() const |
105 | { |
106 | return data->nodeClass; |
107 | } |
108 | |
109 | /*! |
110 | Sets the node class of the new node to \a nodeClass. |
111 | */ |
112 | void QOpcUaAddNodeItem::setNodeClass(const QOpcUa::NodeClass &nodeClass) |
113 | { |
114 | data->nodeClass = nodeClass; |
115 | } |
116 | |
117 | /*! |
118 | Returns the browse name of the new node. |
119 | */ |
120 | QOpcUaQualifiedName QOpcUaAddNodeItem::browseName() const |
121 | { |
122 | return data->browseName; |
123 | } |
124 | |
125 | /*! |
126 | Sets the browse name of the new node to \a browseName. |
127 | */ |
128 | void QOpcUaAddNodeItem::setBrowseName(const QOpcUaQualifiedName &browseName) |
129 | { |
130 | data->browseName = browseName; |
131 | } |
132 | |
133 | /*! |
134 | Returns the requested new node id. |
135 | */ |
136 | QOpcUaExpandedNodeId QOpcUaAddNodeItem::requestedNewNodeId() const |
137 | { |
138 | return data->requestedNewNodeId; |
139 | } |
140 | |
141 | /*! |
142 | Sets the requested new node id to \a requestedNewNodeId. |
143 | */ |
144 | void QOpcUaAddNodeItem::setRequestedNewNodeId(const QOpcUaExpandedNodeId &requestedNewNodeId) |
145 | { |
146 | data->requestedNewNodeId = requestedNewNodeId; |
147 | } |
148 | |
149 | /*! |
150 | Returns the reference type id. |
151 | */ |
152 | QString QOpcUaAddNodeItem::referenceTypeId() const |
153 | { |
154 | return data->referenceTypeId; |
155 | } |
156 | |
157 | /*! |
158 | Sets the reference type id to \a referenceTypeId. A reference of this type will be used to connect |
159 | the node to the parent node. |
160 | */ |
161 | void QOpcUaAddNodeItem::setReferenceTypeId(const QString &referenceTypeId) |
162 | { |
163 | data->referenceTypeId = referenceTypeId; |
164 | } |
165 | |
166 | /*! |
167 | Returns the parent node id. |
168 | */ |
169 | QOpcUaExpandedNodeId QOpcUaAddNodeItem::parentNodeId() const |
170 | { |
171 | return data->parentNodeId; |
172 | } |
173 | |
174 | /*! |
175 | Sets the parent node id to \a parentNodeId. A reference of the type set in \l setReferenceTypeId() |
176 | from this node to the newly added node will be created. |
177 | |
178 | \sa setReferenceTypeId() |
179 | */ |
180 | void QOpcUaAddNodeItem::setParentNodeId(const QOpcUaExpandedNodeId &parentNodeId) |
181 | { |
182 | data->parentNodeId = parentNodeId; |
183 | } |
184 | |
185 | QT_END_NAMESPACE |
186 | |