9 #include "Arp/System/Nm/INotificationSending.hpp"
10 #include "Arp/System/Nm/NotificationRegistrationBase.hpp"
12 namespace Arp {
namespace System {
namespace Nm
28 template<
typename PayloadType>
36 using payload_type = PayloadType;
64 template<
typename... Args>
71 template<
typename... Args>
79 void DisposeImpl()
override;
88 template<
typename PayloadType>
91 :
base_type(notificationName, senderName, severity),
92 NotificationSending(¬ificationSending)
98 template<
typename PayloadType>
101 : base_type(
std::move(other)),
102 NotificationSending(
std::exchange(other.NotificationSending, nullptr)),
108 template<
typename PayloadType>
109 NotificationRegistration<PayloadType>::~NotificationRegistration()
115 template<
typename PayloadType>
116 NotificationRegistration<PayloadType>& NotificationRegistration<PayloadType>::operator=(
117 NotificationRegistration<PayloadType>&& other)
124 base_type::operator=(std::move(other));
126 this->NotificationSending = std::exchange(other.NotificationSending,
nullptr);
133 template<
typename PayloadType>
134 void NotificationRegistration<PayloadType>::Initialize()
136 if ((this->NotificationSending !=
nullptr) && (!this->NotificationNameId.IsValid()))
138 this->NotificationNameId = this->NotificationSending->RegisterNotification(
139 this->NotificationName, this->SenderName, this->severity, this->GetPayloadTypeId());
144 template<
typename PayloadType>
145 void NotificationRegistration<PayloadType>::DisposeImpl()
147 if ((this->NotificationSending !=
nullptr) && (this->NotificationNameId.IsValid()))
149 this->NotificationSending->UnregisterNotification(this->NotificationNameId);
155 template<
typename PayloadType>
156 template<
typename... Args>
159 return this->SendNotificationWithTimestamp(
DateTime::Now(), std::forward<Args>(args)...);
163 template<
typename PayloadType>
164 template<
typename... Args>
166 const DateTime& timestamp, Args&& ... args)
168 if (this->NotificationSending ==
nullptr)
172 if (!this->NotificationNameId.IsValid())
176 return this->NotificationSending->SendNotification(
177 this->NotificationNameId, timestamp, PayloadType{std::forward<Args>(args)...});
181 template<
class PayloadType>
184 return this->NotificationNameId;
The class contains date and time informations.
Definition: DateTime.hpp:45
static DateTime Now(void)
Gets the current time as DateTime, expressed as the UTC time.
Interface for sending of notifications
Definition: INotificationSending.hpp:21
Base class with common behavior of NotificationRegistration and NonBlockingNotificationRegistration
Definition: NotificationRegistrationBase.hpp:22
Proxy object for a NotificationRegistration
Definition: NotificationRegistration.hpp:31
NotificationNameIdType GetNotificationNameId() const override
Returns the NotificationNameId
Definition: NotificationRegistration.hpp:182
NotificationIdType SendNotificationWithTimestamp(const DateTime ×tamp, Args &&... args)
Sends a notification with a specified timestamp
Definition: NotificationRegistration.hpp:165
NotificationRegistration()=default
Creates an empty NotificationRegistration
NotificationIdType SendNotification(Args &&... args)
Sends a notification
Definition: NotificationRegistration.hpp:157
@ System
System components used by the System, Device, Plc or Io domains.
IdType< Arp::uint64, struct NotificationIdTag > NotificationIdType
type for Notification ids
Definition: NotificationManagerTypes.hpp:19
Severity
Enumeration of Severities for notifications
Definition: Severity.hpp:15
IdType< Arp::uint32, struct NotificationNameIdTag > NotificationNameIdType
type for Notification name ids
Definition: NotificationManagerTypes.hpp:22
Root namespace for the PLCnext API
Namespace of the C++ standard library