open62541pp 0.17.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.7
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.
22 explicit Event(Server& connection, const NodeId& eventType = ObjectTypeId::BaseEventType);
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
66 ByteString trigger(const NodeId& originId = ObjectId::Server);
67
68private:
69 Server* connection_;
70 NodeId id_;
71};
72
73/// @relates Event
74bool operator==(const Event& lhs, const Event& rhs) noexcept;
75
76/// @relates Event
77bool operator!=(const Event& lhs, const Event& rhs) noexcept;
78
79} // namespace opcua
UA_ByteString wrapper class.
Definition types.hpp:531
UA_DateTime wrapper class.
Definition types.hpp:390
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.
bool operator!=(const Event &lhs, const Event &rhs) noexcept
bool operator==(const Event &lhs, const Event &rhs) noexcept
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:1062
UA_NodeId wrapper class.
Definition types.hpp:666
UA_QualifiedName wrapper class.
Definition types.hpp:1011
High-level server class.
Definition server.hpp:132
UA_Variant wrapper class.
Definition types.hpp:1176