open62541pp 0.15.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
subscription_context.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <functional>
5
7#include "open62541pp/types_composed.hpp" // StatusChangeNotification
8#include "open62541pp/wrapper.hpp" // asWrapper
9
10struct UA_Client;
11
13
15 bool stale{false};
16 std::function<void(uint32_t subId, StatusChangeNotification&)> statusChangeCallback;
17 std::function<void(uint32_t subId)> deleteCallback;
18
20 [[maybe_unused]] UA_Client* client,
21 uint32_t subId,
22 void* subContext,
23 UA_StatusChangeNotification* notification
24 ) noexcept {
25 if (subContext != nullptr && notification != nullptr) {
26 auto* self = static_cast<SubscriptionContext*>(subContext);
27 self->invoke(
28 self->statusChangeCallback,
29 subId,
31 );
32 }
33 }
34
36 [[maybe_unused]] UA_Client* client, uint32_t subId, void* subContext
37 ) noexcept {
38 if (subContext != nullptr) {
39 auto* self = static_cast<SubscriptionContext*>(subContext);
40 self->invoke(self->deleteCallback, subId);
41 self->stale = true;
42 }
43 }
44};
45
46} // namespace opcua::services::detail
UA_StatusChangeNotification wrapper class.
constexpr WrapperType * asWrapper(NativeType *native) noexcept
Cast native object pointers to Wrapper object pointers.
Definition wrapper.hpp:164
Helper class to map open62541 / C-style callbacks to std::function objects.
void invoke(F &&callback, Args &&... args) const noexcept
static void deleteCallbackNative(UA_Client *client, uint32_t subId, void *subContext) noexcept
std::function< void(uint32_t subId, StatusChangeNotification &)> statusChangeCallback
static void statusChangeCallbackNative(UA_Client *client, uint32_t subId, void *subContext, UA_StatusChangeNotification *notification) noexcept
std::function< void(uint32_t subId)> deleteCallback