1// Copyright (C) 2019 The Qt Company Ltd.
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 <private/opcuafilterelement_p.h>
5#include <private/opcuaoperandbase_p.h>
6
7#include <QOpcUaContentFilterElement>
8#include <QLoggingCategory>
9
10QT_BEGIN_NAMESPACE
11
12/*!
13 \qmltype FilterElement
14 \inqmlmodule QtOpcUa
15 \brief The OPC UA ContentFilterElement.
16 \since QtOpcUa 5.13
17 \deprecated [6.9]
18
19 A content filter element contains an operator and operands.
20 There are four different operator types which contain literal values, references to
21 attributes of nodes or to other content filter elements.
22
23 A combination of one or more content filter elements makes a content filter which is used
24 by the server to filter data for the criteria defined by the content filter elements.
25 For example, the \c where clause of an event filter is a content filter which is used to decide
26 if a notification is generated for an event.
27
28 \code
29 QtOpcUa.FilterElement {
30 operator: QtOpcUa.FilterElement.GreaterThanOrEqual
31 firstOperand: QtOpcUa.SimpleAttributeOperand { ... }
32 secondOperand: QtOpcUa.LiteralOperand { ... }
33 }
34 \endcode
35
36 \sa EventFilter
37*/
38
39/*!
40 \qmlproperty enumeration FilterElement::operatorType
41
42 The filter operator.
43
44 Possible operators for a FilterElement that are specified in
45 OPC UA 1.05 part 4, 7.7.3
46
47 \value FilterElement.Equals
48 \value FilterElement.IsNull
49 \value FilterElement.GreaterThan
50 \value FilterElement.LessThan
51 \value FilterElement.GreaterThanOrEqual
52 \value FilterElement.LessThanOrEqual
53 \value FilterElement.Like
54 \value FilterElement.Not
55 \value FilterElement.Between
56 \value FilterElement.InList
57 \value FilterElement.And
58 \value FilterElement.Or
59 \value FilterElement.Cast
60 \value FilterElement.InView
61 \value FilterElement.OfType
62 \value FilterElement.RelatedTo
63 \value FilterElement.BitwiseAnd
64 \value FilterElement.BitwiseOr
65*/
66
67/*!
68 \qmlproperty variant FilterElement::firstOperand
69
70 First operand to be used with the operator.
71 This can be one of \l SimpleAttributeOperand, \l AttributeOperand,
72 \l LiteralOperand or \l ElementOperand.
73*/
74
75/*!
76 \qmlproperty variant FilterElement::secondOperand
77
78 Second operand to be used with the operator.
79 This can be one of \l SimpleAttributeOperand, \l AttributeOperand,
80 \l LiteralOperand or \l ElementOperand.
81*/
82
83
84OpcUaFilterElement::OpcUaFilterElement(QObject *parent)
85 : QObject(parent)
86{
87}
88
89OpcUaFilterElement::~OpcUaFilterElement() = default;
90
91QOpcUaContentFilterElement OpcUaFilterElement::toFilterElement(QOpcUaClient *client)
92{
93 QOpcUaContentFilterElement value;
94 value.setFilterOperator(static_cast<QOpcUaContentFilterElement::FilterOperator>(operatorType()));
95 value.filterOperandsRef().append(t: m_firstOperand->toCppVariant(client));
96 value.filterOperandsRef().append(t: m_secondOperand->toCppVariant(client));
97 return value;
98}
99
100OpcUaFilterElement::FilterOperator OpcUaFilterElement::operatorType() const
101{
102 return m_filterOperator;
103}
104
105void OpcUaFilterElement::setOperatorType(OpcUaFilterElement::FilterOperator filterOperator)
106{
107 m_filterOperator = filterOperator;
108}
109
110OpcUaOperandBase *OpcUaFilterElement::firstOperand() const
111{
112 return m_firstOperand;
113}
114
115void OpcUaFilterElement::setFirstOperand(OpcUaOperandBase *operand)
116{
117 if (m_firstOperand != operand) {
118 m_firstOperand = operand;
119 emit dataChanged();
120 }
121}
122
123OpcUaOperandBase *OpcUaFilterElement::secondOperand() const
124{
125 return m_secondOperand;
126}
127
128void OpcUaFilterElement::setSecondOperand(OpcUaOperandBase *operand)
129{
130 if (m_secondOperand != operand) {
131 m_secondOperand = operand;
132 emit dataChanged();
133 }
134}
135
136QT_END_NAMESPACE
137

source code of qtopcua/src/declarative_opcua/opcuafilterelement.cpp