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/opcualiteraloperand_p.h> |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | /*! |
9 | \qmltype LiteralOperand |
10 | \inqmlmodule QtOpcUa |
11 | \brief The OPC UA LiteralOperand type. |
12 | \since QtOpcUa 5.13 |
13 | |
14 | The LiteralOperand is defined in OPC-UA part 4, 7.4.4.3. |
15 | It contains a literal value that is to be used as operand for filters. |
16 | |
17 | Setting the type should be done to match the expected types on the server. |
18 | Otherwise the type will be guessed and may lead to errors because it does |
19 | not match on the server. |
20 | |
21 | \code |
22 | import QtOpcUa as QtOpcUa |
23 | |
24 | QtOpcUa.LiteralOperand { |
25 | value: 43.21 |
26 | type: QtOpcUa.Constants.Double |
27 | } |
28 | \endcode |
29 | */ |
30 | |
31 | /*! |
32 | \qmlproperty QOpcUa.Types LiteralOperand::type |
33 | |
34 | Type of the value of the literal operand. |
35 | */ |
36 | |
37 | /*! |
38 | \qmlproperty variant LiteralOperand::value |
39 | |
40 | Value of the literal operand. |
41 | */ |
42 | |
43 | OpcUaLiteralOperand::OpcUaLiteralOperand(QObject *parent) |
44 | : OpcUaOperandBase(parent) |
45 | , m_type(QOpcUa::Undefined) |
46 | { |
47 | } |
48 | |
49 | OpcUaLiteralOperand::~OpcUaLiteralOperand() = default; |
50 | |
51 | QVariant OpcUaLiteralOperand::toCppVariant(QOpcUaClient *client) const |
52 | { |
53 | Q_UNUSED(client); |
54 | return QOpcUaLiteralOperand(m_value, m_type); |
55 | } |
56 | |
57 | QVariant OpcUaLiteralOperand::value() const |
58 | { |
59 | return m_value; |
60 | } |
61 | |
62 | void OpcUaLiteralOperand::setValue(const QVariant &value) |
63 | { |
64 | if (m_value != value) { |
65 | m_value = value; |
66 | emit dataChanged(); |
67 | } |
68 | } |
69 | |
70 | QOpcUa::Types OpcUaLiteralOperand::type() const |
71 | { |
72 | return m_type; |
73 | } |
74 | |
75 | void OpcUaLiteralOperand::setType(QOpcUa::Types type) |
76 | { |
77 | if (m_type != type) { |
78 | m_type = type; |
79 | emit dataChanged(); |
80 | } |
81 | } |
82 | |
83 | QT_END_NAMESPACE |
84 |