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 "qopcuarange.h"
5
6QT_BEGIN_NAMESPACE
7
8/*!
9 \class QOpcUaRange
10 \inmodule QtOpcUa
11 \brief The OPC UA Range type.
12
13 This is the Qt OPC UA representation for the OPC UA Range type defined in OPC-UA part 8, 5.6.2.
14 It consists of two double values which mark minimum and maximum of the range.
15 Ranges are mostly used to store information about acceptable values for a node.
16*/
17
18class QOpcUaRangeData : public QSharedData
19{
20public:
21 double low{0};
22 double high{0};
23};
24
25QOpcUaRange::QOpcUaRange()
26 : data(new QOpcUaRangeData)
27{
28}
29
30/*!
31 Constructs a range from \a rhs.
32*/
33QOpcUaRange::QOpcUaRange(const QOpcUaRange &rhs)
34 : data(rhs.data)
35{
36}
37
38/*!
39 Constructs a range with low value \a low and high value \a high.
40*/
41QOpcUaRange::QOpcUaRange(double low, double high)
42 : data(new QOpcUaRangeData)
43{
44 data->low = low;
45 data->high = high;
46}
47
48/*!
49 Sets the values from \a rhs in this range.
50*/
51QOpcUaRange &QOpcUaRange::operator=(const QOpcUaRange &rhs)
52{
53 if (this != &rhs)
54 data.operator=(o: rhs.data);
55 return *this;
56}
57
58/*!
59 Returns \c true if this range has the same value as \a rhs.
60*/
61bool QOpcUaRange::operator==(const QOpcUaRange &rhs) const
62{
63 return data->low == rhs.low() &&
64 data->high == rhs.high();
65}
66
67/*!
68 Converts this range to \l QVariant.
69*/
70QOpcUaRange::operator QVariant() const
71{
72 return QVariant::fromValue(value: *this);
73}
74
75QOpcUaRange::~QOpcUaRange()
76{
77}
78
79/*!
80 Returns the high value of the range.
81*/
82double QOpcUaRange::high() const
83{
84 return data->high;
85}
86
87/*!
88 Sets the high value of the range to \a high.
89*/
90void QOpcUaRange::setHigh(double high)
91{
92 data->high = high;
93}
94
95/*!
96 Returns the low value of the range.
97*/
98double QOpcUaRange::low() const
99{
100 return data->low;
101}
102
103/*!
104 Sets the low value of the range to \a low.
105*/
106void QOpcUaRange::setLow(double low)
107{
108 data->low = low;
109}
110
111QT_END_NAMESPACE
112

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