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>
134 argumentsBuffer(std::move(other.argumentsBuffer))
138 template<
typename PayloadType,
typename ArgumentsType>
144 template<
typename PayloadType,
typename ArgumentsType>
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>
168 template<
typename PayloadType,
typename ArgumentsType>
169 template<
typename... 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>
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();
void Dispose() noexcept
Unregisters the Notification and release all resources
Definition: NotificationRegistrationBase.hpp:78
The class contains date and time informations.
Definition: DateTime.hpp:44
Definition: NonBlockingNotificationSendingAdapter.hpp:27
Internal class for pimpl pattern
Definition: NonBlockingNotificationRegistration3Base.hpp:18
Future< NotificationIdType > SendNotification(Args &&... args)
Sends a notification
Definition: NonBlockingNotificationRegistration3.hpp:170
Definition: NonBlockingNotificationRegistration3ArgumentsBuffer.hpp:18
std::vector< Arp::System::Rsc::Services::RscVariant< RawPayloadTypeLength > > RawPayloadType
type for the internally transferred payloads
Definition: NotificationManagerTypes.hpp:34
static DateTime Now(void)
Gets the current time as DateTime, expressed as the UTC time.
Severity
Enumeration of Severities for notifications
Definition: Severity.hpp:15
Root namespace for the PLCnext API
Base class with common behavior of NotificationRegistration and NonBlockingNotificationRegistration
Definition: NotificationRegistrationBase.hpp:19
PayloadTypeIdType GetPayloadTypeId() const
Returns the PayloadTypeId
Definition: NotificationRegistrationBase.hpp:119
NonBlockingNotificationRegistration3()=default
Creates an empty NotificationRegistration
NotificationNameIdType GetNotificationNameId() const override
Returns the NotificationNameId
Definition: NonBlockingNotificationRegistration3.hpp:199
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:114
System components used by the System, Device, Plc or Io domains.
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:42
Proxy object for a non-blocking NotificationRegistration
Definition: NonBlockingNotificationRegistration3.hpp:50