PLCnext API Documentation  22.9.0.33
Public Types | Public Member Functions | Protected Types | Friends | List of all members
Arp::System::Nm::NonBlockingNotificationRegistration3< PayloadType, ArgumentsType > Class Template Reference

Proxy object for a non-blocking NotificationRegistration More...

#include <NonBlockingNotificationRegistration3.hpp>

Inheritance diagram for Arp::System::Nm::NonBlockingNotificationRegistration3< PayloadType, ArgumentsType >:
Inheritance graph

Public Types

using payload_type = PayloadType
 
using arguments_type = ArgumentsType
 

Public Member Functions

 NonBlockingNotificationRegistration3 ()=default
 Creates an empty NotificationRegistration More...
 
 NonBlockingNotificationRegistration3 (const NonBlockingNotificationRegistration3 &)=delete
 
 NonBlockingNotificationRegistration3 (NonBlockingNotificationRegistration3 &&other) noexcept
 
NonBlockingNotificationRegistration3operator= (const NonBlockingNotificationRegistration3 &)=delete
 
NonBlockingNotificationRegistration3operator= (NonBlockingNotificationRegistration3 &&other) noexcept
 
template<typename... Args>
Future< NotificationIdTypeSendNotification (Args &&... args)
 Sends a notification More...
 
template<typename... Args>
Future< NotificationIdTypeSendNotificationWithTimestamp (const DateTime &timestamp, Args &&... args)
 Sends a notification with a specified timestamp More...
 
NotificationNameIdType GetNotificationNameId () const override
 Returns the NotificationNameId More...
 
- Public Member Functions inherited from Arp::System::Nm::NotificationRegistrationBase< NonBlockingNotificationRegistration3< PayloadType, typename PayloadType::ArgumentsType > >
 NotificationRegistrationBase (const NotificationRegistrationBase &)=delete
 
NotificationRegistrationBaseoperator= (NotificationRegistrationBase &&other)=default
 
NotificationRegistrationBaseoperator= (const NotificationRegistrationBase &)=delete
 
void Dispose () noexcept
 Unregisters the Notification and release all resources More...
 
const String GetNotificationName () const
 Returns the notification name More...
 
const String GetSenderName () const
 Returns the sender name More...
 
Severity GetSeverity () const
 Returns the Severity More...
 
PayloadTypeIdType GetPayloadTypeId () const
 Returns the PayloadTypeId More...
 
- Public Member Functions inherited from Arp::System::Nm::NonBlockingNotificationRegistration3Base
 NonBlockingNotificationRegistration3Base (const NonBlockingNotificationRegistration3Base &other)=delete
 
 NonBlockingNotificationRegistration3Base (NonBlockingNotificationRegistration3Base &&other) noexcept
 
NonBlockingNotificationRegistration3Baseoperator= (const NonBlockingNotificationRegistration3Base &other)=delete
 
NonBlockingNotificationRegistration3Baseoperator= (NonBlockingNotificationRegistration3Base &&other) noexcept
 
bool IsCompleted () const
 Returns true if the last operation is completed More...
 
NotificationIdType GetLastNotificationId () const
 Returns the id of the last send Notification More...
 

Protected Types

using ArgumentsBuffer = NonBlockingNotificationRegistration3ArgumentsBuffer< ArgumentsType >
 
- Protected Types inherited from Arp::System::Commons::Diagnostics::Logging::Loggable< Derived, IsSingleton, IsStaticClass >
typedef Loggable< Derived, IsSingleton, IsStaticClass > LoggableBase
 

Friends

class NotificationManager
 

Additional Inherited Members

- Protected Member Functions inherited from Arp::System::Commons::Diagnostics::Logging::Loggable< Derived, IsSingleton, IsStaticClass >
 Loggable (bool initialize=true)
 
- Protected Member Functions inherited from Arp::System::Nm::NonBlockingNotificationRegistration3Base
 NonBlockingNotificationRegistration3Base (std::unique_ptr< NonBlockingNotificationSendingAdapter > notificationSending)
 
bool HasImpl () const
 
NotificationNameIdType GetNotificationNameIdInternal () const
 
const Future< NotificationIdType > & GetFutureNotificationId () const
 
void ResetFutureNotificationId ()
 
void Register (const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId)
 
void Unregister ()
 
void SendNotificationInternal (const DateTime &timestamp, std::shared_ptr< NonBlockingNotificationRegistration3ArgumentsBufferBase > argumentsBuffer, NonBlockingNotificationRegistration3ArgumentsBufferBase::InsertResult argumentsBufferInsertResult, NonBlockingNotificationSendingAdapter::CreatePayloadFunctor createPayloadFunctor)
 
bool IsReadyToSend () const
 
- Static Protected Member Functions inherited from Arp::System::Commons::Diagnostics::Logging::Loggable< Derived, IsSingleton, IsStaticClass >
static void InitializeLogger (const char *loggerName=nullptr)
 
- Static Protected Attributes inherited from Arp::System::Commons::Diagnostics::Logging::Loggable< Derived, IsSingleton, IsStaticClass >
static Logger< Derived > log
 

Detailed Description

template<typename PayloadType, typename ArgumentsType = typename PayloadType::ArgumentsType>
class Arp::System::Nm::NonBlockingNotificationRegistration3< PayloadType, ArgumentsType >

Proxy object for a non-blocking NotificationRegistration

This proxy class represents a Notification registration like a smart pointer. The Notification is registered in the constructor and unregistered in the destructor. Notifications can be send using the SendNotification method. The template parameter PayloadType indicates the Payload class to be used when sending Notifications.

This class supports move semantics. Ownership of a notification registration is transfered by a move operation.

Use NotificationManager::CreateNonBlockingNotificationRegistration3 to create instances of this type.

This class does not allocate memory to send notifications. This is required to use it in real-time context. When SendNotification is called a request to send a notification is inserted into a queue. A worker thread will send the notification later. Creating payload objects is expensive. Therefore they are created by the worker thread. The arguments to create the payload object (type ArgumentsType) are stored in a buffer until the payload object is created. ArgumentsType shall be small and shall not allocate dynamic memory.

The PayloadType must have a constructor with exactly one parameter of ArgumentsType. This will be called to construct the payload object.

Sending strings as payload is supported. Since Arp::String and std::string allocate memory on the heap the strings shall be passed as const char* via ArgumentsType. The pointers must stay valid until the worker thread has constructed the payload object. Use IsCompleted() to check whether the last SendNotification call has been processed by the worker thread. It is recommended to use constant strings or literals.

When a call to SendNotification cannot be executed (e.g. too many entries in the queue of the worker thread or in the buffer for ArgumentsType) an invalid Future<NotificationIdType> is returned. Use IsValid() to check it. If the future is invalid, wait for the worker thread to process some requests and try again later.

Constructor & Destructor Documentation

◆ NonBlockingNotificationRegistration3()

template<typename PayloadType , typename ArgumentsType = typename PayloadType::ArgumentsType>
Arp::System::Nm::NonBlockingNotificationRegistration3< PayloadType, ArgumentsType >::NonBlockingNotificationRegistration3 ( )
default

Creates an empty NotificationRegistration

To be used as a class member, when it cannot be initialized directly. Use move semantics to transfer ownership from another object.

Member Function Documentation

◆ GetNotificationNameId()

template<typename PayloadType , typename ArgumentsType >
NotificationNameIdType Arp::System::Nm::NonBlockingNotificationRegistration3< PayloadType, ArgumentsType >::GetNotificationNameId
overridevirtual

◆ SendNotification()

template<typename PayloadType , typename ArgumentsType >
template<typename... Args>
Future< NotificationIdType > Arp::System::Nm::NonBlockingNotificationRegistration3< PayloadType, ArgumentsType >::SendNotification ( Args &&...  args)

Sends a notification

Parameters
argsArguments to the constructor of PayloadType (variadic)
Returns
NotificationId (Future)

Uses the current time as timestamp.

◆ SendNotificationWithTimestamp()

template<typename PayloadType , typename ArgumentsType >
template<typename... Args>
Future< NotificationIdType > Arp::System::Nm::NonBlockingNotificationRegistration3< PayloadType, ArgumentsType >::SendNotificationWithTimestamp ( const DateTime timestamp,
Args &&...  args 
)

Sends a notification with a specified timestamp

Parameters
timestamptimestamp to be used
argsArguments to the constructor of PayloadType (variadic)
Returns
NotificationId (Future)

The documentation for this class was generated from the following file: