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 part 4, 7.4.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
24QOpcUaLiteralOperand::QOpcUaLiteralOperand()
25 : data(new QOpcUaLiteralOperandData)
26{
27 data->type = QOpcUa::Types::Undefined;
28}
29
30/*!
31 Constructs a literal operand from \a rhs.
32*/
33QOpcUaLiteralOperand::QOpcUaLiteralOperand(const QOpcUaLiteralOperand &rhs)
34 : data(rhs.data)
35{
36}
37
38/*!
39 Constructs a literal operand of value \a value and type \a type.
40*/
41QOpcUaLiteralOperand::QOpcUaLiteralOperand(const QVariant &value, QOpcUa::Types type)
42 : data(new QOpcUaLiteralOperandData)
43{
44 setValue(value);
45 setType(type);
46}
47
48/*!
49 Sets the values from \a rhs in this \l QOpcUaLiteralOperand.
50*/
51QOpcUaLiteralOperand &QOpcUaLiteralOperand::operator=(const QOpcUaLiteralOperand &rhs)
52{
53 if (this != &rhs)
54 data.operator=(o: rhs.data);
55 return *this;
56}
57
58/*!
59 Converts this literal operand to \l QVariant.
60*/
61QOpcUaLiteralOperand::operator QVariant() const
62{
63 return QVariant::fromValue(value: *this);
64}
65
66QOpcUaLiteralOperand::~QOpcUaLiteralOperand()
67{
68}
69
70/*!
71 Returns the type of the value of the literal operand.
72*/
73QOpcUa::Types QOpcUaLiteralOperand::type() const
74{
75 return data->type;
76}
77
78/*!
79 Sets the type of the value of the literal operand to \a type.
80*/
81void QOpcUaLiteralOperand::setType(QOpcUa::Types type)
82{
83 data->type = type;
84}
85
86/*!
87 Returns the value of the literal operand.
88*/
89QVariant QOpcUaLiteralOperand::value() const
90{
91 return data->value;
92}
93
94/*!
95 Sets the value of the literal operand to \a value.
96*/
97void QOpcUaLiteralOperand::setValue(const QVariant &value)
98{
99 data->value = value;
100}
101
102QT_END_NAMESPACE
103

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