open62541pp 0.16.0
C++ wrapper of open62541
Loading...
Searching...
No Matches
event.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string_view>
5
8
9namespace opcua {
10
11class Server;
12
13/**
14 * Create and trigger events.
15 *
16 * @see https://reference.opcfoundation.org/Core/Part3/v105/docs/4.6
17 * @see https://reference.opcfoundation.org/Core/Part5/v105/docs/6.4.2
18 */
19class Event {
20public:
21 /// Create an event with the underlying (abstract) node representation.
23
24 /// Delete the node representation of the event.
26
27 Event(const Event&) = default;
28 Event(Event&&) noexcept = default;
29
30 Event& operator=(const Event&) = delete;
31 Event& operator=(Event&&) noexcept = delete;
32
33 /// Get the server instance.
34 Server& connection() noexcept {
35 return *connection_;
36 }
37
38 /// Get the server instance.
39 const Server& connection() const noexcept {
40 return *connection_;
41 }
42
43 /// Get the NodeId of the underlying node representation.
44 const NodeId& id() const noexcept {
45 return id_;
46 }
47
48 /// Set the source name (optional).
49 Event& writeSourceName(std::string_view sourceName);
50
51 /// Set the time of the event (UTC).
53
54 /// Set the urgency/priority of the event from 1 (lowest) to 1000 (highest).
55 Event& writeSeverity(uint16_t severity);
56
57 /// Set a human-readable and localizable text description of the event.
59
60 /// Set arbitrary properties of the event (for custom event types).
61 Event& writeProperty(const QualifiedName& propertyName, const Variant& value);
62
63 /// Trigger the event.
64 /// @param originId Origin node of the event (requires `EventNotifier` attribute)
65 /// @return Unique `EventId` generated by server
67
68private:
69 Server* connection_;
70 NodeId id_;
71};
72
73bool operator==(const Event& lhs, const Event& rhs) noexcept;
74bool operator!=(const Event& lhs, const Event& rhs) noexcept;
75
76} // namespace opcua
UA_ByteString wrapper class.
Definition types.hpp:490
UA_DateTime wrapper class.
Definition types.hpp:354
Create and trigger events.
Definition event.hpp:19
Event & writeSourceName(std::string_view sourceName)
Set the source name (optional).
Event & writeSeverity(uint16_t severity)
Set the urgency/priority of the event from 1 (lowest) to 1000 (highest).
const Server & connection() const noexcept
Get the server instance.
Definition event.hpp:39
Event & writeMessage(const LocalizedText &message)
Set a human-readable and localizable text description of the event.
const NodeId & id() const noexcept
Get the NodeId of the underlying node representation.
Definition event.hpp:44
Server & connection() noexcept
Get the server instance.
Definition event.hpp:34
Event(Server &connection, const NodeId &eventType=ObjectTypeId::BaseEventType)
Create an event with the underlying (abstract) node representation.
Event(const Event &)=default
Event(Event &&) noexcept=default
Event & writeProperty(const QualifiedName &propertyName, const Variant &value)
Set arbitrary properties of the event (for custom event types).
ByteString trigger(const NodeId &originId=ObjectId::Server)
Trigger the event.
~Event()
Delete the node representation of the event.
Event & writeTime(DateTime time)
Set the time of the event (UTC).
UA_LocalizedText wrapper class.
Definition types.hpp:837
UA_NodeId wrapper class.
Definition types.hpp:590
UA_QualifiedName wrapper class.
Definition types.hpp:800
High-level server class.
Definition server.hpp:132
UA_Variant wrapper class.
Definition types.hpp:887
bool operator!=(const Client &lhs, const Client &rhs) noexcept
Definition client.hpp:295
bool operator==(const Client &lhs, const Client &rhs) noexcept
Definition client.hpp:291