1// Copyright (C) 2019 The Qt Company Ltd.
2// Copyright (C) 2015 basysKom GmbH, opensource@basyskom.com
3// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include "qopcualiteraloperand.h"
6
7QT_BEGIN_NAMESPACE
8
9/*!
10 \class QOpcUaLiteralOperand
11 \inmodule QtOpcUa
12 \brief The OPC UA LiteralOperand type.
13
14 The LiteralOperand is defined in OPC UA 1.05 part 4, 7.7.4.3.
15 It contains a literal value that is to be used as operand.
16*/
17class QOpcUaLiteralOperandData : public QSharedData
18{
19public:
20 QVariant value;
21 QOpcUa::Types type {QOpcUa::Types::Undefined};
22};
23
24/*!
25 Default constructs a literal operand with no parameters set.
26*/
27QOpcUaLiteralOperand::QOpcUaLiteralOperand()
28 : data(new QOpcUaLiteralOperandData)
29{
30 data->type = QOpcUa::Types::Undefined;
31}
32
33/*!
34 Constructs a literal operand from \a rhs.
35*/
36QOpcUaLiteralOperand::QOpcUaLiteralOperand(const QOpcUaLiteralOperand &rhs)
37 : data(rhs.data)
38{
39}
40
41/*!
42 Constructs a literal operand of value \a value and type \a type.
43*/
44QOpcUaLiteralOperand::QOpcUaLiteralOperand(const QVariant &value, QOpcUa::Types type)
45 : data(new QOpcUaLiteralOperandData)
46{
47 setValue(value);
48 setType(type);
49}
50
51/*!
52 Sets the values from \a rhs in this \l QOpcUaLiteralOperand.
53*/
54QOpcUaLiteralOperand &QOpcUaLiteralOperand::operator=(const QOpcUaLiteralOperand &rhs)
55{
56 if (this != &rhs)
57 data.operator=(o: rhs.data);
58 return *this;
59}
60
61/*!
62 Converts this literal operand to \l QVariant.
63*/
64QOpcUaLiteralOperand::operator QVariant() const
65{
66 return QVariant::fromValue(value: *this);
67}
68
69QOpcUaLiteralOperand::~QOpcUaLiteralOperand()
70{
71}
72
73/*!
74 Returns the type of the value of the literal operand.
75*/
76QOpcUa::Types QOpcUaLiteralOperand::type() const
77{
78 return data->type;
79}
80
81/*!
82 Sets the type of the value of the literal operand to \a type.
83*/
84void QOpcUaLiteralOperand::setType(QOpcUa::Types type)
85{
86 data->type = type;
87}
88
89/*!
90 Returns the value of the literal operand.
91*/
92QVariant QOpcUaLiteralOperand::value() const
93{
94 return data->value;
95}
96
97/*!
98 Sets the value of the literal operand to \a value.
99*/
100void QOpcUaLiteralOperand::setValue(const QVariant &value)
101{
102 data->value = value;
103}
104
105/*!
106 \fn bool QOpcUaLiteralOperand::operator==(const QOpcUaLiteralOperand &lhs,
107 const QOpcUaLiteralOperand &rhs)
108 \since 6.7
109
110 Returns \c true if \a lhs has the same value as \a rhs.
111*/
112bool comparesEqual(const QOpcUaLiteralOperand &lhs, const QOpcUaLiteralOperand &rhs) noexcept
113{
114 return lhs.value() == rhs.value() && lhs.type() == rhs.type();
115}
116
117/*!
118 \fn bool QOpcUaLiteralOperand::operator!=(const QOpcUaLiteralOperand &lhs,
119 const QOpcUaLiteralOperand &rhs)
120 \since 6.7
121
122 Returns \c true if \a lhs has a different value than \a rhs.
123*/
124
125QT_END_NAMESPACE
126

Provided by KDAB

Privacy Policy
Learn to use CMake with our Intro Training
Find out more

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