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

source code of qtopcua/src/declarative_opcua/universalnode_p.h