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 "qopcuaaddreferenceitem.h"
6#include "qopcuaexpandednodeid.h"
7
8QT_BEGIN_NAMESPACE
9
10/*!
11 \class QOpcUaAddReferenceItem
12 \inmodule QtOpcUa
13 \brief This class stores the necessary information to add a new reference on the server.
14
15 \sa QOpcUaClient::addReference()
16*/
17class QOpcUaAddReferenceItemData : public QSharedData
18{
19public:
20 QString sourceNodeId;
21 QString referenceTypeId;
22 bool isForwardReference {true};
23 QOpcUaExpandedNodeId targetNodeId;
24 QOpcUa::NodeClass targetNodeClass {QOpcUa::NodeClass::Undefined};
25 QString targetServerUri;
26};
27
28QOpcUaAddReferenceItem::QOpcUaAddReferenceItem()
29 : data(new QOpcUaAddReferenceItemData)
30{
31}
32
33/*!
34 Constructs an add reference item from \a other.
35*/
36QOpcUaAddReferenceItem::QOpcUaAddReferenceItem(const QOpcUaAddReferenceItem &other)
37 : data(other.data)
38{
39
40}
41
42/*!
43 Sets the values from \a rhs in this add reference item.
44*/
45QOpcUaAddReferenceItem &QOpcUaAddReferenceItem::operator=(const QOpcUaAddReferenceItem &rhs)
46{
47 if (this != &rhs)
48 data.operator=(o: rhs.data);
49 return *this;
50}
51
52QOpcUaAddReferenceItem::~QOpcUaAddReferenceItem()
53{
54}
55
56/*!
57 Returns the target node class.
58*/
59QOpcUa::NodeClass QOpcUaAddReferenceItem::targetNodeClass() const
60{
61 return data->targetNodeClass;
62}
63
64/*!
65 Sets the node class of the target node to \a targetNodeClass.
66 The target node class shall be specified because the target node might be located on another server.
67*/
68void QOpcUaAddReferenceItem::setTargetNodeClass(QOpcUa::NodeClass targetNodeClass)
69{
70 data->targetNodeClass = targetNodeClass;
71}
72
73/*!
74 Returns the target server URI.
75*/
76QString QOpcUaAddReferenceItem::targetServerUri() const
77{
78 return data->targetServerUri;
79}
80
81/*!
82 Sets the URI of the target server to \a targetServerUri.
83 If this value is set, it will override the server URI from \l setTargetNodeId().
84*/
85void QOpcUaAddReferenceItem::setTargetServerUri(const QString &targetServerUri)
86{
87 data->targetServerUri = targetServerUri;
88}
89
90/*!
91 Returns the target node id.
92*/
93QOpcUaExpandedNodeId QOpcUaAddReferenceItem::targetNodeId() const
94{
95 return data->targetNodeId;
96}
97
98/*!
99 Sets the node id of the target node to \a targetNodeId.
100*/
101void QOpcUaAddReferenceItem::setTargetNodeId(const QOpcUaExpandedNodeId &targetNodeId)
102{
103 data->targetNodeId = targetNodeId;
104}
105
106/*!
107 Returns the isForwardReference flag.
108*/
109bool QOpcUaAddReferenceItem::isForwardReference() const
110{
111 return data->isForwardReference;
112}
113
114/*!
115 Sets the isForwardReference flag to \a isForwardReference.
116 If the flag is set, a forward reference is created.
117 Otherwise, an inverse reference is created.
118*/
119void QOpcUaAddReferenceItem::setIsForwardReference(bool isForwardReference)
120{
121 data->isForwardReference = isForwardReference;
122}
123
124/*!
125 Returns the reference type id.
126*/
127QString QOpcUaAddReferenceItem::referenceTypeId() const
128{
129 return data->referenceTypeId;
130}
131
132/*!
133 Sets the reference type id to \a referenceTypeId.
134 A reference of this type will be created on the server.
135*/
136void QOpcUaAddReferenceItem::setReferenceTypeId(const QString &referenceTypeId)
137{
138 data->referenceTypeId = referenceTypeId;
139}
140
141/*!
142 Returns the source node id.
143*/
144QString QOpcUaAddReferenceItem::sourceNodeId() const
145{
146 return data->sourceNodeId;
147}
148
149/*!
150 Sets the node id of the source node to \a sourceNodeId.
151*/
152void QOpcUaAddReferenceItem::setSourceNodeId(const QString &sourceNodeId)
153{
154 data->sourceNodeId = sourceNodeId;
155}
156
157QT_END_NAMESPACE
158

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