1// Copyright (C) 2015 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 "qopcuaattributeoperand.h"
5#include "qopcuarelativepathelement.h"
6#include <QtCore/qlist.h>
7
8QT_BEGIN_NAMESPACE
9
10/*!
11 \class QOpcUaAttributeOperand
12 \inmodule QtOpcUa
13 \brief The OPC UA AttributeOperand type.
14
15 The AttributeOperand is defined in OPC UA 1.05 part 4, 7.7.4.4.
16 It has the same purpose as \l QOpcUaSimpleAttributeOperand but has more configurable options.
17*/
18
19class QOpcUaAttributeOperandData : public QSharedData
20{
21public:
22 QString nodeId;
23 QString alias;
24 QList<QOpcUaRelativePathElement> browsePath;
25 QOpcUa::NodeAttribute attributeId {QOpcUa::NodeAttribute::Value};
26 QString indexRange;
27};
28
29/*!
30 Default constructs an attribute operand with no parameters set.
31*/
32QOpcUaAttributeOperand::QOpcUaAttributeOperand()
33 : data(new QOpcUaAttributeOperandData)
34{
35}
36
37/*!
38 Constructs an attribute operand from \a rhs.
39*/
40QOpcUaAttributeOperand::QOpcUaAttributeOperand(const QOpcUaAttributeOperand &rhs)
41 : data(rhs.data)
42{
43}
44
45/*!
46 Sets the values from \a rhs in this attribute operand.
47*/
48QOpcUaAttributeOperand &QOpcUaAttributeOperand::operator=(const QOpcUaAttributeOperand &rhs)
49{
50 if (this != &rhs)
51 data.operator=(o: rhs.data);
52 return *this;
53}
54
55/*!
56 Converts this attribute operand to \l QVariant.
57*/
58QOpcUaAttributeOperand::operator QVariant() const
59{
60 return QVariant::fromValue(value: *this);
61}
62
63QOpcUaAttributeOperand::~QOpcUaAttributeOperand()
64{
65}
66
67/*!
68 Returns the index range string.
69*/
70QString QOpcUaAttributeOperand::indexRange() const
71{
72 return data->indexRange;
73}
74
75/*!
76 Sets the index range string used to identify a single value or subset of the attribute's value to \a indexRange.
77*/
78void QOpcUaAttributeOperand::setIndexRange(const QString &indexRange)
79{
80 data->indexRange = indexRange;
81}
82
83/*!
84 Returns the attribute id for an attribute of the node \l browsePath is pointing to.
85*/
86QOpcUa::NodeAttribute QOpcUaAttributeOperand::attributeId() const
87{
88 return data->attributeId;
89}
90
91/*!
92 Sets the attribute id to \a attributeId.
93*/
94void QOpcUaAttributeOperand::setAttributeId(QOpcUa::NodeAttribute attributeId)
95{
96 data->attributeId = attributeId;
97}
98
99/*!
100 Returns the browse path.
101*/
102QList<QOpcUaRelativePathElement> QOpcUaAttributeOperand::browsePath() const
103{
104 return data->browsePath;
105}
106
107/*!
108 Returns a reference to the browse path.
109
110 \sa browsePath()
111*/
112QList<QOpcUaRelativePathElement> &QOpcUaAttributeOperand::browsePathRef()
113{
114 return data->browsePath;
115}
116
117/*!
118 Sets the relative path to a node starting from \l nodeId() to \a browsePath.
119*/
120void QOpcUaAttributeOperand::setBrowsePath(const QList<QOpcUaRelativePathElement> &browsePath)
121{
122 data->browsePath = browsePath;
123}
124
125/*!
126 Returns the alias for this QAttributeOperand.
127*/
128QString QOpcUaAttributeOperand::alias() const
129{
130 return data->alias;
131}
132
133/*!
134 Sets the alias to \a alias. This allows using this instance
135 as operand for other operations in the filter.
136*/
137void QOpcUaAttributeOperand::setAlias(const QString &alias)
138{
139 data->alias = alias;
140}
141
142/*!
143 Returns the node id of the type definition node.
144*/
145QString QOpcUaAttributeOperand::nodeId() const
146{
147 return data->nodeId;
148}
149
150/*!
151 Sets the node id of the type definition node to \a nodeId.
152*/
153void QOpcUaAttributeOperand::setNodeId(const QString &nodeId)
154{
155 data->nodeId = nodeId;
156}
157
158/*!
159 \fn bool QOpcUaAttributeOperand::operator==(const QOpcUaAttributeOperand &lhs,
160 const QOpcUaAttributeOperand &rhs)
161 \since 6.7
162
163 Returns \c true if \a lhs has the same value as \a rhs.
164*/
165bool comparesEqual(const QOpcUaAttributeOperand &lhs, const QOpcUaAttributeOperand &rhs) noexcept
166{
167 return lhs.nodeId() == rhs.nodeId() && lhs.attributeId() == rhs.attributeId() &&
168 lhs.alias() == rhs.alias() && lhs.browsePath() == rhs.browsePath() &&
169 lhs.indexRange() == rhs.indexRange();
170}
171
172/*!
173 \fn bool QOpcUaAttributeOperand::operator!=(const QOpcUaAttributeOperand &lhs,
174 const QOpcUaAttributeOperand &rhs)
175 \since 6.7
176
177 Returns \c true if \a lhs has a different value than \a rhs.
178*/
179
180QT_END_NAMESPACE
181

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

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