1 | // Copyright (C) 2018 The Qt Company Ltd. |
---|---|
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 <private/opcuaattributevalue_p.h> |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | /*! |
9 | \class OpcUaAttributeValue |
10 | \inqmlmodule QtOpcUa |
11 | \brief Stores an attribute value and provides a changed signal. |
12 | \internal |
13 | |
14 | This class is just for internal use in the declarative backend and not exposed to users. |
15 | |
16 | When setting the value it will emit a changed signal if the value has changed. |
17 | |
18 | \sa OpcUaAttributeCache |
19 | */ |
20 | |
21 | OpcUaAttributeValue::OpcUaAttributeValue(QObject *parent) |
22 | : QObject(parent) |
23 | { |
24 | |
25 | } |
26 | |
27 | bool OpcUaAttributeValue::operator ==(const OpcUaAttributeValue &rhs) |
28 | { |
29 | return m_value == rhs.m_value; |
30 | } |
31 | |
32 | void OpcUaAttributeValue::setValue(const QVariant &value) |
33 | { |
34 | if (value.metaType() != m_value.metaType() || value != m_value) { |
35 | m_value = value; |
36 | emit changed(value: m_value); |
37 | } |
38 | } |
39 | |
40 | void OpcUaAttributeValue::invalidate() |
41 | { |
42 | setValue(QVariant()); |
43 | } |
44 | |
45 | const QVariant &OpcUaAttributeValue::value() const |
46 | { |
47 | return m_value; |
48 | } |
49 | |
50 | OpcUaAttributeValue::operator QVariant() const |
51 | { |
52 | return value(); |
53 | } |
54 | |
55 | QT_END_NAMESPACE |
56 |