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 "qopcuaeventfilterresult.h"
5#include "qopcuacontentfilterelementresult.h"
6#include <QtCore/qlist.h>
7
8QT_BEGIN_NAMESPACE
9
10/*!
11 \class QOpcUaEventFilterResult
12 \inmodule QtOpcUa
13 \brief The OPCUA EventFilterResult.
14
15 The EventFilterResult contains status codes for all elements of the \c select clauses
16 and all elements of the \c where clause.
17*/
18
19class QOpcUaEventFilterResultData : public QSharedData
20{
21public:
22 QList<QOpcUa::UaStatusCode> selectClauseResults;
23 QList<QOpcUaContentFilterElementResult> whereClauseResults;
24};
25
26QOpcUaEventFilterResult::QOpcUaEventFilterResult()
27 : data(new QOpcUaEventFilterResultData)
28{
29}
30
31/*!
32 Constructs an event filter result from \a rhs.
33*/
34QOpcUaEventFilterResult::QOpcUaEventFilterResult(const QOpcUaEventFilterResult &rhs)
35 : data(rhs.data)
36{
37}
38
39/*!
40 Sets the values from \a rhs in this event filter result.
41*/
42QOpcUaEventFilterResult &QOpcUaEventFilterResult::operator=(const QOpcUaEventFilterResult &rhs)
43{
44 if (this != &rhs)
45 data.operator=(o: rhs.data);
46 return *this;
47}
48
49QOpcUaEventFilterResult::~QOpcUaEventFilterResult()
50{
51}
52
53/*!
54 Returns \c true if this event filter result is good.
55*/
56bool QOpcUaEventFilterResult::isGood() const
57{
58 for (auto status : std::as_const(t: data->selectClauseResults)) {
59 if (status != QOpcUa::UaStatusCode::Good)
60 return false;
61 }
62 for (QOpcUaContentFilterElementResult element : std::as_const(t: data->whereClauseResults)) {
63 if (element.statusCode() != QOpcUa::UaStatusCode::Good)
64 return false;
65 for (auto status : std::as_const(t&: element.operandStatusCodesRef())) {
66 if (status != QOpcUa::UaStatusCode::Good)
67 return false;
68 }
69 }
70
71 return true;
72}
73
74/*!
75 Returns the status codes for all elements of the \c where clause in the order that was used in the filter.
76*/
77QList<QOpcUaContentFilterElementResult> QOpcUaEventFilterResult::whereClauseResults() const
78{
79 return data->whereClauseResults;
80}
81
82/*!
83 Returns a reference to the \c where clause results.
84
85 \sa whereClauseResults()
86*/
87QList<QOpcUaContentFilterElementResult> &QOpcUaEventFilterResult::whereClauseResultsRef()
88{
89 return data->whereClauseResults;
90}
91
92/*!
93 Sets the \c where clause results to \a whereClausesResult.
94*/
95void QOpcUaEventFilterResult::setWhereClauseResults(const QList<QOpcUaContentFilterElementResult> &whereClausesResult)
96{
97 data->whereClauseResults = whereClausesResult;
98}
99
100/*!
101 Returns the status codes for all elements of the \c select clauses in the order that was used in the filter.
102*/
103QList<QOpcUa::UaStatusCode> QOpcUaEventFilterResult::selectClauseResults() const
104{
105 return data->selectClauseResults;
106}
107
108/*!
109 Returns a reference to the \c select clause results.
110
111 \sa selectClauseResults()
112*/
113QList<QOpcUa::UaStatusCode> &QOpcUaEventFilterResult::selectClauseResultsRef()
114{
115 return data->selectClauseResults;
116}
117
118/*!
119 Sets the \c select clause results to \a selectClausesResult.
120*/
121void QOpcUaEventFilterResult::setSelectClauseResults(const QList<QOpcUa::UaStatusCode> &selectClausesResult)
122{
123 data->selectClauseResults = selectClausesResult;
124}
125
126QT_END_NAMESPACE
127

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