10#include "Arp/System/Nm/INotificationSending.hpp"
11#include "Arp/System/Nm/NotificationRegistrationBase.hpp"
13namespace Arp {
namespace System {
namespace Nm
29template<
typename PayloadType>
37 using payload_type = PayloadType;
65 template<
typename... Args>
72 template<
typename... Args>
80 void DisposeImpl()
override;
89template<
typename PayloadType>
92 :
base_type(notificationName, senderName, severity),
93 NotificationSending(¬ificationSending)
99template<
typename PayloadType>
102 : base_type(
std::move(other)),
103 NotificationSending(
std::exchange(other.NotificationSending, nullptr)),
109template<
typename PayloadType>
110NotificationRegistration<PayloadType>::~NotificationRegistration()
116template<
typename PayloadType>
117NotificationRegistration<PayloadType>& NotificationRegistration<PayloadType>::operator=(
118 NotificationRegistration<PayloadType>&& other)
125 base_type::operator=(std::move(other));
127 this->NotificationSending = std::exchange(other.NotificationSending,
nullptr);
134template<
typename PayloadType>
135void NotificationRegistration<PayloadType>::Initialize()
137 if ((this->NotificationSending !=
nullptr) && (!this->NotificationNameId.IsValid()))
139 this->NotificationNameId = this->NotificationSending->RegisterNotification(
140 this->NotificationName, this->SenderName, this->severity, this->GetPayloadTypeId());
145template<
typename PayloadType>
146void NotificationRegistration<PayloadType>::DisposeImpl()
148 if ((this->NotificationSending !=
nullptr) && (this->NotificationNameId.IsValid()))
150 this->NotificationSending->UnregisterNotification(this->NotificationNameId);
156template<
typename PayloadType>
157template<
typename... Args>
160 return this->SendNotificationWithTimestamp(
DateTime::GetUtcNow(), std::forward<Args>(args)...);
164template<
typename PayloadType>
165template<
typename... Args>
167 const DateTime& timestamp, Args&& ... args)
169 if (this->NotificationSending ==
nullptr)
173 if (!this->NotificationNameId.IsValid())
177 return this->NotificationSending->SendNotification(
178 this->NotificationNameId, timestamp, PayloadType{std::forward<Args>(args)...});
182template<
class PayloadType>
185 return this->NotificationNameId;
The class contains date and time informations.
Definition: DateTime.hpp:46
static DateTime GetUtcNow(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:24
Proxy object for a NotificationRegistration
Definition: NotificationRegistration.hpp:32
NotificationNameIdType GetNotificationNameId() const override
Returns the NotificationNameId
Definition: NotificationRegistration.hpp:183
NotificationIdType SendNotificationWithTimestamp(const DateTime ×tamp, Args &&... args)
Sends a notification with a specified timestamp
Definition: NotificationRegistration.hpp:166
NotificationRegistration()=default
Creates an empty NotificationRegistration
NotificationIdType SendNotification(Args &&... args)
Sends a notification
Definition: NotificationRegistration.hpp:158
@ System
System components used by the System, Device, Plc or Io domains.
enum ARP_CXX_SYMBOL_EXPORT Severity
Enumeration of Severities for notifications
Definition: Severity.hpp:14
IdType< Arp::uint64, struct NotificationIdTag > NotificationIdType
type for Notification ids
Definition: NotificationManagerTypes.hpp:19
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