| 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 | #include <QtOpcUa/qopcuaglobal.h> | 
| 5 | #include <QtOpcUa/qopcuatype.h> | 
| 6 |  | 
| 7 | #include <QtCore/qobject.h> | 
| 8 | #include <QtCore/qstringfwd.h> | 
| 9 |  | 
| 10 | #include <optional> | 
| 11 |  | 
| 12 | #ifndef QOPCUAGENERICSTRUCTHANDLER_H | 
| 13 | #define QOPCUAGENERICSTRUCTHANDLER_H | 
| 14 |  | 
| 15 | QT_BEGIN_NAMESPACE | 
| 16 |  | 
| 17 | class QOpcUaClient; | 
| 18 | class QOpcUaEnumDefinition; | 
| 19 | class QOpcUaExtensionObject; | 
| 20 | class QOpcUaStructureDefinition; | 
| 21 | class QOpcUaGenericStructValue; | 
| 22 |  | 
| 23 | class QOpcUaGenericStructHandlerPrivate; | 
| 24 |  | 
| 25 | class Q_OPCUA_EXPORT QOpcUaGenericStructHandler : public QObject { | 
| 26 |     Q_OBJECT | 
| 27 |     Q_DISABLE_COPY(QOpcUaGenericStructHandler) | 
| 28 |     Q_DECLARE_PRIVATE(QOpcUaGenericStructHandler) | 
| 29 | public: | 
| 30 |     explicit QOpcUaGenericStructHandler(QOpcUaClient *client, QObject *parent = nullptr); | 
| 31 |     ~QOpcUaGenericStructHandler() override; | 
| 32 |  | 
| 33 |     bool initialize(); | 
| 34 |  | 
| 35 |     std::optional<QOpcUaGenericStructValue> decode(const QOpcUaExtensionObject &extensionObject) const; | 
| 36 |     std::optional<QOpcUaExtensionObject> encode(const QOpcUaGenericStructValue &value); | 
| 37 |  | 
| 38 |     QOpcUaGenericStructValue createGenericStructValueForTypeId(const QString &typeId); | 
| 39 |  | 
| 40 |     QOpcUaStructureDefinition structureDefinitionForBinaryEncodingId(const QString &id) const; | 
| 41 |     QOpcUaStructureDefinition structureDefinitionForTypeId(const QString &id) const; | 
| 42 |     QOpcUaEnumDefinition enumDefinitionForTypeId(const QString &id) const; | 
| 43 |     QString typeNameForBinaryEncodingId(const QString &id) const; | 
| 44 |     QString typeNameForTypeId(const QString &id) const; | 
| 45 |     bool isAbstractTypeId(const QString &id) const; | 
| 46 |  | 
| 47 |     bool addCustomStructureDefinition(const QOpcUaStructureDefinition &definition, const QString &typeId, | 
| 48 |                                       const QString &name, QOpcUa::IsAbstract isAbstract = QOpcUa::IsAbstract::NotAbstract); | 
| 49 |     bool addCustomEnumDefinition(const QOpcUaEnumDefinition &definition, const QString &typeId, | 
| 50 |                                  const QString &name, QOpcUa::IsAbstract isAbstract = QOpcUa::IsAbstract::NotAbstract); | 
| 51 |  | 
| 52 |     bool initialized() const; | 
| 53 |  | 
| 54 |     enum class DataTypeKind { | 
| 55 |         Unknown = 0, | 
| 56 |         Struct = 1, | 
| 57 |         Enum = 2, | 
| 58 |         Other = 3, | 
| 59 |     }; | 
| 60 |     Q_ENUM(DataTypeKind) | 
| 61 |  | 
| 62 |     DataTypeKind dataTypeKindForTypeId(const QString &id) const; | 
| 63 |  | 
| 64 |     QString typeIdForBinaryEncodingId(const QString &id) const; | 
| 65 |  | 
| 66 | Q_SIGNALS: | 
| 67 |     void initializedChanged(bool initialized); | 
| 68 | }; | 
| 69 |  | 
| 70 | QT_END_NAMESPACE | 
| 71 |  | 
| 72 | #endif // QOPCUAGENERICSTRUCTHANDLER_H | 
| 73 |  |