11 #include "Arp/System/Nm/NonBlockingNotificationSendingAdapter.hpp"    12 #include "Arp/System/Nm/NotificationRegistrationBase.hpp"    15 namespace Arp { 
namespace System { 
namespace Nm
    31 template<
typename PayloadType>
    40     using payload_type = PayloadType;
    72     template<
typename... Args>
    79     template<
typename... Args>
    81         const DateTime& timestamp, Args&& ... args);
    94     void DisposeImpl() 
override;
    96     bool IsNotificationNameIdValid() 
const;
   112     State state = State::Uninitialized;
   116 template<
typename PayloadType>
   120     : 
base_type(notificationName, senderName, severity), NotificationSending(¬ificationSending)
   125 template<
typename PayloadType>
   129     : 
base_type(notificationName, senderName, severity),
   130       NotificationSending(adapter)
   136 template<
typename PayloadType>
   140       NotificationSending(std::move(other.NotificationSending)),
   141       futureNotificationNameId(std::move(other.futureNotificationNameId)),
   142       futureNotificationId(std::move(other.futureNotificationId)),
   143       futureUnregister(std::move(other.futureUnregister)),
   144       state(std::move(other.state))
   146     other.NotificationSending = 
nullptr;
   147     other.state = State::Uninitialized;
   151 template<
typename PayloadType>
   158 template<
typename PayloadType>
   167     base_type::operator=(std::move(other));
   169     this->NotificationSending = std::move(other.NotificationSending);
   170     other.NotificationSending = 
nullptr;
   172     this->futureNotificationNameId = std::move(other.futureNotificationNameId);
   173     this->futureNotificationId = std::move(other.futureNotificationId);
   174     this->futureUnregister = std::move(other.futureUnregister);
   176     this->state = std::move(other.state);
   177     other.state = State::Uninitialized;
   183 template<
typename PayloadType>
   186     if (this->NotificationSending != 
nullptr && !this->IsNotificationNameIdValid())
   190         if (adapterPtr != 
nullptr)
   193                     this->severity, this->GetPayloadTypeId(), this->futureNotificationNameId);
   197             this->futureNotificationNameId =
   198                 this->NotificationSending->NonBlockingRegisterNotification(this->NotificationName,
   199                         this->SenderName, this->severity, this->GetPayloadTypeId());
   201         this->state = State::RegisterCalled;
   206 template<
typename PayloadType>
   209     if (this->NotificationSending != 
nullptr && this->IsNotificationNameIdValid())
   213         if (adapterPtr != 
nullptr)
   216                 this->GetNotificationNameId(), this->futureUnregister);
   220             this->futureUnregister = this->NotificationSending->NonBlockingUnregisterNotification(
   221                                          this->GetNotificationNameId());
   225         this->state = State::UnregisterCalled;
   227         if (adapterPtr != 
nullptr)
   229             delete this->NotificationSending;
   231         this->NotificationSending = 
nullptr;
   236 template<
typename PayloadType>
   237 template<
typename... Args>
   241     return this->SendNotificationWithTimestamp(DateTime::Now(), std::forward<Args>(args)...);
   245 template<
typename PayloadType>
   246 template<
typename... Args>
   249     const DateTime& timestamp, Args&& ... args)
   251     if (this->NotificationSending == 
nullptr || !this->IsNotificationNameIdValid())
   257 #ifndef ARP_CXX_COMPILER_MSC   261         if (adapterPtr != 
nullptr)
   263             std::function<RawPayloadType()> createPayloadFunctor = [args...]()
   265                 return PayloadType{args...}.MoveOutRawPayload();
   267             adapterPtr->NonBlockingSendNotification(this->futureNotificationNameId.GetValue(),
   268                                                     timestamp, std::move(createPayloadFunctor), this->futureNotificationId);
   271 #endif // #ifndef ARP_CXX_COMPILER_MSC   273             this->futureNotificationId = this->NotificationSending->NonBlockingSendNotification(
   274                                              this->futureNotificationNameId.GetValue(), timestamp,
   275                                              PayloadType{std::forward<Args>(args)...});
   277         this->state = State::SendCalled;
   279     return this->futureNotificationId;
   283 template<
class PayloadType>
   287     return this->futureNotificationNameId.GetValue();
   291 template<
class PayloadType>
   294     return this->futureNotificationId.GetValue();
   298 template<
class PayloadType>
   303         case State::Uninitialized:
   306         case State::RegisterCalled:
   307             return this->futureNotificationNameId.HasValue();
   309         case State::SendCalled:
   310             return this->futureNotificationId.HasValue();
   312         case State::UnregisterCalled:
   313             return this->futureUnregister.HasValue();
   321 template<
class PayloadType>
   324     return this->futureNotificationNameId.HasValue() &&
   325            this->futureNotificationNameId.GetValue().IsValid();
 Interface for non blocking sending of Notifications
Definition: INonBlockingNotificationSending.hpp:21
 
NotificationNameIdType GetNotificationNameId() const override
Returns the NotificationNameId
Definition: NonBlockingNotificationRegistration.hpp:285
 
Future< void > NonBlockingUnregisterNotification(NotificationNameIdType notificationNameId) override
Unregisters a Nototification (non-blocking)
 
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:198
 
bool IsCompleted() const
Returns true if the last operation is completed
Definition: NonBlockingNotificationRegistration.hpp:299
 
The class contains date and time informations.
Definition: DateTime.hpp:43
 
Proxy object for a non-blocking NotificationRegistration
Definition: NonBlockingNotificationRegistration.hpp:32
 
NonBlockingNotificationRegistration()=default
Creates an empty NotificationRegistration
 
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
 
NotificationIdType GetLastNotificationId() const
Returns the id of the last send Notification
Definition: NonBlockingNotificationRegistration.hpp:292
 
Future< NotificationIdType > SendNotificationWithTimestamp(const DateTime ×tamp, Args &&... args)
Sends a notification with a specified timestamp
Definition: NonBlockingNotificationRegistration.hpp:248
 
Future< NotificationIdType > SendNotification(Args &&... args)
Sends a notification
Definition: NonBlockingNotificationRegistration.hpp:238
 
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:114
 
Future< NotificationNameIdType > NonBlockingRegisterNotification(const String ¬ificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId) override
Registers a new Notification (non-blocking)
 
System components used by the System, Device, Plc or Io domains.
 
Adapter for INonBlockingNotificationSending with additional functions
Definition: NonBlockingNotificationSendingAdapter.hpp:24
 
Representation of an unique id
Definition: IdType.hpp:28