open62541pp 0.16.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
view.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <utility>
5#include <vector>
6
14#include "open62541pp/span.hpp"
15#include "open62541pp/types.hpp"
17
18namespace opcua {
19class Client;
20class Server;
21} // namespace opcua
22
23namespace opcua::services {
24
25/**
26 * @defgroup View View service set
27 * Browse the address space / view created by a server.
28 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8
29 * @ingroup Services
30 * @{
31 */
32
33/**
34 * @defgroup Browse Browse service
35 * Discover references of nodes.
36 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.2
37 * @{
38 */
39
40/**
41 * Discover the references of one or more nodes (client only).
42 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.2
43 * @param connection Instance of type Client
44 * @param request Browse request
45 */
46BrowseResponse browse(Client& connection, const BrowseRequest& request) noexcept;
47
48/**
49 * @copydoc browse
50 * @param token @completiontoken{void(BrowseResponse&)}
51 * @return @asyncresult{BrowseResponse}
52 */
53template <typename CompletionToken>
54auto browseAsync(Client& connection, const BrowseRequest& request, CompletionToken&& token) {
56 connection, request, std::forward<CompletionToken>(token)
57 );
58}
59
60/**
61 * Discover the references of a specified node.
62 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.2
63 * @param connection Instance of type Server or Client
64 * @param bd Browse description
65 * @param maxReferences The maximum number of references to return (0 if no limit)
66 */
67template <typename T>
68BrowseResult browse(T& connection, const BrowseDescription& bd, uint32_t maxReferences) noexcept;
69
70/**
71 * @copydoc browse(T&, const BrowseDescription&, uint32_t)
72 * @param token @completiontoken{void(BrowseResult&)}
73 * @return @asyncresult{BrowseResult}
74 */
75template <typename CompletionToken>
77 Client& connection, const BrowseDescription& bd, uint32_t maxReferences, CompletionToken&& token
78) {
79 const auto request = detail::createBrowseRequest(bd, maxReferences);
80 return browseAsync(
81 connection,
85 std::forward<CompletionToken>(token)
86 )
87 );
88}
89
90/**
91 * @}
92 * @defgroup BrowseNext BrowseNext service
93 * Request the next set of a Browse or BrowseNext response information that is too large to be sent
94 * in a single response. Discover references of nodes.
95 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.3
96 * @{
97 */
98
99/**
100 * Request the next sets of @ref browse / @ref browseNext responses (client only).
101 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.3
102 * @param connection Instance of type Client
103 * @param request Browse request
104 */
105BrowseNextResponse browseNext(Client& connection, const BrowseNextRequest& request) noexcept;
106
107/**
108 * @copydoc browseNext
109 * @param token @completiontoken{void(BrowseNextResponse&)}
110 * @return @asyncresult{BrowseNextResponse}
111 */
112template <typename CompletionToken>
114 Client& connection, const BrowseNextRequest& request, CompletionToken&& token
115) {
117 connection, request, std::forward<CompletionToken>(token)
118 );
119}
120
121/**
122 * Request the next set of a @ref browse or @ref browseNext response.
123 * The response might get split up if the information is too large to be sent in a single response.
124 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.3
125 * @param connection Instance of type Server or Client
126 * @param releaseContinuationPoint Free resources in server if `true`, get next result if `false`
127 * @param continuationPoint Continuation point from a preview browse/browseNext request
128 */
129template <typename T>
131 T& connection, bool releaseContinuationPoint, const ByteString& continuationPoint
132) noexcept;
133
134/**
135 * @copydoc browseNext(T&, bool, const ByteString&)
136 * @param token @completiontoken{void(BrowseResult&)}
137 * @return @asyncresult{BrowseResult}
138 */
139template <typename CompletionToken>
141 Client& connection,
142 bool releaseContinuationPoint,
143 const ByteString& continuationPoint,
144 CompletionToken&& token
145) {
146 const auto request = detail::createBrowseNextRequest(
147 releaseContinuationPoint, continuationPoint
148 );
149 return browseNextAsync(
150 connection,
154 std::forward<CompletionToken>(token)
155 )
156 );
157}
158
159/**
160 * @}
161 * @defgroup TranslateBrowsePathsToNodeIds TranslateBrowsePathsToNodeIds service
162 * Request that the server translates browse paths to node ids.
163 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.4
164 * @{
165 */
166
167/**
168 * Translate browse paths to NodeIds (client only).
169 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.4
170 * @param connection Instance of type Client
171 * @param request Request
172 */
174 Client& connection, const TranslateBrowsePathsToNodeIdsRequest& request
175) noexcept;
176
177/**
178 * @copydoc translateBrowsePathsToNodeIds
179 * @param token @completiontoken{void(TranslateBrowsePathsToNodeIdsResponse&)}
180 * @return @asyncresult{TranslateBrowsePathsToNodeIdsResponse}
181 */
182template <typename CompletionToken>
184 Client& connection, const TranslateBrowsePathsToNodeIdsRequest& request, CompletionToken&& token
185) {
189 connection, request, std::forward<CompletionToken>(token)
190 );
191}
192
193/**
194 * Translate a browse path to NodeIds.
195 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.4
196 * @param connection Instance of type Server or Client
197 * @param browsePath Browse path (starting node & relative path)
198 */
199template <typename T>
200BrowsePathResult translateBrowsePathToNodeIds(T& connection, const BrowsePath& browsePath) noexcept;
201
202/**
203 * @copydoc translateBrowsePathToNodeIds
204 * @param token @completiontoken{void(BrowsePathResult&)}
205 * @return @asyncresult{BrowsePathResult}
206 */
207template <typename CompletionToken>
209 Client& connection, const BrowsePath& browsePath, CompletionToken&& token
210) {
211 const auto request = detail::createTranslateBrowsePathsToNodeIdsRequest(browsePath);
213 connection,
219 std::forward<CompletionToken>(token)
220 )
221 );
222}
223
224/**
225 * A simplified version of @ref translateBrowsePathToNodeIds.
226 *
227 * The relative path is specified using browse names instead of the RelativePath structure.
228 * The list of browse names is equivalent to a RelativePath that specifies forward references which
229 * are subtypes of the HierarchicalReferences ReferenceTypeId.
230 *
231 * @param connection Instance of type Server or Client
232 * @param origin Starting node of the browse path
233 * @param browsePath Browse path as a list of browse names
234 */
235template <typename T>
237 T& connection, const NodeId& origin, Span<const QualifiedName> browsePath
238) {
239 return translateBrowsePathToNodeIds(connection, detail::createBrowsePath(origin, browsePath));
240}
241
242/**
243 * @copydoc browseSimplifiedBrowsePath
244 * @param token @completiontoken{void(BrowsePathResult&)}
245 * @return @asyncresult{BrowsePathResult}
246 */
247template <typename CompletionToken>
249 Client& connection,
250 const NodeId& origin,
251 Span<const QualifiedName> browsePath,
252 CompletionToken&& token
253) {
255 connection,
256 detail::createBrowsePath(origin, browsePath),
257 std::forward<CompletionToken>(token)
258 );
259}
260
261/**
262 * @}
263 * @defgroup RegisterNodes RegisterNodes service
264 * Register nodes for efficient access operations.
265 * Clients shall unregister unneeded nodes immediately to free up resources.
266 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.5
267 * @{
268 */
269
270/**
271 * Register nodes for efficient access operations (client only).
272 * @param connection Instance of type Client
273 * @param request Request
274 */
276 Client& connection, const RegisterNodesRequest& request
277) noexcept;
278
279/**
280 * @copydoc registerNodes
281 * @param token @completiontoken{void(RegisterNodesResponse&)}
282 * @return @asyncresult{RegisterNodesResponse}
283 */
284template <typename CompletionToken>
286 Client& connection, const RegisterNodesRequest& request, CompletionToken&& token
287) {
289 connection, request, std::forward<CompletionToken>(token)
290 );
291}
292
293/**
294 * @}
295 * @defgroup UnregisterNodes UnregisterNodes service
296 * Unregister nodes that have been obtained via the RegisterNodes service.
297 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.6
298 * @{
299 */
300
301/**
302 * Unregister nodes (client only).
303 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.6
304 * @param connection Instance of type Client
305 * @param request Request
306 */
308 Client& connection, const UnregisterNodesRequest& request
309) noexcept;
310
311/**
312 * @copydoc unregisterNodes
313 * @param token @completiontoken{void(UnregisterNodesResponse&)}
314 * @return @asyncresult{UnregisterNodesResponse}
315 */
316template <typename CompletionToken>
318 Client& connection, const UnregisterNodesRequest& request, CompletionToken&& token
319) {
321 connection, request, std::forward<CompletionToken>(token)
322 );
323}
324
325/**
326 * @}
327 */
328
329/* ----------------------------------- Non-standard functions ----------------------------------- */
330
331/**
332 * Discover all the references of a specified node (without calling @ref browseNext).
333 * @copydetails browse(T&, const BrowseDescription&, uint32_t)
334 * @ingroup Browse
335 */
336template <typename T>
338 T& connection, const BrowseDescription& bd, uint32_t maxReferences = 0
339);
340
341/**
342 * Discover child nodes recursively (non-standard).
343 *
344 * Possible loops (that can occur for non-hierarchical references) are handled internally. Every
345 * node is added at most once to the results array. Nodes are only added if they match the
346 * `nodeClassMask` in the BrowseDescription. However, child nodes are still recursed into if the
347 * NodeClass does not match. So it is possible, for example, to get all VariableNodes below a
348 * certain ObjectNode, with additional objects in the hierarchy below.
349 *
350 * @note No implementation for `Client`.
351 *
352 * @param connection Instance of type Server
353 * @param bd Browse description
354 * @see UA_Server_browseRecursive
355 * @ingroup Browse
356 */
357[[deprecated("will be removed in the future, use UA_Server_browseRecursive instead")]]
359 Server& connection, const BrowseDescription& bd
360);
361
362/**
363 * @}
364 */
365
366} // namespace opcua::services
UA_BrowseDescription wrapper class.
UA_BrowseNextRequest wrapper class.
UA_BrowseNextResponse wrapper class.
UA_BrowsePathResult wrapper class.
UA_BrowsePath wrapper class.
UA_BrowseRequest wrapper class.
UA_BrowseResponse wrapper class.
UA_BrowseResult wrapper class.
UA_ByteString wrapper class.
Definition types.hpp:490
High-level client class.
Definition client.hpp:121
UA_NodeId wrapper class.
Definition types.hpp:590
UA_RegisterNodesRequest wrapper class.
UA_RegisterNodesResponse wrapper class.
The template class Result encapsulates a StatusCode and optionally a value.
Definition result.hpp:53
High-level server class.
Definition server.hpp:132
View to a contiguous sequence of objects, similar to std::span in C++20.
Definition span.hpp:26
UA_TranslateBrowsePathsToNodeIdsRequest wrapper class.
UA_TranslateBrowsePathsToNodeIdsResponse wrapper class.
UA_UnregisterNodesRequest wrapper class.
UA_UnregisterNodesResponse wrapper class.
BrowseNextResponse browseNext(Client &connection, const BrowseNextRequest &request) noexcept
Request the next sets of browse / browseNext responses (client only).
auto browseNextAsync(Client &connection, const BrowseNextRequest &request, CompletionToken &&token)
Request the next sets of browse / browseNext responses (client only).
Definition view.hpp:113
auto browseAsync(Client &connection, const BrowseRequest &request, CompletionToken &&token)
Discover the references of one or more nodes (client only).
Definition view.hpp:54
Result< std::vector< ReferenceDescription > > browseAll(T &connection, const BrowseDescription &bd, uint32_t maxReferences=0)
Discover all the references of a specified node (without calling browseNext).
BrowseResponse browse(Client &connection, const BrowseRequest &request) noexcept
Discover the references of one or more nodes (client only).
Result< std::vector< ExpandedNodeId > > browseRecursive(Server &connection, const BrowseDescription &bd)
Discover child nodes recursively (non-standard).
@ TranslateBrowsePathsToNodeIdsRequest
RegisterNodesResponse registerNodes(Client &connection, const RegisterNodesRequest &request) noexcept
Register nodes for efficient access operations (client only).
auto registerNodesAsync(Client &connection, const RegisterNodesRequest &request, CompletionToken &&token)
Register nodes for efficient access operations (client only).
Definition view.hpp:285
BrowsePathResult translateBrowsePathToNodeIds(T &connection, const BrowsePath &browsePath) noexcept
Translate a browse path to NodeIds.
auto translateBrowsePathsToNodeIdsAsync(Client &connection, const TranslateBrowsePathsToNodeIdsRequest &request, CompletionToken &&token)
Translate browse paths to NodeIds (client only).
Definition view.hpp:183
TranslateBrowsePathsToNodeIdsResponse translateBrowsePathsToNodeIds(Client &connection, const TranslateBrowsePathsToNodeIdsRequest &request) noexcept
Translate browse paths to NodeIds (client only).
auto translateBrowsePathToNodeIdsAsync(Client &connection, const BrowsePath &browsePath, CompletionToken &&token)
Translate a browse path to NodeIds.
Definition view.hpp:208
auto browseSimplifiedBrowsePathAsync(Client &connection, const NodeId &origin, Span< const QualifiedName > browsePath, CompletionToken &&token)
A simplified version of translateBrowsePathToNodeIds.
Definition view.hpp:248
BrowsePathResult browseSimplifiedBrowsePath(T &connection, const NodeId &origin, Span< const QualifiedName > browsePath)
A simplified version of translateBrowsePathToNodeIds.
Definition view.hpp:236
UnregisterNodesResponse unregisterNodes(Client &connection, const UnregisterNodesRequest &request) noexcept
Unregister nodes (client only).
auto unregisterNodesAsync(Client &connection, const UnregisterNodesRequest &request, CompletionToken &&token)
Unregister nodes (client only).
Definition view.hpp:317
UA_BrowseRequest createBrowseRequest(const BrowseDescription &bd, uint32_t maxReferences) noexcept
WrapperType wrapSingleResultWithStatus(Response &response) noexcept
BrowsePath createBrowsePath(const NodeId &origin, Span< const QualifiedName > browsePath)
auto sendRequestAsync(Client &client, const Request &request, CompletionToken &&token)
Async client service requests.
UA_TranslateBrowsePathsToNodeIdsRequest createTranslateBrowsePathsToNodeIdsRequest(const BrowsePath &browsePath) noexcept
UA_BrowseNextRequest createBrowseNextRequest(bool releaseContinuationPoint, const ByteString &continuationPoint) noexcept
OPC UA services as free functions.
Definition attribute.hpp:22
Client * asWrapper(UA_Client *client) noexcept
Convert native UA_Client pointer to its wrapper instance.
Special token to transform async results within the completion handler.