| 1 | // Copyright (C) 2021 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 | #ifndef QOPCUA_UNIVERSALNODE_P_H |
| 5 | #define QOPCUA_UNIVERSALNODE_P_H |
| 6 | |
| 7 | #include <QObject> |
| 8 | #include <private/qglobal_p.h> |
| 9 | |
| 10 | // |
| 11 | // W A R N I N G |
| 12 | // ------------- |
| 13 | // |
| 14 | // This file is not part of the Qt API. It exists purely as an |
| 15 | // implementation detail. This header file may change from version to |
| 16 | // version without notice, or even be removed. |
| 17 | // |
| 18 | // We mean it. |
| 19 | // |
| 20 | |
| 21 | QT_BEGIN_NAMESPACE |
| 22 | |
| 23 | class QOpcUaClient; |
| 24 | class QOpcUaNode; |
| 25 | class QOpcUaQualifiedName; |
| 26 | class QOpcUaExpandedNodeId; |
| 27 | class QOpcUaBrowsePathTarget; |
| 28 | class QOpcUaLocalizedText; |
| 29 | class OpcUaNodeIdType; |
| 30 | |
| 31 | class UniversalNode : public QObject |
| 32 | { |
| 33 | Q_OBJECT |
| 34 | public: |
| 35 | UniversalNode(); |
| 36 | UniversalNode(QObject *parent); |
| 37 | UniversalNode(const QString &nodeIdentifier, QObject *parent = nullptr); |
| 38 | UniversalNode(const QString &namespaceName, const QString &nodeIdentifier, QObject *parent = nullptr); |
| 39 | UniversalNode(quint16 namespaceIndex, const QString &nodeIdentifier, QObject *parent = nullptr); |
| 40 | UniversalNode(const UniversalNode &other, QObject *parent = nullptr); |
| 41 | UniversalNode(const OpcUaNodeIdType *other, QObject *parent = nullptr); |
| 42 | |
| 43 | void setNamespace(quint16 namespaceIndex); |
| 44 | void setNamespace(const QString &name); |
| 45 | |
| 46 | const QString &namespaceName() const; |
| 47 | void setNamespaceName(const QString &namespaceName); |
| 48 | bool isNamespaceNameValid() const; |
| 49 | |
| 50 | quint16 namespaceIndex() const; |
| 51 | bool isNamespaceIndexValid() const; |
| 52 | |
| 53 | const QString &nodeIdentifier() const; |
| 54 | void setNodeIdentifier(const QString &nodeIdentifier); |
| 55 | |
| 56 | void resolveNamespaceIndexToName(QOpcUaClient *client); |
| 57 | void resolveNamespaceNameToIndex(QOpcUaClient *client); |
| 58 | void resolveNamespace(QOpcUaClient *client); |
| 59 | static int resolveNamespaceNameToIndex(const QString &namespaceName, QOpcUaClient *client); |
| 60 | |
| 61 | QOpcUaQualifiedName toQualifiedName() const; |
| 62 | void from(const QOpcUaQualifiedName &qualifiedName); |
| 63 | |
| 64 | QOpcUaExpandedNodeId toExpandedNodeId() const; |
| 65 | void from(const QOpcUaExpandedNodeId &expandedNodeId); |
| 66 | |
| 67 | void from(const QOpcUaBrowsePathTarget &browsePathTarget); |
| 68 | void from(const OpcUaNodeIdType &); |
| 69 | void from(const OpcUaNodeIdType *); |
| 70 | void from(const UniversalNode &); |
| 71 | |
| 72 | QString fullNodeId() const; |
| 73 | QOpcUaNode *createNode(QOpcUaClient *client); |
| 74 | |
| 75 | UniversalNode& operator=(const UniversalNode&); |
| 76 | bool operator==(const UniversalNode &rhs) const; |
| 77 | |
| 78 | static QString resolveNamespaceToNode(const QString &nodeId, const QString &namespaceName, QOpcUaClient *client); |
| 79 | inline static QString createNodeString(int namespaceIndex, const QString &nodeIdentifier) { |
| 80 | return QStringLiteral("ns=%1;%2" ).arg(a: namespaceIndex).arg(a: nodeIdentifier); |
| 81 | } |
| 82 | static bool splitNodeIdAndNamespace(const QString nodeIdentifier, int *namespaceIndex, QString *identifier); |
| 83 | |
| 84 | signals: |
| 85 | void namespaceNameChanged(const QString &); |
| 86 | void namespaceIndexChanged(quint16); |
| 87 | void nodeIdentifierChanged(const QString &); |
| 88 | void nodeChanged(); |
| 89 | void namespaceChanged(); |
| 90 | |
| 91 | private: |
| 92 | void setMembers(bool setNamespaceIndex, quint16 namespaceIndex, |
| 93 | bool setNamespaceName, const QString &namespaceName, |
| 94 | bool setNodeIdentifier, const QString &nodeIdentifier); |
| 95 | |
| 96 | QString m_namespaceName; |
| 97 | QString m_nodeIdentifier; |
| 98 | quint16 m_namespaceIndex = 0; |
| 99 | bool m_namespaceIndexValid = false; |
| 100 | }; |
| 101 | |
| 102 | QT_END_NAMESPACE |
| 103 | |
| 104 | #endif // QOPCUA_UNIVERSALNODE_P_H |
| 105 | |