| 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 | |
| 6 | QT_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 | |
| 18 | class QOpcUaRangeData : public QSharedData |
| 19 | { |
| 20 | public: |
| 21 | double low{0}; |
| 22 | double high{0}; |
| 23 | }; |
| 24 | |
| 25 | /*! |
| 26 | Default constructs a range with no parameters set. |
| 27 | */ |
| 28 | QOpcUaRange::QOpcUaRange() |
| 29 | : data(new QOpcUaRangeData) |
| 30 | { |
| 31 | } |
| 32 | |
| 33 | /*! |
| 34 | Constructs a range from \a rhs. |
| 35 | */ |
| 36 | QOpcUaRange::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 | */ |
| 44 | QOpcUaRange::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 | */ |
| 54 | QOpcUaRange &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 | */ |
| 64 | bool 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 | */ |
| 73 | QOpcUaRange::operator QVariant() const |
| 74 | { |
| 75 | return QVariant::fromValue(value: *this); |
| 76 | } |
| 77 | |
| 78 | QOpcUaRange::~QOpcUaRange() |
| 79 | { |
| 80 | } |
| 81 | |
| 82 | /*! |
| 83 | Returns the high value of the range. |
| 84 | */ |
| 85 | double QOpcUaRange::high() const |
| 86 | { |
| 87 | return data->high; |
| 88 | } |
| 89 | |
| 90 | /*! |
| 91 | Sets the high value of the range to \a high. |
| 92 | */ |
| 93 | void QOpcUaRange::setHigh(double high) |
| 94 | { |
| 95 | data->high = high; |
| 96 | } |
| 97 | |
| 98 | /*! |
| 99 | Returns the low value of the range. |
| 100 | */ |
| 101 | double QOpcUaRange::low() const |
| 102 | { |
| 103 | return data->low; |
| 104 | } |
| 105 | |
| 106 | /*! |
| 107 | Sets the low value of the range to \a low. |
| 108 | */ |
| 109 | void QOpcUaRange::setLow(double low) |
| 110 | { |
| 111 | data->low = low; |
| 112 | } |
| 113 | |
| 114 | QT_END_NAMESPACE |
| 115 | |