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 "qopcuaelementoperand.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class QOpcUaElementOperand
10 \inmodule QtOpcUa
11 \brief The OPC UA ElementOperand type.
12
13 The ElementOperand is defined in OPC-UA part 4, 7.4.4.2.
14 It is used to identify another element in the filter by its index
15 (the first element has the index 0).
16
17 This is required to create complex filters, for example to reference
18 the two operands of the AND operation in ((Severity > 500) AND (Message == "TestString")).
19 The first step is to create content filter elements for the two conditions (Severity > 500)
20 and (Message == "TestString"). A third content filter element is required to create an AND
21 combination of the two conditions. It consists of the AND operator and two element operands
22 with the indices of the two conditions created before:
23
24 \code
25 QOpcUaMonitoringParameters::EventFilter filter;
26 ...
27 // setup select clauses
28 ...
29 QOpcUaContentFilterElement condition1;
30 QOpcUaContentFilterElement condition2;
31 QOpcUaContentFilterElement condition3;
32 condition1 << QOpcUaContentFilterElement::FilterOperator::GreaterThan << QOpcUaSimpleAttributeOperand("Severity") <<
33 QOpcUaLiteralOperand(quint16(500), QOpcUa::Types::UInt16);
34 condition2 << QOpcUaContentFilterElement::FilterOperator::Equals << QOpcUaSimpleAttributeOperand("Message") <<
35 QOpcUaLiteralOperand("TestString", QOpcUa::Types::String);
36 condition3 << QOpcUaContentFilterElement::FilterOperator::And << QOpcUaElementOperand(0) << QOpcUaElementOperand(1);
37 filter << condition1 << condition2 << condition3;
38 \endcode
39*/
40
41class QOpcUaElementOperandData : public QSharedData
42{
43public:
44 quint32 index{0};
45};
46
47QOpcUaElementOperand::QOpcUaElementOperand()
48 : data(new QOpcUaElementOperandData)
49{
50}
51
52/*!
53 Constructs an element operand from \a rhs.
54*/
55QOpcUaElementOperand::QOpcUaElementOperand(const QOpcUaElementOperand &rhs)
56 : data(rhs.data)
57{
58}
59
60/*!
61 Constructs an element operand with index \a index.
62*/
63QOpcUaElementOperand::QOpcUaElementOperand(quint32 index)
64 : data(new QOpcUaElementOperandData)
65{
66 setIndex(index);
67}
68
69/*!
70 Sets the values from \a rhs in this element operand.
71*/
72QOpcUaElementOperand &QOpcUaElementOperand::operator=(const QOpcUaElementOperand &rhs)
73{
74 if (this != &rhs)
75 data.operator=(o: rhs.data);
76 return *this;
77}
78
79/*!
80 Converts this element operand to \l QVariant.
81*/
82QOpcUaElementOperand::operator QVariant() const
83{
84 return QVariant::fromValue(value: *this);
85}
86
87QOpcUaElementOperand::~QOpcUaElementOperand()
88{
89}
90
91/*!
92 Returns the index of the filter element that is going to be used as operand.
93*/
94quint32 QOpcUaElementOperand::index() const
95{
96 return data->index;
97}
98
99/*!
100 Sets the index of the filter element that is going to be used as operand to \a index.
101*/
102void QOpcUaElementOperand::setIndex(quint32 index)
103{
104 data->index = index;
105}
106
107QT_END_NAMESPACE
108

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