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 "qopcuacontentfilterelement.h" |
5 | #include "qopcuasimpleattributeoperand.h" |
6 | #include "qopcuaattributeoperand.h" |
7 | #include "qopcualiteraloperand.h" |
8 | #include "qopcuaelementoperand.h" |
9 | |
10 | QT_BEGIN_NAMESPACE |
11 | |
12 | /*! |
13 | \class QOpcUaContentFilterElement |
14 | \inmodule QtOpcUa |
15 | \brief The OPC UA ContentFilterElement. |
16 | |
17 | A content filter element contains an operator and a list of operands. |
18 | There are four different operator types which contain literal values, references to |
19 | attributes of nodes or to other content filter elements. |
20 | |
21 | A combination of one or more content filter elements makes a content filter which is used |
22 | by the server to filter data for the criteria defined by the content filter elements. |
23 | For example, the \c where clause of an event filter is a content filter which is used to decide |
24 | if a notification is generated for an event. |
25 | */ |
26 | |
27 | /*! |
28 | \enum QOpcUaContentFilterElement::FilterOperator |
29 | |
30 | FilterOperator enumerates all possible operators for a ContentFilterElement that are specified in |
31 | OPC-UA part 4, Tables 115 and 116. |
32 | |
33 | \value Equals |
34 | \value IsNull |
35 | \value GreaterThan |
36 | \value LessThan |
37 | \value GreaterThanOrEqual |
38 | \value LessThanOrEqual |
39 | \value Like |
40 | \value Not |
41 | \value Between |
42 | \value InList |
43 | \value And |
44 | \value Or |
45 | \value Cast |
46 | \value InView |
47 | \value OfType |
48 | \value RelatedTo |
49 | \value BitwiseAnd |
50 | \value BitwiseOr |
51 | */ |
52 | |
53 | class QOpcUaContentFilterElementData : public QSharedData |
54 | { |
55 | public: |
56 | QOpcUaContentFilterElement::FilterOperator filterOperator; |
57 | QList<QVariant> filterOperands; |
58 | }; |
59 | |
60 | QOpcUaContentFilterElement::QOpcUaContentFilterElement() |
61 | : data(new QOpcUaContentFilterElementData) |
62 | { |
63 | } |
64 | |
65 | /*! |
66 | Constructs a content filter element from \a rhs. |
67 | */ |
68 | QOpcUaContentFilterElement::QOpcUaContentFilterElement(const QOpcUaContentFilterElement &rhs) |
69 | : data(rhs.data) |
70 | { |
71 | } |
72 | |
73 | QOpcUaContentFilterElement::~QOpcUaContentFilterElement() = default; |
74 | |
75 | /*! |
76 | Sets the values from \a rhs in this content filter element. |
77 | */ |
78 | QOpcUaContentFilterElement &QOpcUaContentFilterElement::operator=(const QOpcUaContentFilterElement &rhs) |
79 | { |
80 | if (this != &rhs) |
81 | data.operator=(o: rhs.data); |
82 | return *this; |
83 | } |
84 | |
85 | /*! |
86 | Returns \c true if this content filter element has the same value as \a rhs. |
87 | */ |
88 | bool QOpcUaContentFilterElement::operator==(const QOpcUaContentFilterElement &rhs) const |
89 | { |
90 | return filterOperator() == rhs.filterOperator() && filterOperands() == rhs.filterOperands(); |
91 | } |
92 | |
93 | /*! |
94 | Converts this content filter element to \l QVariant. |
95 | */ |
96 | QOpcUaContentFilterElement::operator QVariant() const |
97 | { |
98 | return QVariant::fromValue(value: *this); |
99 | } |
100 | |
101 | /*! |
102 | Returns the operands of the filter element. |
103 | */ |
104 | QList<QVariant> QOpcUaContentFilterElement::filterOperands() const |
105 | { |
106 | return data->filterOperands; |
107 | } |
108 | |
109 | /*! |
110 | Returns a reference to the filter operands. |
111 | |
112 | \sa filterOperands() |
113 | */ |
114 | QList<QVariant> &QOpcUaContentFilterElement::filterOperandsRef() |
115 | { |
116 | return data->filterOperands; |
117 | } |
118 | |
119 | /*! |
120 | Sets the filter operands for this content filter element to \a filterOperands. |
121 | Supported classes are \l QOpcUaElementOperand, \l QOpcUaLiteralOperand, |
122 | \l QOpcUaSimpleAttributeOperand and \l QOpcUaAttributeOperand. |
123 | */ |
124 | void QOpcUaContentFilterElement::setFilterOperands(const QList<QVariant> &filterOperands) |
125 | { |
126 | data->filterOperands = filterOperands; |
127 | } |
128 | |
129 | /*! |
130 | Returns the filter operator. |
131 | */ |
132 | QOpcUaContentFilterElement::FilterOperator QOpcUaContentFilterElement::filterOperator() const |
133 | { |
134 | return data->filterOperator; |
135 | } |
136 | |
137 | /*! |
138 | Sets the operator that is applied to the filter operands to \a filterOperator. |
139 | */ |
140 | void QOpcUaContentFilterElement::setFilterOperator(QOpcUaContentFilterElement::FilterOperator filterOperator) |
141 | { |
142 | data->filterOperator = filterOperator; |
143 | } |
144 | |
145 | /*! |
146 | Sets filter operator \a op in this content filter element. |
147 | If multiple operators are streamed into one content filter element, only the last operator is used. |
148 | All others are discarded. |
149 | */ |
150 | QOpcUaContentFilterElement &QOpcUaContentFilterElement::operator<<(QOpcUaContentFilterElement::FilterOperator op) |
151 | { |
152 | setFilterOperator(op); |
153 | return *this; |
154 | } |
155 | |
156 | /*! |
157 | Adds the simple attribute operand \a op to the operands list of this content filter element. |
158 | */ |
159 | QOpcUaContentFilterElement &QOpcUaContentFilterElement::operator<<(const QOpcUaSimpleAttributeOperand &op) |
160 | { |
161 | filterOperandsRef().append(t: op); |
162 | return *this; |
163 | } |
164 | |
165 | /*! |
166 | Adds the attribute operand \a op to the operands list of this content filter element. |
167 | */ |
168 | QOpcUaContentFilterElement &QOpcUaContentFilterElement::operator<<(const QOpcUaAttributeOperand &op) |
169 | { |
170 | filterOperandsRef().append(t: op); |
171 | return *this; |
172 | } |
173 | |
174 | /*! |
175 | Adds the literal operand \a op to the operands list of this content filter element. |
176 | */ |
177 | QOpcUaContentFilterElement &QOpcUaContentFilterElement::operator<<(const QOpcUaLiteralOperand &op) |
178 | { |
179 | filterOperandsRef().append(t: op); |
180 | return *this; |
181 | } |
182 | |
183 | /*! |
184 | Adds the element operand \a op to the operands list of this content filter element. |
185 | */ |
186 | QOpcUaContentFilterElement &QOpcUaContentFilterElement::operator<<(const QOpcUaElementOperand &op) |
187 | { |
188 | filterOperandsRef().append(t: op); |
189 | return *this; |
190 | } |
191 | |
192 | QT_END_NAMESPACE |
193 |