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 1.05 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
25/*!
26 Default constructs a range with no parameters set.
27*/
28QOpcUaRange::QOpcUaRange()
29 : data(new QOpcUaRangeData)
30{
31}
32
33/*!
34 Constructs a range from \a rhs.
35*/
36QOpcUaRange::QOpcUaRange(const QOpcUaRange &rhs)
37 : data(rhs.data)
38{
39}
40
41/*!
42 Constructs a range with low value \a low and high value \a high.
43*/
44QOpcUaRange::QOpcUaRange(double low, double high)
45 : data(new QOpcUaRangeData)
46{
47 data->low = low;
48 data->high = high;
49}
50
51/*!
52 Sets the values from \a rhs in this range.
53*/
54QOpcUaRange &QOpcUaRange::operator=(const QOpcUaRange &rhs)
55{
56 if (this != &rhs)
57 data.operator=(o: rhs.data);
58 return *this;
59}
60
61/*!
62 Returns \c true if this range has the same value as \a rhs.
63*/
64bool QOpcUaRange::operator==(const QOpcUaRange &rhs) const
65{
66 return data->low == rhs.low() &&
67 data->high == rhs.high();
68}
69
70/*!
71 Converts this range to \l QVariant.
72*/
73QOpcUaRange::operator QVariant() const
74{
75 return QVariant::fromValue(value: *this);
76}
77
78QOpcUaRange::~QOpcUaRange()
79{
80}
81
82/*!
83 Returns the high value of the range.
84*/
85double QOpcUaRange::high() const
86{
87 return data->high;
88}
89
90/*!
91 Sets the high value of the range to \a high.
92*/
93void QOpcUaRange::setHigh(double high)
94{
95 data->high = high;
96}
97
98/*!
99 Returns the low value of the range.
100*/
101double QOpcUaRange::low() const
102{
103 return data->low;
104}
105
106/*!
107 Sets the low value of the range to \a low.
108*/
109void QOpcUaRange::setLow(double low)
110{
111 data->low = low;
112}
113
114QT_END_NAMESPACE
115

Provided by KDAB

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

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