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
7QT_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
17class QOpcUaAddNodeItemData : public QSharedData
18{
19public:
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
29QOpcUaAddNodeItem::QOpcUaAddNodeItem()
30 : data(new QOpcUaAddNodeItemData)
31{
32}
33
34/*!
35 Constructs a add node item from \a other.
36*/
37QOpcUaAddNodeItem::QOpcUaAddNodeItem(const QOpcUaAddNodeItem &other)
38 : data(other.data)
39{
40}
41
42/*!
43 Assigns the values from \a rhs to this add node item.
44*/
45QOpcUaAddNodeItem &QOpcUaAddNodeItem::operator=(const QOpcUaAddNodeItem &rhs)
46{
47 if (this != &rhs)
48 data.operator=(o: rhs.data);
49 return *this;
50}
51
52QOpcUaAddNodeItem::~QOpcUaAddNodeItem()
53{
54}
55
56/*!
57 Returns the node id of the type definition node.
58*/
59QOpcUaExpandedNodeId QOpcUaAddNodeItem::typeDefinition() const
60{
61 return data->typeDefinition;
62}
63
64/*!
65 Sets the node id of the type definition node to \a typeDefinition. This value shall be set if the node class
66 is not Object or Variable.
67*/
68void QOpcUaAddNodeItem::setTypeDefinition(const QOpcUaExpandedNodeId &typeDefinition)
69{
70 data->typeDefinition = typeDefinition;
71}
72
73/*!
74 Returns the values for the node attributes of the new node.
75*/
76QOpcUaNodeCreationAttributes QOpcUaAddNodeItem::nodeAttributes() const
77{
78 return data->nodeAttributes;
79}
80
81/*!
82 Returns a reference to the values for the node attributes of the new node.
83*/
84QOpcUaNodeCreationAttributes &QOpcUaAddNodeItem::nodeAttributesRef()
85{
86 return data->nodeAttributes;
87}
88
89/*!
90 Sets the values for the node attributes of the new node to \a nodeAttributes.
91 Only the attributes supported by the node class of the new node will be used.
92*/
93void QOpcUaAddNodeItem::setNodeAttributes(const QOpcUaNodeCreationAttributes &nodeAttributes)
94{
95 data->nodeAttributes = nodeAttributes;
96}
97
98/*!
99 Returns the node class of the new node.
100*/
101QOpcUa::NodeClass QOpcUaAddNodeItem::nodeClass() const
102{
103 return data->nodeClass;
104}
105
106/*!
107 Sets the node class of the new node to \a nodeClass.
108*/
109void QOpcUaAddNodeItem::setNodeClass(const QOpcUa::NodeClass &nodeClass)
110{
111 data->nodeClass = nodeClass;
112}
113
114/*!
115 Returns the browse name of the new node.
116*/
117QOpcUaQualifiedName QOpcUaAddNodeItem::browseName() const
118{
119 return data->browseName;
120}
121
122/*!
123 Sets the browse name of the new node to \a browseName.
124*/
125void QOpcUaAddNodeItem::setBrowseName(const QOpcUaQualifiedName &browseName)
126{
127 data->browseName = browseName;
128}
129
130/*!
131 Returns the requested new node id.
132*/
133QOpcUaExpandedNodeId QOpcUaAddNodeItem::requestedNewNodeId() const
134{
135 return data->requestedNewNodeId;
136}
137
138/*!
139 Sets the requested new node id to \a requestedNewNodeId.
140*/
141void QOpcUaAddNodeItem::setRequestedNewNodeId(const QOpcUaExpandedNodeId &requestedNewNodeId)
142{
143 data->requestedNewNodeId = requestedNewNodeId;
144}
145
146/*!
147 Returns the reference type id.
148*/
149QString QOpcUaAddNodeItem::referenceTypeId() const
150{
151 return data->referenceTypeId;
152}
153
154/*!
155 Sets the reference type id to \a referenceTypeId. A reference of this type will be used to connect
156 the node to the parent node.
157*/
158void QOpcUaAddNodeItem::setReferenceTypeId(const QString &referenceTypeId)
159{
160 data->referenceTypeId = referenceTypeId;
161}
162
163/*!
164 Returns the parent node id.
165*/
166QOpcUaExpandedNodeId QOpcUaAddNodeItem::parentNodeId() const
167{
168 return data->parentNodeId;
169}
170
171/*!
172 Sets the parent node id to \a parentNodeId. A reference of the type set in \l setReferenceTypeId()
173 from this node to the newly added node will be created.
174
175 \sa setReferenceTypeId()
176*/
177void QOpcUaAddNodeItem::setParentNodeId(const QOpcUaExpandedNodeId &parentNodeId)
178{
179 data->parentNodeId = parentNodeId;
180}
181
182QT_END_NAMESPACE
183

source code of qtopcua/src/opcua/client/qopcuaaddnodeitem.cpp