open62541pp 0.16.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
method.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <utility> // forward
4
6#include "open62541pp/config.hpp"
11#include "open62541pp/span.hpp"
12#include "open62541pp/types.hpp"
14
15#ifdef UA_ENABLE_METHODCALLS
16
17namespace opcua {
18class Client;
19} // namespace opcua
20
21namespace opcua::services {
22
23/**
24 * @defgroup Method Method service set
25 * Call (invoke) methods.
26 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.11
27 * @ingroup Services
28 * @{
29 *
30 * @defgroup Call Call service
31 * This Service is used to call (invoke) a list of methods.
32 * @see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.11.2
33 * @{
34 */
35
36/**
37 * Call server methods.
38 * @param connection Instance of type Client
39 * @param request Call request
40 */
41CallResponse call(Client& connection, const CallRequest& request) noexcept;
42
43/**
44 * @copydoc call
45 * @param token @completiontoken{void(CallResponse&)}
46 * @return @asyncresult{CallResponse}
47 */
48template <typename CompletionToken>
49auto callAsync(Client& connection, const CallRequest& request, CompletionToken&& token) {
51 connection, request, std::forward<CompletionToken>(token)
52 );
53}
54
55/**
56 * Call a server method.
57 * The `objectId` must have a `HasComponent` reference to the method specified in `methodId`.
58 *
59 * @param connection Instance of type Server or Client
60 * @param objectId NodeId of the object on which the method is invoked
61 * @param methodId NodeId of the method to invoke
62 * @param inputArguments Input argument values
63 */
64template <typename T>
66 T& connection,
67 const NodeId& objectId,
68 const NodeId& methodId,
69 Span<const Variant> inputArguments
70) noexcept;
71
72/**
73 * @copydoc call(T&, const NodeId&, const NodeId&, Span<const Variant>)
74 * @param token @completiontoken{void(CallMethodResult&)}
75 * @return @asyncresult{CallMethodResult}
76 */
77template <typename CompletionToken>
79 Client& connection,
80 const NodeId& objectId,
81 const NodeId& methodId,
82 Span<const Variant> inputArguments,
83 CompletionToken&& token
84) {
85 auto item = detail::createCallMethodRequest(objectId, methodId, inputArguments);
86 const auto request = detail::createCallRequest(item);
87 return callAsync(
88 connection,
92 std::forward<CompletionToken>(token)
93 }
94 );
95}
96
97/**
98 * @}
99 * @}
100 */
101
102} // namespace opcua::services
103
104#endif
UA_CallMethodResult wrapper class.
UA_CallRequest wrapper class.
UA_CallResponse wrapper class.
High-level client class.
Definition client.hpp:121
UA_NodeId wrapper class.
Definition types.hpp:590
View to a contiguous sequence of objects, similar to std::span in C++20.
Definition span.hpp:26
CallResponse call(Client &connection, const CallRequest &request) noexcept
Call server methods.
auto callAsync(Client &connection, const CallRequest &request, CompletionToken &&token)
Call server methods.
Definition method.hpp:49
UA_CallRequest createCallRequest(UA_CallMethodRequest &item) noexcept
UA_CallMethodRequest createCallMethodRequest(const NodeId &objectId, const NodeId &methodId, Span< const Variant > inputArguments) noexcept
WrapperType wrapSingleResultWithStatus(Response &response) noexcept
auto sendRequestAsync(Client &client, const Request &request, CompletionToken &&token)
Async client service requests.
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.