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
6QT_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
21OpcUaAttributeValue::OpcUaAttributeValue(QObject *parent)
22 : QObject(parent)
23{
24
25}
26
27bool OpcUaAttributeValue::operator ==(const OpcUaAttributeValue &rhs)
28{
29 return m_value == rhs.m_value;
30}
31
32void 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
40void OpcUaAttributeValue::invalidate()
41{
42 setValue(QVariant());
43}
44
45const QVariant &OpcUaAttributeValue::value() const
46{
47 return m_value;
48}
49
50OpcUaAttributeValue::operator QVariant() const
51{
52 return value();
53}
54
55QT_END_NAMESPACE
56

source code of qtopcua/src/declarative_opcua/opcuaattributevalue.cpp