9#include "Arp/System/Nm/INotificationSending.hpp"
10#include "Arp/System/Nm/NotificationRegistrationBase.hpp"
12namespace Arp {
namespace System {
namespace Nm
28template<
typename PayloadType>
36 using payload_type = PayloadType;
54 template<
typename... Args>
57 template<
typename... Args>
64 void DisposeImpl()
override;
79template<
typename PayloadType>
82 :
base_type(notificationName, senderName, severity),
83 NotificationSending(¬ificationSending)
89template<
typename PayloadType>
92 : base_type(
std::move(other)),
93 NotificationSending(
std::exchange(other.NotificationSending, nullptr)),
99template<
typename PayloadType>
106template<
typename PayloadType>
115 base_type::operator=(std::move(other));
117 this->NotificationSending = std::exchange(other.NotificationSending,
nullptr);
124template<
typename PayloadType>
125void NotificationRegistration<PayloadType>::Initialize()
127 if ((this->NotificationSending !=
nullptr) && (!this->NotificationNameId.IsValid()))
129 this->NotificationNameId = this->NotificationSending->RegisterNotification(
130 this->NotificationName, this->SenderName, this->severity, this->GetPayloadTypeId());
135template<
typename PayloadType>
136void NotificationRegistration<PayloadType>::DisposeImpl()
138 if ((this->NotificationSending !=
nullptr) && (this->NotificationNameId.IsValid()))
140 this->NotificationSending->UnregisterNotification(this->NotificationNameId);
150template<
typename PayloadType>
151template<
typename... Args>
154 return this->SendNotificationWithTimestamp(
DateTime::GetUtcNow(), std::forward<Args>(args)...);
162template<
typename PayloadType>
163template<
typename... Args>
165 const DateTime& timestamp, Args&& ... args)
167 if (this->NotificationSending ==
nullptr)
171 if (!this->NotificationNameId.IsValid())
175 return this->NotificationSending->SendNotification(
176 this->NotificationNameId, timestamp, PayloadType{std::forward<Args>(args)...});
181template<
class PayloadType>
184 return this->NotificationNameId;
This class contains date and time informations.
Definition: DateTime.hpp:27
static DateTime GetUtcNow(void)
Gets the current time in UTC.
Definition: DateTime.cpp:186
This class represents the Arp String. The implementation is based on std::string.
Definition: String.hpp:39
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: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:164
NotificationRegistration()=default
Creates an empty NotificationRegistration
NotificationIdType SendNotification(Args &&... args)
Sends a notification
Definition: NotificationRegistration.hpp:152
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:17
IdType< Arp::uint32, struct NotificationNameIdTag > NotificationNameIdType
type for Notification name ids
Definition: NotificationManagerTypes.hpp:20
Root namespace for the PLCnext API
Namespace of the C++ standard library