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