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 "qopcuasimpleattributeoperand.h" |
5 | #include "qopcuaqualifiedname.h" |
6 | |
7 | QT_BEGIN_NAMESPACE |
8 | |
9 | /*! |
10 | \class QOpcUaSimpleAttributeOperand |
11 | \inmodule QtOpcUa |
12 | \brief The OPC UA SimpleAttributeOperand type. |
13 | |
14 | The SimpleAttributeOperand is specified in OPC UA 1.05 part 4, 7.7.4.5. |
15 | It is used when a node attribute is required as operand. |
16 | |
17 | For example, the following simple attribute operand represents the value |
18 | of the "Severity" field of the base event type: |
19 | \code |
20 | QOpcUaSimpleAttributeOperand("Severity"); |
21 | \endcode |
22 | */ |
23 | class QOpcUaSimpleAttributeOperandData : public QSharedData |
24 | { |
25 | public: |
26 | QString typeId{QStringLiteral("ns=0;i=2041")}; // BaseEventType |
27 | QList<QOpcUaQualifiedName> browsePath; |
28 | QOpcUa::NodeAttribute attributeId {QOpcUa::NodeAttribute::Value}; |
29 | QString indexRange; |
30 | }; |
31 | |
32 | /*! |
33 | Default constructs a simple attribute operand with no parameters set. |
34 | */ |
35 | QOpcUaSimpleAttributeOperand::QOpcUaSimpleAttributeOperand() |
36 | : data(new QOpcUaSimpleAttributeOperandData) |
37 | { |
38 | } |
39 | |
40 | /*! |
41 | Constructs a simple attribute operand from \a rhs. |
42 | */ |
43 | QOpcUaSimpleAttributeOperand::QOpcUaSimpleAttributeOperand(const QOpcUaSimpleAttributeOperand &rhs) |
44 | : data(rhs.data) |
45 | { |
46 | } |
47 | |
48 | /*! |
49 | Constructs a simple attribute operand for attribute \a attributeId of the direct child with the browse name |
50 | \a name in namespace \a namespaceIndex. \a typeId is the node id of a type definition node. The operand will |
51 | be restricted to instances of type \a typeId or a subtype. |
52 | */ |
53 | QOpcUaSimpleAttributeOperand::QOpcUaSimpleAttributeOperand(const QString &name, quint16 namespaceIndex, const QString &typeId, QOpcUa::NodeAttribute attributeId) |
54 | : data(new QOpcUaSimpleAttributeOperandData) |
55 | { |
56 | browsePathRef().append(t: QOpcUaQualifiedName(namespaceIndex, name)); |
57 | setTypeId(typeId); |
58 | setAttributeId(attributeId); |
59 | } |
60 | |
61 | /*! |
62 | Constructs a simple attribute operand for the attribute \a attributeId of an object or variable of type \a typeId. |
63 | This can be used for requesting the ConditionId in an event filter as described in OPC UA 1.05 part 9, 5.5.2. |
64 | */ |
65 | QOpcUaSimpleAttributeOperand::QOpcUaSimpleAttributeOperand(QOpcUa::NodeAttribute attributeId, const QString &typeId) |
66 | : data(new QOpcUaSimpleAttributeOperandData) |
67 | { |
68 | setTypeId(typeId); |
69 | setAttributeId(attributeId); |
70 | } |
71 | |
72 | /*! |
73 | Sets the values from \a rhs in this simple attribute operand. |
74 | */ |
75 | QOpcUaSimpleAttributeOperand &QOpcUaSimpleAttributeOperand::operator=(const QOpcUaSimpleAttributeOperand &rhs) |
76 | { |
77 | if (this != &rhs) |
78 | data.operator=(o: rhs.data); |
79 | return *this; |
80 | } |
81 | |
82 | /*! |
83 | \fn bool QOpcUaSimpleAttributeOperand::operator==(const QOpcUaSimpleAttributeOperand &lhs, |
84 | const QOpcUaSimpleAttributeOperand &rhs) |
85 | |
86 | Returns \c true if \a lhs has the same value as \a rhs. |
87 | */ |
88 | bool comparesEqual(const QOpcUaSimpleAttributeOperand &lhs, |
89 | const QOpcUaSimpleAttributeOperand &rhs) noexcept |
90 | { |
91 | return lhs.attributeId() == rhs.attributeId() && rhs.browsePath() == rhs.browsePath() && |
92 | lhs.indexRange() == rhs.indexRange() && lhs.typeId() == rhs.typeId(); |
93 | } |
94 | |
95 | /*! |
96 | Converts this simple attribute operand to \l QVariant. |
97 | */ |
98 | QOpcUaSimpleAttributeOperand::operator QVariant() const |
99 | { |
100 | return QVariant::fromValue(value: *this); |
101 | } |
102 | |
103 | QOpcUaSimpleAttributeOperand::~QOpcUaSimpleAttributeOperand() |
104 | { |
105 | } |
106 | |
107 | /*! |
108 | Returns the index range string. |
109 | */ |
110 | QString QOpcUaSimpleAttributeOperand::indexRange() const |
111 | { |
112 | return data->indexRange; |
113 | } |
114 | |
115 | /*! |
116 | Sets the index range string used to identify a single value or subset of the attribute's value to \a indexRange. |
117 | */ |
118 | void QOpcUaSimpleAttributeOperand::setIndexRange(const QString &indexRange) |
119 | { |
120 | data->indexRange = indexRange; |
121 | } |
122 | |
123 | /*! |
124 | Returns the attribute of the node \l browsePath is pointing to. |
125 | */ |
126 | QOpcUa::NodeAttribute QOpcUaSimpleAttributeOperand::attributeId() const |
127 | { |
128 | return data->attributeId; |
129 | } |
130 | |
131 | /*! |
132 | Sets the attribute id to \a attributeId. |
133 | */ |
134 | void QOpcUaSimpleAttributeOperand::setAttributeId(QOpcUa::NodeAttribute attributeId) |
135 | { |
136 | data->attributeId = attributeId; |
137 | } |
138 | |
139 | /*! |
140 | Returns the relative path to a node starting from \l typeId. |
141 | */ |
142 | QList<QOpcUaQualifiedName> QOpcUaSimpleAttributeOperand::browsePath() const |
143 | { |
144 | return data->browsePath; |
145 | } |
146 | |
147 | /*! |
148 | Returns a reference to the browse path. |
149 | |
150 | \sa browsePath() |
151 | */ |
152 | QList<QOpcUaQualifiedName> &QOpcUaSimpleAttributeOperand::browsePathRef() |
153 | { |
154 | return data->browsePath; |
155 | } |
156 | |
157 | /*! |
158 | Sets the browse path to the node holding the attribute to \a browsePath. |
159 | */ |
160 | void QOpcUaSimpleAttributeOperand::setBrowsePath(const QList<QOpcUaQualifiedName> &browsePath) |
161 | { |
162 | data->browsePath = browsePath; |
163 | } |
164 | |
165 | /*! |
166 | Returns the node id of a type definition node. |
167 | */ |
168 | QString QOpcUaSimpleAttributeOperand::typeId() const |
169 | { |
170 | return data->typeId; |
171 | } |
172 | |
173 | /*! |
174 | Sets the node id of the type definition node to \a typeId. The operand will be of the type or one of its subtypes. |
175 | */ |
176 | void QOpcUaSimpleAttributeOperand::setTypeId(const QString &typeId) |
177 | { |
178 | data->typeId = typeId; |
179 | } |
180 | |
181 | /*! |
182 | \fn bool QOpcUaSimpleAttributeOperand::operator!=(const QOpcUaSimpleAttributeOperand &lhs, |
183 | const QOpcUaSimpleAttributeOperand &rhs) |
184 | \since 6.7 |
185 | |
186 | Returns \c true if \a lhs has a different value than \a rhs. |
187 | */ |
188 | |
189 | QT_END_NAMESPACE |
190 |
Definitions
- QOpcUaSimpleAttributeOperandData
- QOpcUaSimpleAttributeOperand
- QOpcUaSimpleAttributeOperand
- QOpcUaSimpleAttributeOperand
- QOpcUaSimpleAttributeOperand
- operator=
- comparesEqual
- operator QVariant
- ~QOpcUaSimpleAttributeOperand
- indexRange
- setIndexRange
- attributeId
- setAttributeId
- browsePath
- browsePathRef
- setBrowsePath
- typeId
Learn to use CMake with our Intro Training
Find out more