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 "qopcuareaditem.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class QOpcUaReadItem
10 \inmodule QtOpcUa
11 \brief This class stores the options for a read operation.
12
13 A read operation on an OPC UA server returns the entire value or a certain index range of the value of an
14 attribute of a node on the server. This class contains the necessary information for the backend to make
15 a read request to the server.
16
17 One or multiple objects of this class make up the request of a \l QOpcUaClient::readNodeAttributes() operation.
18
19 \sa QOpcUaClient::readNodeAttributes() QOpcUaReadResult
20*/
21
22class QOpcUaReadItemData : public QSharedData
23{
24public:
25 QString nodeId;
26 QOpcUa::NodeAttribute attribute {QOpcUa::NodeAttribute::Value};
27 QString indexRange;
28};
29
30/*!
31 Default constructs a read item with no parameters set.
32*/
33QOpcUaReadItem::QOpcUaReadItem()
34 : data(new QOpcUaReadItemData)
35{
36
37}
38
39/*!
40 Constructs a read item from \a other.
41*/
42QOpcUaReadItem::QOpcUaReadItem(const QOpcUaReadItem &other)
43 : data(other.data)
44{
45}
46
47/*!
48 Constructs a read item for the index range \a indexRange of the attribute \a attr of node \a nodeId.
49*/
50QOpcUaReadItem::QOpcUaReadItem(const QString &nodeId, QOpcUa::NodeAttribute attr, const QString &indexRange)
51 : data(new QOpcUaReadItemData)
52{
53 setNodeId(nodeId);
54 setAttribute(attr);
55 setIndexRange(indexRange);
56}
57
58/*!
59 Sets the values from \a rhs in this read item.
60*/
61QOpcUaReadItem &QOpcUaReadItem::operator=(const QOpcUaReadItem &rhs)
62{
63 if (this != &rhs)
64 data.operator=(o: rhs.data);
65 return *this;
66}
67
68QOpcUaReadItem::~QOpcUaReadItem()
69{
70}
71
72/*!
73 Returns the index range.
74*/
75QString QOpcUaReadItem::indexRange() const
76{
77 return data->indexRange;
78}
79
80/*!
81 Sets the index range to \a indexRange.
82*/
83void QOpcUaReadItem::setIndexRange(const QString &indexRange)
84{
85 data->indexRange = indexRange;
86}
87
88/*!
89 Returns the node attribute id.
90*/
91QOpcUa::NodeAttribute QOpcUaReadItem::attribute() const
92{
93 return data->attribute;
94}
95
96/*!
97 Sets the node attribute id to \a attribute.
98*/
99void QOpcUaReadItem::setAttribute(QOpcUa::NodeAttribute attribute)
100{
101 data->attribute = attribute;
102}
103
104/*!
105 Returns the node id.
106*/
107QString QOpcUaReadItem::nodeId() const
108{
109 return data->nodeId;
110}
111
112/*!
113 Sets the node id to \a nodeId.
114*/
115void QOpcUaReadItem::setNodeId(const QString &nodeId)
116{
117 data->nodeId = nodeId;
118}
119
120/*!
121 \fn bool QOpcUaReadItem::operator==(const QOpcUaReadItem &lhs, const QOpcUaReadItem &rhs)
122
123 Returns \c true if \a lhs is equal to \a rhs; otherwise returns \c false.
124
125 Two read items are considered equal if their \c nodeId, \c attribute, and \c indexRange are
126 equal.
127*/
128bool operator==(const QOpcUaReadItem &lhs, const QOpcUaReadItem &rhs) noexcept
129{
130 return lhs.data->nodeId == rhs.data->nodeId &&
131 lhs.data->attribute == rhs.data->attribute &&
132 lhs.data->indexRange == rhs.data->indexRange;
133}
134
135/*!
136 \fn bool QOpcUaReadItem::operator!=(const QOpcUaReadItem &lhs, const QOpcUaReadItem &rhs)
137
138 Returns \c true if \a lhs is not equal to \a rhs; otherwise returns \c false.
139
140 Two read items are considered not equal if their \c nodeId, \c attribute or \c indexRange are
141 not equal.
142*/
143
144QT_END_NAMESPACE
145

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

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