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
21QT_BEGIN_NAMESPACE
22
23class QOpcUaClient;
24class QOpcUaNode;
25class QOpcUaQualifiedName;
26class QOpcUaExpandedNodeId;
27class QOpcUaBrowsePathTarget;
28class QOpcUaLocalizedText;
29class OpcUaNodeIdType;
30
31class UniversalNode : public QObject
32{
33 Q_OBJECT
34public:
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
84signals:
85 void namespaceNameChanged(const QString &);
86 void namespaceIndexChanged(quint16);
87 void nodeIdentifierChanged(const QString &);
88 void nodeChanged();
89 void namespaceChanged();
90
91private:
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
102QT_END_NAMESPACE
103
104#endif // QOPCUA_UNIVERSALNODE_P_H
105

Provided by KDAB

Privacy Policy
Learn Advanced QML with KDAB
Find out more

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