7 #include "Arp/System/Commons/Threading/LockGuard.hpp"
8 #include "Arp/System/Commons/Threading/Mutex.hpp"
9 #include "Arp/System/Nm/NonBlockingNotificationRegistration3ArgumentsBuffer.hpp"
10 #include "Arp/System/Nm/NonBlockingNotificationRegistration3Base.hpp"
11 #include "Arp/System/Nm/NonBlockingNotificationSendingAdapter.hpp"
12 #include "Arp/System/Nm/NotificationRegistrationBase.hpp"
15 namespace Arp {
namespace System {
namespace Nm
18 class NotificationManager;
49 template<
typename PayloadType,
typename ArgumentsType =
typename PayloadType::ArgumentsType>
60 using payload_type = PayloadType;
61 using arguments_type = ArgumentsType;
63 static_assert(std::is_constructible<PayloadType,
typename std::add_const<ArgumentsType>::type>::value,
64 "PayloadType must be constructible by const ArgumentsType!");
65 static_assert(std::is_default_constructible<ArgumentsType>::value,
"ArgumentType must be default constructible");
66 static_assert(std::is_copy_assignable<ArgumentsType>::value,
"ArgumentsType must be copy assignable");
72 size_t argumentsBufferCapacity, std::unique_ptr<NonBlockingNotificationSendingAdapter> adapter);
91 template<
typename... Args>
98 template<
typename... Args>
105 void DisposeImpl()
override;
115 std::shared_ptr<ArgumentsBuffer> argumentsBuffer =
nullptr;
118 template<
typename PayloadType,
typename ArgumentsType>
120 const String& notificationName,
const String& senderName,
Severity severity,
size_t argumentsBufferCapacity,
121 std::unique_ptr<NonBlockingNotificationSendingAdapter> adapter)
122 : base_type(notificationName, senderName, severity),
124 argumentsBuffer(
std::make_shared<ArgumentsBuffer>(argumentsBufferCapacity))
126 this->Register(notificationName, senderName, severity, this->
GetPayloadTypeId());
129 template<
typename PayloadType,
typename ArgumentsType>
131 NonBlockingNotificationRegistration3<PayloadType, ArgumentsType>&& other) noexcept
132 : base_type(std::move(other)),
133 NonBlockingNotificationRegistration3Base(std::move(other)),
134 argumentsBuffer(std::move(other.argumentsBuffer))
138 template<
typename PayloadType,
typename ArgumentsType>
139 NonBlockingNotificationRegistration3<PayloadType, ArgumentsType>::~NonBlockingNotificationRegistration3()
144 template<
typename PayloadType,
typename ArgumentsType>
145 NonBlockingNotificationRegistration3<PayloadType, ArgumentsType>&
146 NonBlockingNotificationRegistration3<PayloadType, ArgumentsType>::operator=(
147 NonBlockingNotificationRegistration3<PayloadType, ArgumentsType>&& other) noexcept
154 base_type::operator=(std::move(other));
155 NonBlockingNotificationRegistration3Base::operator=(std::move(other));
157 this->argumentsBuffer = std::move(other.argumentsBuffer);
162 template<
typename PayloadType,
typename ArgumentsType>
163 void NonBlockingNotificationRegistration3<PayloadType, ArgumentsType>::DisposeImpl()
168 template<
typename PayloadType,
typename ArgumentsType>
169 template<
typename... Args>
173 return this->SendNotificationWithTimestamp(
DateTime::Now(), std::forward<Args>(args)...);
176 template<
typename PayloadType,
typename ArgumentsType>
177 template<
typename... Args>
180 const DateTime& timestamp, Args&& ... args)
182 static_assert(std::is_constructible<ArgumentsType, Args...>::value,
183 "The ArgumentsType must be constructible by the passed arguments (Args).");
185 if (this->IsReadyToSend())
187 auto insertResult = this->argumentsBuffer->Insert(ArgumentsType{std::forward<Args>(args)...});
188 this->SendNotificationInternal(
189 timestamp, this->argumentsBuffer, insertResult, &NonBlockingNotificationRegistration3::CreatePayload);
193 this->ResetFutureNotificationId();
195 return this->GetFutureNotificationId();
198 template<
typename PayloadType,
typename ArgumentsType>
201 return this->GetNotificationNameIdInternal();
204 template<
typename PayloadType,
typename ArgumentsType>
206 CreatePayloadFunctorArg arg)
208 auto buffer = std::dynamic_pointer_cast<ArgumentsBuffer>(arg.BufferPtr);
214 auto removeResult = buffer->Remove(arg.Index);
215 if (!removeResult.IsValid)
220 return PayloadType{removeResult.Args}.MoveOutRawPayload();
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.
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:114
Definition: NonBlockingNotificationRegistration3ArgumentsBuffer.hpp:20
Internal class for pimpl pattern
Definition: NonBlockingNotificationRegistration3Base.hpp:19
Proxy object for a non-blocking NotificationRegistration
Definition: NonBlockingNotificationRegistration3.hpp:53
Future< NotificationIdType > SendNotification(Args &&... args)
Sends a notification
Definition: NonBlockingNotificationRegistration3.hpp:170
NonBlockingNotificationRegistration3()=default
Creates an empty NotificationRegistration
NotificationNameIdType GetNotificationNameId() const override
Returns the NotificationNameId
Definition: NonBlockingNotificationRegistration3.hpp:199
Future< NotificationIdType > SendNotificationWithTimestamp(const DateTime ×tamp, Args &&... args)
Sends a notification with a specified timestamp
Definition: NonBlockingNotificationRegistration3.hpp:179
Primary access to the NotificationManager
Definition: NotificationManager.hpp:49
Base class with common behavior of NotificationRegistration and NonBlockingNotificationRegistration
Definition: NotificationRegistrationBase.hpp:22
PayloadTypeIdType GetPayloadTypeId() const
Returns the PayloadTypeId
Definition: NotificationRegistrationBase.hpp:119
@ System
System components used by the System, Device, Plc or Io domains.
Severity
Enumeration of Severities for notifications
Definition: Severity.hpp:15
std::vector< Arp::System::Rsc::Services::RscVariant< RawPayloadTypeLength > > RawPayloadType
type for the internally transferred payloads
Definition: NotificationManagerTypes.hpp:34
Root namespace for the PLCnext API
Namespace of the C++ standard library
Definition: NonBlockingNotificationSendingAdapter.hpp:28