1 | // Copyright (C) 2023 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 <QtOpcUa/qopcuadiagnosticinfo.h> |
5 | |
6 | #include <QtCore/qvariant.h> |
7 | |
8 | QT_BEGIN_NAMESPACE |
9 | |
10 | /*! |
11 | \class QOpcUaDiagnosticInfo |
12 | \inmodule QtOpcUa |
13 | \since 6.7 |
14 | |
15 | \brief The QOpcUaDiagnosticInfo class models the OPC UA built-in type DiagnosticInfo. |
16 | |
17 | The DiagnosticInfo type is used to convey diagnostics for some operations |
18 | on the server. The \l qint32 type members refer to an index in the stringTable |
19 | field of the OPC UA response header which is currently not supported by |
20 | Qt OPC UA. |
21 | */ |
22 | |
23 | class QOpcUaDiagnosticInfoData : public QSharedData |
24 | { |
25 | public: |
26 | qint32 symbolicId = 0; |
27 | bool hasSymbolicId = false; |
28 | qint32 namespaceUri = 0; |
29 | bool hasNamespaceUri = false; |
30 | qint32 locale = 0; |
31 | bool hasLocale = false; |
32 | qint32 localizedText = 0; |
33 | bool hasLocalizedText = false; |
34 | QString additionalInfo; |
35 | bool hasAdditionalInfo = false; |
36 | QOpcUa::UaStatusCode innerStatusCode = QOpcUa::UaStatusCode::Good; |
37 | bool hasInnerStatusCode = false; |
38 | std::optional<QOpcUaDiagnosticInfo> innerDiagnosticInfo; |
39 | bool hasInnerDiagnosticInfo = false; |
40 | }; |
41 | |
42 | QT_DEFINE_QESDP_SPECIALIZATION_DTOR(QOpcUaDiagnosticInfoData) |
43 | |
44 | /*! |
45 | Constructs a diagnostic info. |
46 | */ |
47 | QOpcUaDiagnosticInfo::QOpcUaDiagnosticInfo() |
48 | : data(new QOpcUaDiagnosticInfoData()) |
49 | { |
50 | } |
51 | |
52 | /*! |
53 | Destroys this diagnostic info object. |
54 | */ |
55 | QOpcUaDiagnosticInfo::~QOpcUaDiagnosticInfo() |
56 | { |
57 | } |
58 | |
59 | /*! |
60 | Constructs a diagnostic info from \a other. |
61 | */ |
62 | QOpcUaDiagnosticInfo::QOpcUaDiagnosticInfo(const QOpcUaDiagnosticInfo &other) |
63 | : data(other.data) |
64 | { |
65 | } |
66 | |
67 | /*! |
68 | Sets the value of \a rhs in this diagnostic info. |
69 | */ |
70 | QOpcUaDiagnosticInfo &QOpcUaDiagnosticInfo::operator=(const QOpcUaDiagnosticInfo &rhs) |
71 | { |
72 | if (this != &rhs) |
73 | this->data = rhs.data; |
74 | |
75 | return *this; |
76 | } |
77 | |
78 | /*! |
79 | \fn QOpcUaDiagnosticInfo::QOpcUaDiagnosticInfo(QOpcUaDiagnosticInfo &&other) |
80 | |
81 | Move-constructs a new diagnostic info from \a other. |
82 | |
83 | \note The moved-from object \a other is placed in a |
84 | partially-formed state, in which the only valid operations are |
85 | destruction and assignment of a new value. |
86 | */ |
87 | |
88 | /*! |
89 | \fn QOpcUaDiagnosticInfo &QOpcUaDiagnosticInfo::operator=(QOpcUaDiagnosticInfo &&other) |
90 | |
91 | Move-assigns \a other to this QOpcUaDiagnosticInfo instance. |
92 | |
93 | \note The moved-from object \a other is placed in a |
94 | partially-formed state, in which the only valid operations are |
95 | destruction and assignment of a new value. |
96 | */ |
97 | |
98 | /*! |
99 | \fn void QOpcUaDiagnosticInfo::swap(QOpcUaDiagnosticInfo &other) |
100 | |
101 | Swaps diagnostic info object \a other with this diagnostic info |
102 | object. This operation is very fast and never fails. |
103 | */ |
104 | |
105 | /*! |
106 | \fn bool QOpcUaDiagnosticInfo::operator!=(const QOpcUaDiagnosticInfo &lhs, const QOpcUaDiagnosticInfo &rhs) |
107 | |
108 | Returns \c true if \a lhs is not equal to \a rhs. |
109 | */ |
110 | |
111 | /*! |
112 | \fn bool QOpcUaDiagnosticInfo::operator==(const QOpcUaDiagnosticInfo &lhs, const QOpcUaDiagnosticInfo &rhs) |
113 | |
114 | Returns \c true if \a lhs is equal to \a rhs. |
115 | */ |
116 | bool comparesEqual(const QOpcUaDiagnosticInfo &lhs, const QOpcUaDiagnosticInfo &rhs) noexcept |
117 | { |
118 | if (lhs.hasSymbolicId() != rhs.hasSymbolicId() || |
119 | (lhs.hasSymbolicId() && lhs.symbolicId() != rhs.symbolicId())) |
120 | return false; |
121 | |
122 | if (lhs.hasNamespaceUri() != rhs.hasNamespaceUri() || |
123 | (lhs.hasNamespaceUri() && lhs.namespaceUri() != rhs.namespaceUri())) |
124 | return false; |
125 | |
126 | if (lhs.hasLocale() != lhs.hasLocale() || |
127 | (lhs.hasLocale() && lhs.locale() != rhs.locale())) |
128 | return false; |
129 | |
130 | if (lhs.hasLocalizedText() != rhs.hasLocalizedText() || |
131 | (lhs.hasLocalizedText() && lhs.localizedText() != rhs.localizedText())) |
132 | return false; |
133 | |
134 | if (lhs.hasAdditionalInfo() != lhs.hasAdditionalInfo() || |
135 | (lhs.hasAdditionalInfo() && lhs.additionalInfo() != rhs.additionalInfo())) |
136 | return false; |
137 | |
138 | if (lhs.hasInnerStatusCode() != lhs.hasInnerStatusCode() || |
139 | (lhs.hasInnerStatusCode() && lhs.innerStatusCode() != rhs.innerStatusCode())) |
140 | return false; |
141 | |
142 | if (lhs.hasInnerDiagnosticInfo() != lhs.hasInnerDiagnosticInfo() |
143 | || (lhs.hasInnerDiagnosticInfo() |
144 | && lhs.data->innerDiagnosticInfo != rhs.data->innerDiagnosticInfo)) |
145 | return false; |
146 | |
147 | return true; |
148 | } |
149 | |
150 | /*! |
151 | Returns a \l QVariant containing this diagnostic info. |
152 | */ |
153 | QOpcUaDiagnosticInfo::operator QVariant() const |
154 | { |
155 | return QVariant::fromValue(value: *this); |
156 | } |
157 | |
158 | /*! |
159 | Returns the symbolic id of this diagnostic info. |
160 | */ |
161 | qint32 QOpcUaDiagnosticInfo::symbolicId() const |
162 | { |
163 | return data->symbolicId; |
164 | } |
165 | |
166 | /*! |
167 | Sets the symbolic id of this diagnostic info to \a newSymbolicId. |
168 | */ |
169 | void QOpcUaDiagnosticInfo::setSymbolicId(qint32 newSymbolicId) |
170 | { |
171 | if (newSymbolicId != data->symbolicId) { |
172 | data.detach(); |
173 | data->symbolicId = newSymbolicId; |
174 | } |
175 | } |
176 | |
177 | /*! |
178 | Returns \c true if this diagnostic info has a symbolic id. |
179 | */ |
180 | bool QOpcUaDiagnosticInfo::hasSymbolicId() const |
181 | { |
182 | return data->hasSymbolicId; |
183 | } |
184 | |
185 | /*! |
186 | Sets the information whether this diagnostic info has a symbolic id to \a newHasSymbolicId. |
187 | */ |
188 | void QOpcUaDiagnosticInfo::setHasSymbolicId(bool newHasSymbolicId) |
189 | { |
190 | if (newHasSymbolicId != data->hasSymbolicId) { |
191 | data.detach(); |
192 | data->hasSymbolicId = newHasSymbolicId; |
193 | } |
194 | } |
195 | |
196 | /*! |
197 | Returns the namespace URI of this diagnostic info. |
198 | */ |
199 | qint32 QOpcUaDiagnosticInfo::namespaceUri() const |
200 | { |
201 | return data->namespaceUri; |
202 | } |
203 | |
204 | /*! |
205 | Sets the namespace URI of this diagnostic info to \a newNamespaceUri. |
206 | */ |
207 | void QOpcUaDiagnosticInfo::setNamespaceUri(qint32 newNamespaceUri) |
208 | { |
209 | if (newNamespaceUri != data->namespaceUri) { |
210 | data.detach(); |
211 | data->namespaceUri = newNamespaceUri; |
212 | } |
213 | } |
214 | |
215 | /*! |
216 | Returns \c true if this diagnostic info has a namespace URI. |
217 | */ |
218 | bool QOpcUaDiagnosticInfo::hasNamespaceUri() const |
219 | { |
220 | return data->hasNamespaceUri; |
221 | } |
222 | |
223 | /*! |
224 | Sets the information whether this diagnostic info has a namespace URI to \a newHasNamespaceUri. |
225 | */ |
226 | void QOpcUaDiagnosticInfo::setHasNamespaceUri(bool newHasNamespaceUri) |
227 | { |
228 | if (newHasNamespaceUri != data->hasNamespaceUri) { |
229 | data.detach(); |
230 | data->hasNamespaceUri = newHasNamespaceUri; |
231 | } |
232 | } |
233 | |
234 | /*! |
235 | Returns the locale of this diagnostic info. |
236 | */ |
237 | qint32 QOpcUaDiagnosticInfo::locale() const |
238 | { |
239 | return data->locale; |
240 | } |
241 | |
242 | /*! |
243 | Sets the locale of this diagnostic info to \a newLocale. |
244 | */ |
245 | void QOpcUaDiagnosticInfo::setLocale(qint32 newLocale) |
246 | { |
247 | if (newLocale != data->locale) { |
248 | data.detach(); |
249 | data->locale = newLocale; |
250 | } |
251 | } |
252 | |
253 | /*! |
254 | Returns \c true if this diagnostic info has a locale. |
255 | */ |
256 | bool QOpcUaDiagnosticInfo::hasLocale() const |
257 | { |
258 | return data->hasLocale; |
259 | } |
260 | |
261 | /*! |
262 | Sets the information whether this diagnostic info has a locale to \a newHasLocale. |
263 | */ |
264 | void QOpcUaDiagnosticInfo::setHasLocale(bool newHasLocale) |
265 | { |
266 | if (newHasLocale != data->hasLocale) { |
267 | data.detach(); |
268 | data->hasLocale = newHasLocale; |
269 | } |
270 | } |
271 | |
272 | /*! |
273 | Returns the localized text of this diagnostic info. |
274 | */ |
275 | qint32 QOpcUaDiagnosticInfo::localizedText() const |
276 | { |
277 | return data->localizedText; |
278 | } |
279 | |
280 | /*! |
281 | Sets the localized text of this diagnostic info to \a newLocalizedText. |
282 | */ |
283 | void QOpcUaDiagnosticInfo::setLocalizedText(qint32 newLocalizedText) |
284 | { |
285 | if (newLocalizedText != data->localizedText) { |
286 | data.detach(); |
287 | data->localizedText = newLocalizedText; |
288 | } |
289 | } |
290 | |
291 | /*! |
292 | Returns \c true if this diagnostic info has a localized text. |
293 | */ |
294 | bool QOpcUaDiagnosticInfo::hasLocalizedText() const |
295 | { |
296 | return data->hasLocalizedText; |
297 | } |
298 | |
299 | /*! |
300 | Sets the information whether this diagnostic info has a localized text to \a newHasLocalizedText. |
301 | */ |
302 | void QOpcUaDiagnosticInfo::setHasLocalizedText(bool newHasLocalizedText) |
303 | { |
304 | if (newHasLocalizedText != data->hasLocalizedText) { |
305 | data.detach(); |
306 | data->hasLocalizedText = newHasLocalizedText; |
307 | } |
308 | } |
309 | |
310 | /*! |
311 | Returns the additional information of this diagnostic info. |
312 | */ |
313 | QString QOpcUaDiagnosticInfo::additionalInfo() const |
314 | { |
315 | return data->additionalInfo; |
316 | } |
317 | |
318 | /*! |
319 | Sets the additional information of this diagnostic info to \a newAdditionalInfo. |
320 | */ |
321 | void QOpcUaDiagnosticInfo::setAdditionalInfo(const QString &newAdditionalInfo) |
322 | { |
323 | if (newAdditionalInfo != data->additionalInfo) { |
324 | data.detach(); |
325 | data->additionalInfo = newAdditionalInfo; |
326 | } |
327 | } |
328 | |
329 | /*! |
330 | Returns \c true if this diagnostic info has additional information. |
331 | */ |
332 | bool QOpcUaDiagnosticInfo::hasAdditionalInfo() const |
333 | { |
334 | return data->hasAdditionalInfo; |
335 | } |
336 | |
337 | /*! |
338 | Sets the information whether this diagnostic info has additional information to \a newHasAdditionalInfo. |
339 | */ |
340 | void QOpcUaDiagnosticInfo::setHasAdditionalInfo(bool newHasAdditionalInfo) |
341 | { |
342 | if (newHasAdditionalInfo != data->hasAdditionalInfo) { |
343 | data.detach(); |
344 | data->hasAdditionalInfo = newHasAdditionalInfo; |
345 | } |
346 | } |
347 | |
348 | /*! |
349 | Returns the inner status code of this diagnostic info. |
350 | */ |
351 | QOpcUa::UaStatusCode QOpcUaDiagnosticInfo::innerStatusCode() const |
352 | { |
353 | return data->innerStatusCode; |
354 | } |
355 | |
356 | /*! |
357 | Sets the inner status code of this diagnostic info to \a newInnerStatusCode. |
358 | */ |
359 | void QOpcUaDiagnosticInfo::setInnerStatusCode(QOpcUa::UaStatusCode newInnerStatusCode) |
360 | { |
361 | if (newInnerStatusCode != data->innerStatusCode) { |
362 | data.detach(); |
363 | data->innerStatusCode = newInnerStatusCode; |
364 | } |
365 | } |
366 | |
367 | /*! |
368 | Returns \c true if this diagnostic info has an inner status code. |
369 | */ |
370 | bool QOpcUaDiagnosticInfo::hasInnerStatusCode() const |
371 | { |
372 | return data->hasInnerStatusCode; |
373 | } |
374 | |
375 | /*! |
376 | Sets the information whether this diagnostic info has an inner status code to \a newHasInnerStatusCode. |
377 | */ |
378 | void QOpcUaDiagnosticInfo::setHasInnerStatusCode(bool newHasInnerStatusCode) |
379 | { |
380 | if (newHasInnerStatusCode != data->hasInnerStatusCode) { |
381 | data.detach(); |
382 | data->hasInnerStatusCode = newHasInnerStatusCode; |
383 | } |
384 | } |
385 | |
386 | /*! |
387 | Returns the inner diagnostic info of this diagnostic info. |
388 | */ |
389 | QOpcUaDiagnosticInfo QOpcUaDiagnosticInfo::innerDiagnosticInfo() const |
390 | { |
391 | return data->innerDiagnosticInfo.value_or(u: QOpcUaDiagnosticInfo()); |
392 | } |
393 | |
394 | /*! |
395 | Returns a reference to the inner diagnostic info of this diagnostic info. |
396 | */ |
397 | QOpcUaDiagnosticInfo &QOpcUaDiagnosticInfo::innerDiagnosticInfoRef() |
398 | { |
399 | if (!data->innerDiagnosticInfo.has_value()) { |
400 | data.detach(); |
401 | data->innerDiagnosticInfo = QOpcUaDiagnosticInfo(); |
402 | } |
403 | |
404 | return data->innerDiagnosticInfo.value(); |
405 | } |
406 | |
407 | /*! |
408 | Sets the inner diagnostic info of this diagnostic info to \a newInnerDiagnosticInfo. |
409 | */ |
410 | void QOpcUaDiagnosticInfo::setInnerDiagnosticInfo(const QOpcUaDiagnosticInfo &newInnerDiagnosticInfo) |
411 | { |
412 | if (newInnerDiagnosticInfo != data->innerDiagnosticInfo) { |
413 | data.detach(); |
414 | data->innerDiagnosticInfo = newInnerDiagnosticInfo; |
415 | } |
416 | } |
417 | |
418 | /*! |
419 | Returns \c true if this diagnostic info has an inner diagnostic info. |
420 | */ |
421 | bool QOpcUaDiagnosticInfo::hasInnerDiagnosticInfo() const |
422 | { |
423 | return data->hasInnerDiagnosticInfo; |
424 | } |
425 | |
426 | /*! |
427 | Sets the information whether this diagnostic info has an inner diagnostic info to \a newHasInnerDiagnosticInfo. |
428 | */ |
429 | void QOpcUaDiagnosticInfo::setHasInnerDiagnosticInfo(bool newHasInnerDiagnosticInfo) |
430 | { |
431 | if (newHasInnerDiagnosticInfo != data->hasInnerDiagnosticInfo) { |
432 | data.detach(); |
433 | data->hasInnerDiagnosticInfo = newHasInnerDiagnosticInfo; |
434 | } |
435 | } |
436 | |
437 | QT_END_NAMESPACE |
438 |
Definitions
- QOpcUaDiagnosticInfoData
- QOpcUaDiagnosticInfo
- ~QOpcUaDiagnosticInfo
- QOpcUaDiagnosticInfo
- operator=
- comparesEqual
- operator QVariant
- symbolicId
- setSymbolicId
- hasSymbolicId
- setHasSymbolicId
- namespaceUri
- setNamespaceUri
- hasNamespaceUri
- setHasNamespaceUri
- locale
- setLocale
- hasLocale
- setHasLocale
- localizedText
- setLocalizedText
- hasLocalizedText
- setHasLocalizedText
- additionalInfo
- setAdditionalInfo
- hasAdditionalInfo
- setHasAdditionalInfo
- innerStatusCode
- setInnerStatusCode
- hasInnerStatusCode
- setHasInnerStatusCode
- innerDiagnosticInfo
- innerDiagnosticInfoRef
- setInnerDiagnosticInfo
- hasInnerDiagnosticInfo
Start learning QML with our Intro Training
Find out more