1 | // Copyright (C) 2015 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 "qopcuabrowsepathtarget.h" |
5 | |
6 | QT_BEGIN_NAMESPACE |
7 | |
8 | /*! |
9 | \class QOpcUaBrowsePathTarget |
10 | \inmodule QtOpcUa |
11 | \brief The OPC UA BrowsePathTarget. |
12 | |
13 | A BrowsePathTarget contains a target of a browse path and information about the completeness of the node id resolution. |
14 | */ |
15 | class QOpcUaBrowsePathTargetData : public QSharedData |
16 | { |
17 | public: |
18 | QOpcUaExpandedNodeId targetId; |
19 | quint32 remainingPathIndex{(std::numeric_limits<quint32>::max)()}; |
20 | }; |
21 | |
22 | /*! |
23 | Default constructs a browse path target with no parameters set. |
24 | */ |
25 | QOpcUaBrowsePathTarget::QOpcUaBrowsePathTarget() |
26 | : data(new QOpcUaBrowsePathTargetData) |
27 | { |
28 | } |
29 | |
30 | /*! |
31 | Constructs a browse path target from \a rhs. |
32 | */ |
33 | QOpcUaBrowsePathTarget::QOpcUaBrowsePathTarget(const QOpcUaBrowsePathTarget &rhs) |
34 | : data(rhs.data) |
35 | { |
36 | } |
37 | |
38 | /*! |
39 | Sets the values of \a rhs in this browse path target. |
40 | */ |
41 | QOpcUaBrowsePathTarget &QOpcUaBrowsePathTarget::operator=(const QOpcUaBrowsePathTarget &rhs) |
42 | { |
43 | if (this != &rhs) |
44 | data.operator=(o: rhs.data); |
45 | return *this; |
46 | } |
47 | |
48 | /*! |
49 | Returns \c true if this browse path target has the same value as \a rhs. |
50 | */ |
51 | bool QOpcUaBrowsePathTarget::operator==(const QOpcUaBrowsePathTarget &rhs) const |
52 | { |
53 | return data->targetId == rhs.targetId() && |
54 | data->remainingPathIndex == rhs.remainingPathIndex(); |
55 | } |
56 | |
57 | QOpcUaBrowsePathTarget::~QOpcUaBrowsePathTarget() |
58 | { |
59 | } |
60 | |
61 | /*! |
62 | Returns the index of the first unprocessed element in the browse path. |
63 | If the path was followed to the end, remainingPathIndex has the maximum value of quint32. |
64 | \sa QOpcUaBrowsePathTarget::targetId() |
65 | */ |
66 | quint32 QOpcUaBrowsePathTarget::remainingPathIndex() const |
67 | { |
68 | return data->remainingPathIndex; |
69 | } |
70 | |
71 | /*! |
72 | Sets the remaining path index to \a remainingPathIndex. |
73 | */ |
74 | void QOpcUaBrowsePathTarget::setRemainingPathIndex(quint32 remainingPathIndex) |
75 | { |
76 | data->remainingPathIndex = remainingPathIndex; |
77 | } |
78 | |
79 | /*! |
80 | Returns \c true if the browse path has been fully resolved. |
81 | */ |
82 | bool QOpcUaBrowsePathTarget::isFullyResolved() const |
83 | { |
84 | return (data->remainingPathIndex == (std::numeric_limits<quint32>::max)()); |
85 | } |
86 | |
87 | /*! |
88 | Returns the target of the last reference the server was able to follow. |
89 | If the reference leads to an external server, \e targetId is the id of the first node on that server. |
90 | \sa QOpcUaBrowsePathTarget::remainingPathIndex |
91 | */ |
92 | QOpcUaExpandedNodeId QOpcUaBrowsePathTarget::targetId() const |
93 | { |
94 | return data->targetId; |
95 | } |
96 | |
97 | /*! |
98 | Returns a reference to the target id. |
99 | */ |
100 | QOpcUaExpandedNodeId &QOpcUaBrowsePathTarget::targetIdRef() |
101 | { |
102 | return data->targetId; |
103 | } |
104 | |
105 | /*! |
106 | Sets the node id of the target node to \a targetId. |
107 | */ |
108 | void QOpcUaBrowsePathTarget::setTargetId(const QOpcUaExpandedNodeId &targetId) |
109 | { |
110 | data->targetId = targetId; |
111 | } |
112 | |
113 | QT_END_NAMESPACE |
114 | |