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 part 4, 7.4.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
29QOpcUaAttributeOperand::QOpcUaAttributeOperand()
30 : data(new QOpcUaAttributeOperandData)
31{
32}
33
34/*!
35 Constructs an attribute operand from \a rhs.
36*/
37QOpcUaAttributeOperand::QOpcUaAttributeOperand(const QOpcUaAttributeOperand &rhs)
38 : data(rhs.data)
39{
40}
41
42/*!
43 Sets the values from \a rhs in this attribute operand.
44*/
45QOpcUaAttributeOperand &QOpcUaAttributeOperand::operator=(const QOpcUaAttributeOperand &rhs)
46{
47 if (this != &rhs)
48 data.operator=(o: rhs.data);
49 return *this;
50}
51
52/*!
53 Converts this attribute operand to \l QVariant.
54*/
55QOpcUaAttributeOperand::operator QVariant() const
56{
57 return QVariant::fromValue(value: *this);
58}
59
60QOpcUaAttributeOperand::~QOpcUaAttributeOperand()
61{
62}
63
64/*!
65 Returns the index range string.
66*/
67QString QOpcUaAttributeOperand::indexRange() const
68{
69 return data->indexRange;
70}
71
72/*!
73 Sets the index range string used to identify a single value or subset of the attribute's value to \a indexRange.
74*/
75void QOpcUaAttributeOperand::setIndexRange(const QString &indexRange)
76{
77 data->indexRange = indexRange;
78}
79
80/*!
81 Returns the attribute id for an attribute of the node \l browsePath is pointing to.
82*/
83QOpcUa::NodeAttribute QOpcUaAttributeOperand::attributeId() const
84{
85 return data->attributeId;
86}
87
88/*!
89 Sets the attribute id to \a attributeId.
90*/
91void QOpcUaAttributeOperand::setAttributeId(QOpcUa::NodeAttribute attributeId)
92{
93 data->attributeId = attributeId;
94}
95
96/*!
97 Returns the browse path.
98*/
99QList<QOpcUaRelativePathElement> QOpcUaAttributeOperand::browsePath() const
100{
101 return data->browsePath;
102}
103
104/*!
105 Returns a reference to the browse path.
106
107 \sa browsePath()
108*/
109QList<QOpcUaRelativePathElement> &QOpcUaAttributeOperand::browsePathRef()
110{
111 return data->browsePath;
112}
113
114/*!
115 Sets the relative path to a node starting from \l nodeId() to \a browsePath.
116*/
117void QOpcUaAttributeOperand::setBrowsePath(const QList<QOpcUaRelativePathElement> &browsePath)
118{
119 data->browsePath = browsePath;
120}
121
122/*!
123 Returns the alias for this QAttributeOperand.
124*/
125QString QOpcUaAttributeOperand::alias() const
126{
127 return data->alias;
128}
129
130/*!
131 Sets the alias to \a alias. This allows using this instance
132 as operand for other operations in the filter.
133*/
134void QOpcUaAttributeOperand::setAlias(const QString &alias)
135{
136 data->alias = alias;
137}
138
139/*!
140 Returns the node id of the type definition node.
141*/
142QString QOpcUaAttributeOperand::nodeId() const
143{
144 return data->nodeId;
145}
146
147/*!
148 Sets the node id of the type definition node to \a nodeId.
149*/
150void QOpcUaAttributeOperand::setNodeId(const QString &nodeId)
151{
152 data->nodeId = nodeId;
153}
154
155QT_END_NAMESPACE
156

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