| 1 | // Copyright (C) 2023 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 | #ifndef QOPCUAVARIANT_H | 
| 5 | #define QOPCUAVARIANT_H | 
| 6 |  | 
| 7 | #include <QtOpcUa/qopcuaglobal.h> | 
| 8 |  | 
| 9 | #include <QtCore/qcontainerfwd.h> | 
| 10 | #include <QtCore/qshareddata.h> | 
| 11 |  | 
| 12 | QT_BEGIN_NAMESPACE | 
| 13 |  | 
| 14 | class QVariant; | 
| 15 |  | 
| 16 | class QOpcUaVariantData; | 
| 17 |  | 
| 18 | QT_DECLARE_QESDP_SPECIALIZATION_DTOR_WITH_EXPORT(QOpcUaVariantData, Q_OPCUA_EXPORT) | 
| 19 |  | 
| 20 | class QOpcUaVariant | 
| 21 | { | 
| 22 | public: | 
| 23 |     enum class ValueType { | 
| 24 |         Unknown = 0, | 
| 25 |         Boolean = 1, | 
| 26 |         SByte = 2, | 
| 27 |         Byte = 3, | 
| 28 |         Int16 = 4, | 
| 29 |         UInt16 = 5, | 
| 30 |         Int32 = 6, | 
| 31 |         UInt32 = 7, | 
| 32 |         Int64 = 8, | 
| 33 |         UInt64 = 9, | 
| 34 |         Float = 10, | 
| 35 |         Double = 11, | 
| 36 |         String = 12, | 
| 37 |         DateTime = 13, | 
| 38 |         Guid = 14, | 
| 39 |         ByteString = 15, | 
| 40 |         XmlElement = 16, | 
| 41 |         NodeId = 17, | 
| 42 |         ExpandedNodeId = 18, | 
| 43 |         StatusCode = 19, | 
| 44 |         QualifiedName = 20, | 
| 45 |         LocalizedText = 21, | 
| 46 |         ExtensionObject = 22, | 
| 47 |         DataValue = 23, | 
| 48 |         Variant = 24, | 
| 49 |         DiagnosticInfo = 25, | 
| 50 |     }; | 
| 51 |  | 
| 52 |     Q_OPCUA_EXPORT QOpcUaVariant(); | 
| 53 |     Q_OPCUA_EXPORT QOpcUaVariant(ValueType type, const QVariant &value); | 
| 54 |     Q_OPCUA_EXPORT QOpcUaVariant(ValueType type, const QVariant &value, | 
| 55 |                                                   const QList<qint32> arrayDimensions); | 
| 56 |     Q_OPCUA_EXPORT QOpcUaVariant(const QOpcUaVariant &other); | 
| 57 |     Q_OPCUA_EXPORT ~QOpcUaVariant(); | 
| 58 |     void swap(QOpcUaVariant &other) noexcept | 
| 59 |     { data.swap(other&: other.data); } | 
| 60 |     QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QOpcUaVariant) | 
| 61 |     QOpcUaVariant(QOpcUaVariant &&other) noexcept = default; | 
| 62 |     Q_OPCUA_EXPORT QOpcUaVariant &operator=(const QOpcUaVariant &rhs); | 
| 63 |  | 
| 64 |     Q_OPCUA_EXPORT QVariant value() const; | 
| 65 |     Q_OPCUA_EXPORT void setValue(ValueType type, const QVariant &value); | 
| 66 |     Q_OPCUA_EXPORT void setValue(ValueType type, const QVariant &value, | 
| 67 |                                       const QList<qint32> &arrayDimensions); | 
| 68 |  | 
| 69 |     Q_OPCUA_EXPORT ValueType type() const; | 
| 70 |     Q_OPCUA_EXPORT bool isArray() const; | 
| 71 |  | 
| 72 |     Q_OPCUA_EXPORT QList<qint32> arrayDimensions() const; | 
| 73 |     Q_OPCUA_EXPORT void setArrayDimensions(const QList<qint32> &arrayDimensions); | 
| 74 |  | 
| 75 |     Q_OPCUA_EXPORT operator QVariant() const; | 
| 76 |  | 
| 77 | private: | 
| 78 |     QExplicitlySharedDataPointer<QOpcUaVariantData> data; | 
| 79 |  | 
| 80 |     friend Q_OPCUA_EXPORT bool comparesEqual(const QOpcUaVariant &lhs, | 
| 81 |                                              const QOpcUaVariant &rhs) noexcept; | 
| 82 |     friend bool operator==(const QOpcUaVariant &lhs, const QOpcUaVariant &rhs) noexcept | 
| 83 |     { return comparesEqual(lhs, rhs); } | 
| 84 |     friend bool operator!=(const QOpcUaVariant &lhs, const QOpcUaVariant &rhs) noexcept | 
| 85 |     { | 
| 86 |         return !(lhs == rhs); | 
| 87 |     } | 
| 88 | }; | 
| 89 |  | 
| 90 | Q_DECLARE_SHARED(QOpcUaVariant) | 
| 91 |  | 
| 92 | QT_END_NAMESPACE | 
| 93 |  | 
| 94 | #endif // QOPCUAVARIANT_H | 
| 95 |  |