open62541pp 0.17.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
server_context.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <atomic>
4#include <functional>
5#include <map>
6#include <memory>
7#include <mutex>
8#include <utility> // pair
9#include <vector>
10
11#include "open62541pp/config.hpp"
15#include "open62541pp/detail/open62541/common.h" // UA_AccessControl
18#include "open62541pp/types.hpp" // NodeId, Variant
19#include "open62541pp/ua/types.hpp" // IntegerId
20
21namespace opcua::detail {
22
23struct NodeContext {
24 ValueCallbackBase* valueCallback{nullptr};
25 DataSourceBase* dataSource{nullptr};
26#ifdef UA_ENABLE_METHODCALLS
27 std::function<void(Span<const Variant> input, Span<Variant> output)> methodCallback;
28#endif
29};
30
31
32struct SessionRegistry {
33 using Context = void*;
34
35 decltype(UA_AccessControl::activateSession) activateSessionUser{nullptr};
36 decltype(UA_AccessControl::closeSession) closeSessionUser{nullptr};
37 std::map<NodeId, Context> sessions;
38 std::mutex mutex;
39};
40
41/**
42 * Internal storage for Server class.
43 */
44struct ServerContext {
45 ExceptionCatcher exceptionCatcher;
46 SessionRegistry sessionRegistry;
47 std::atomic<bool> running{false};
48 std::mutex mutexRun;
49
50 std::vector<DataType> dataTypes;
51 std::unique_ptr<UA_DataTypeArray> dataTypeArray;
52
53#ifdef UA_ENABLE_SUBSCRIPTIONS
54 using SubId = IntegerId; // always 0
55 using MonId = IntegerId;
56 using SubMonId = std::pair<SubId, MonId>;
57 ContextMap<SubMonId, services::detail::MonitoredItemContext> monitoredItems;
58#endif
59
60 ContextMap<NodeId, NodeContext> nodeContexts;
61};
62
63} // namespace opcua::detail
Span(Container &) -> Span< typename Container::value_type >
uint32_t IntegerId
IntegerId.
Definition types.hpp:123
void(* closeSession)(UA_Server *server, UA_AccessControl *ac, const UA_NodeId *sessionId, void *sessionContext)
UA_StatusCode(* activateSession)(UA_Server *server, UA_AccessControl *ac, const UA_EndpointDescription *endpointDescription, const UA_ByteString *secureChannelRemoteCertificate, const UA_NodeId *sessionId, const UA_ExtensionObject *userIdentityToken, void **sessionContext)