PLCnext API Documentation 25.0.2.69
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
Arp::System::Nm::NotificationManager Class Reference

Primary access to the NotificationManager More...

#include <NotificationManager.hpp>

Inheritance diagram for Arp::System::Nm::NotificationManager:
Inheritance graph

Classes

class  Impl
 

Public Types

using Instance = NotificationManager
 
using InstancePtr = std::unique_ptr< Instance >
 

Public Member Functions

 NotificationManager (size_t nonBlockingNotificationSendingProxyQueueLength=128)
 
 NotificationManager (const NotificationManager &)=delete
 
 NotificationManager (NotificationManager &&) noexcept=delete
 
NotificationManageroperator= (const NotificationManager &)=delete
 
NotificationManageroperator= (NotificationManager &&) noexcept=delete
 
template<typename PayloadType >
NotificationRegistration< PayloadType > CreateNotificationRegistration (const String &notificationName, const String &senderName, Severity severity)
 Creates a NotificationRegistration proxy More...
 
template<typename PayloadType >
NonBlockingNotificationRegistration< PayloadType > CreateNonBlockingNotificationRegistration (const String &notificationName, const String &senderName, Severity severity)
 Creates a NonBlockingNotificationRegistration proxy More...
 
template<typename PayloadType >
NonBlockingNotificationRegistration< PayloadType > CreateNonBlockingNotificationRegistration2 (const String &notificationName, const String &senderName, Severity severity)
 Creates a NonBlockingNotificationRegistration proxy More...
 
template<typename PayloadType , typename ArgumentsType = typename PayloadType::ArgumentsType>
NonBlockingNotificationRegistration3< PayloadType, ArgumentsType > CreateNonBlockingNotificationRegistration3 (const String &notificationName, const String &senderName, Severity severity, size_t argumentsBufferCapacity=GetDefaultArgumentsBufferCapacity())
 Creates a NonBlockingNotificationRegistration3 proxy More...
 
NotificationSubscriber CreateNotificationSubscriber (const String &notificationName)
 Creates a NotificationSubscriber proxy More...
 
NotificationNameIdType RegisterNotification (const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId) override
 Registers a new Notification More...
 
void UnregisterNotification (NotificationNameIdType notificationNameId) override
 Unregisters a Nototification More...
 
NotificationIdType SendNotification (NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType &payload) override
 Sends a notification More...
 
NotificationIdType SendNotification (NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload &payload) override
 Sends a notification More...
 
Future< NotificationNameIdTypeNonBlockingRegisterNotification (const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId) override
 Registers a new Notification (non-blocking) More...
 
void NonBlockingRegisterNotification (const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId, Future< NotificationNameIdType > result)
 
Future< void > NonBlockingUnregisterNotification (NotificationNameIdType notificationNameId) override
 Unregisters a Nototification (non-blocking) More...
 
void NonBlockingUnregisterNotification (NotificationNameIdType notificationNameId, Future< void > result)
 
Future< NotificationIdTypeNonBlockingSendNotification (NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType &payload) override
 Sends a notification (non-blocking) More...
 
void NonBlockingSendNotification (NotificationNameIdType notificationNameId, Arp::DateTime timestamp, std::function< RawPayloadType()> createPayloadFunctor, Future< NotificationIdType > result)
 
Future< NotificationIdTypeNonBlockingSendNotification (NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload &payload) override
 Sends a notification (non-blocking) More...
 
String GetNotificationName (NotificationNameIdType notificationNameId) const override
 Queries the NotifictionName More...
 
NotificationNameIdType GetNotificationNameId (const String &notificationName) override
 Queries the id of an NotificationName More...
 
NotificationNameIdList GetNotificationNameIdsByStatus (const NotificationRegistrationStatus &status) const override
 Queries the ids of Notifications with a given NotificationRegistrationStatus More...
 
NotificationNameIdList GetAllKnownNotificationNameIds () const override
 Queries of all known NotificationNameIds More...
 
NotificationRegistrationInfo GetNotificationRegistration (NotificationNameIdType notificationNameId) const override
 Queries information about an Notification More...
 
PayloadTypeIdType GetPayloadTypeId (const String &payloadTypeName) override
 Query an id for a given PayloadType More...
 
String GetPayloadTypeName (const PayloadTypeIdType &payloadTypeId) const override
 Query the payload type name of a given id More...
 
Arp::uint64 GetNumberOfSubmittedNotifications () const override
 Returns the number of Notifications submitted since startup of the controller More...
 
NotificationNameIdType Subscribe (const String &notificationName, INotificationSubscriber *subscriber) override
 Subscribe to a Notification More...
 
void Unsubscribe (NotificationNameIdType notificationNameId, INotificationSubscriber *subscriber) override
 Unsubscribe from a Notification More...
 
void UnsubscribeFromAll (INotificationSubscriber *subscriber) override
 Unsubscribe from all Notification More...
 
void ReplaceSubscriber (INotificationSubscriber *oldSubscriber, INotificationSubscriber *newSubscriber)
 
virtual NotificationNameIdType RegisterNotification (const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId)=0
 Registers a new Notification More...
 
virtual void UnregisterNotification (NotificationNameIdType notificationNameId)=0
 Unregisters a Nototification More...
 
virtual NotificationIdType SendNotification (NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType &payload)=0
 Sends a notification More...
 
virtual NotificationIdType SendNotification (NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload &payload)=0
 Sends a notification More...
 
virtual Future< NotificationNameIdTypeNonBlockingRegisterNotification (const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId)=0
 Registers a new Notification (non-blocking) More...
 
virtual Future< void > NonBlockingUnregisterNotification (NotificationNameIdType notificationNameId)=0
 Unregisters a Nototification (non-blocking) More...
 
virtual Future< NotificationIdTypeNonBlockingSendNotification (NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType &payload)=0
 Sends a notification (non-blocking) More...
 
virtual Future< NotificationIdTypeNonBlockingSendNotification (NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload &payload)=0
 Sends a notification (non-blocking) More...
 
virtual String GetNotificationName (NotificationNameIdType notificationNameId) const =0
 Queries the NotifictionName More...
 
virtual NotificationNameIdType GetNotificationNameId (const String &notificationName)=0
 Queries the id of an NotificationName More...
 
virtual NotificationNameIdList GetNotificationNameIdsByStatus (const NotificationRegistrationStatus &status) const =0
 Queries the ids of Notifications with a given NotificationRegistrationStatus More...
 
virtual NotificationNameIdList GetAllKnownNotificationNameIds () const =0
 Queries of all known NotificationNameIds More...
 
virtual NotificationRegistrationInfo GetNotificationRegistration (NotificationNameIdType notificationNameId) const =0
 Queries information about an Notification More...
 
virtual PayloadTypeIdType GetPayloadTypeId (const String &payloadTypeName)=0
 Query an id for a given PayloadType More...
 
virtual String GetPayloadTypeName (const PayloadTypeIdType &payloadTypeId) const =0
 Query the payload type name of a given id More...
 
virtual Arp::uint64 GetNumberOfSubmittedNotifications () const =0
 Returns the number of Notifications submitted since startup of the controller More...
 
virtual NotificationNameIdType Subscribe (const String &notificationName, INotificationSubscriber *subscriber)=0
 Subscribe to a Notification More...
 
virtual void Unsubscribe (NotificationNameIdType notificationNameId, INotificationSubscriber *subscriber)=0
 Unsubscribe from a Notification More...
 
virtual void UnsubscribeFromAll (INotificationSubscriber *subscriber)=0
 Unsubscribe from all Notification More...
 

Static Public Member Functions

static InstanceCreateInstance (size_t nonBlockingNotificationSendingProxyQueueLength=128)
 
static bool IsCreated (void)
 
static void DisposeInstance (void)
 
static InstanceGetInstance (void)
 

Friends

class NonBlockingNotificationSendingAdapter
 

Detailed Description

Primary access to the NotificationManager

The NotificationManager provides a communication system with 1:n communication and loose coupling between components. Notifications contain some meta data like name and timestamp and also a payload defined by the sender. The payload should be defined by deriving a class from SpecializedPayload. See namespace Arp::System::NmPayload for examples.

The NotificationManager is implemented as a singleton. To access it use NotificationManager::GetInstance().

To send notifications they must be registered in advance. The simplest way is to use a NotificationRegistration object created by CreateNotificationRegistration(...). This acts a a proxy like a smart pointer.

To receive a notification a class must implement the INotificationSubscriber interface and subscribe to a Notification. This can be simplified using CreateNotificationSubscriber(...) method to create a NotificationSubscriber and add a callback function to its OnNotification event.

Member Function Documentation

◆ CreateNonBlockingNotificationRegistration()

template<typename PayloadType >
NonBlockingNotificationRegistration< PayloadType > Arp::System::Nm::NotificationManager::CreateNonBlockingNotificationRegistration ( const String notificationName,
const String senderName,
Severity  severity 
)

Creates a NonBlockingNotificationRegistration proxy

Parameters
notificationNamename of the notification (e.g. Arp.System.Nm.SomethingInterestingHappened)
senderNamename of the sender of the notification
severityseverity of the notification

Deprecated! May cause jitter up to multiple milliseconds. Use CreateNonBlockingNotificationRegistration3 instead

The template parameter PayloadType indicates the Payload class to be used when sending Notifications.

◆ CreateNonBlockingNotificationRegistration2()

template<typename PayloadType >
NonBlockingNotificationRegistration< PayloadType > Arp::System::Nm::NotificationManager::CreateNonBlockingNotificationRegistration2 ( const String notificationName,
const String senderName,
Severity  severity 
)

Creates a NonBlockingNotificationRegistration proxy

Parameters
notificationNamename of the notification (e.g. Arp.System.Nm.SomethingInterestingHappened)
senderNamename of the sender of the notification
severityseverity of the notification

Deprecated! May cause jitter up to multiple milliseconds. Use CreateNonBlockingNotificationRegistration3 instead

The template parameter PayloadType indicates the Payload class to be used when sending Notifications. When the proxy is created with this function, the future objects returned from the SendNotification function are always the same object! This avoids creating new future objects and gives a significant performance gain. If you need different future objects use CreateNonBlockingNotificationRegistration.

◆ CreateNonBlockingNotificationRegistration3()

template<typename PayloadType , typename ArgumentsType >
NonBlockingNotificationRegistration3< PayloadType, ArgumentsType > Arp::System::Nm::NotificationManager::CreateNonBlockingNotificationRegistration3 ( const String notificationName,
const String senderName,
Severity  severity,
size_t  argumentsBufferCapacity = GetDefaultArgumentsBufferCapacity() 
)

Creates a NonBlockingNotificationRegistration3 proxy

Parameters
notificationNamename of the notification (e.g. Arp.System.Nm.SomethingInterestingHappened)
senderNamename of the sender of the notification
severityseverity of the notification

The template parameter PayloadType indicates the Payload class to be used when sending Notifications.

The typename ArgumentsType must define one type to be used to create the PayloadType.

See NonBlockingNotificationRegistration3's documentation for further details.

◆ CreateNotificationRegistration()

template<typename PayloadType >
NotificationRegistration< PayloadType > Arp::System::Nm::NotificationManager::CreateNotificationRegistration ( const String notificationName,
const String senderName,
Severity  severity 
)

Creates a NotificationRegistration proxy

Parameters
notificationNamename of the notification (e.g. Arp.System.Nm.SomethingInterestingHappened)
senderNamename of the sender of the notification
severityseverity of the notification

The template parameter PayloadType indicates the Payload class to be used when sending Notifications.

◆ CreateNotificationSubscriber()

NotificationSubscriber Arp::System::Nm::NotificationManager::CreateNotificationSubscriber ( const String notificationName)

Creates a NotificationSubscriber proxy

Parameters
notificationNameNotification name to subscribe to

◆ GetAllKnownNotificationNameIds()

NotificationNameIdList Arp::System::Nm::NotificationManager::GetAllKnownNotificationNameIds ( ) const
overridevirtual

Queries of all known NotificationNameIds

Returns
collection of all known NotificationNameIds

Implements Arp::System::Nm::INotificationManagerInfo.

◆ GetNotificationName()

String Arp::System::Nm::NotificationManager::GetNotificationName ( NotificationNameIdType  notificationNameId) const
overridevirtual

Queries the NotifictionName

Parameters
notificationNameIdNotificationNameId
Returns
NotificationName

Implements Arp::System::Nm::INotificationManagerInfo.

◆ GetNotificationNameId()

NotificationNameIdType Arp::System::Nm::NotificationManager::GetNotificationNameId ( const String notificationName)
overridevirtual

Queries the id of an NotificationName

Parameters
notificationNameNotificationName
Returns
NotificationNameId

Implements Arp::System::Nm::INotificationManagerInfo.

◆ GetNotificationNameIdsByStatus()

NotificationNameIdList Arp::System::Nm::NotificationManager::GetNotificationNameIdsByStatus ( const NotificationRegistrationStatus status) const
overridevirtual

Queries the ids of Notifications with a given NotificationRegistrationStatus

Parameters
statusstatus of the queried Notifications
Returns
collection of matching NotificationNameIds

Implements Arp::System::Nm::INotificationManagerInfo.

◆ GetNotificationRegistration()

NotificationRegistrationInfo Arp::System::Nm::NotificationManager::GetNotificationRegistration ( NotificationNameIdType  notificationNameId) const
overridevirtual

Queries information about an Notification

Parameters
notificationNameIdNotificationNameId
Returns
data structure to describe the Notification

Implements Arp::System::Nm::INotificationManagerInfo.

◆ GetNumberOfSubmittedNotifications()

Arp::uint64 Arp::System::Nm::NotificationManager::GetNumberOfSubmittedNotifications ( ) const
overridevirtual

Returns the number of Notifications submitted since startup of the controller

Returns
number of submitted notifications

Implements Arp::System::Nm::INotificationManagerInfo.

◆ GetPayloadTypeId()

PayloadTypeIdType Arp::System::Nm::NotificationManager::GetPayloadTypeId ( const String payloadTypeName)
overridevirtual

Query an id for a given PayloadType

Parameters
payloadTypeNameName fo the payload type
Returns
id of the payload type

Implements Arp::System::Nm::INotificationManagerInfo.

◆ GetPayloadTypeName()

String Arp::System::Nm::NotificationManager::GetPayloadTypeName ( const PayloadTypeIdType payloadTypeId) const
overridevirtual

Query the payload type name of a given id

Parameters
payloadTypeIdid of the payload type
Returns
name of the payload type

Implements Arp::System::Nm::INotificationManagerInfo.

◆ NonBlockingRegisterNotification()

Future< NotificationNameIdType > Arp::System::Nm::NotificationManager::NonBlockingRegisterNotification ( const String notificationName,
const String senderName,
Severity  severity,
PayloadTypeIdType  payloadTypeId 
)
overridevirtual

Registers a new Notification (non-blocking)

Parameters
notificationNamename of the notification (e.g. Arp.System.Nm.SomethingInterestingHappened)
senderNamename of the sender of the notification
severityseverity of the notification
payloadTypeIdid of the payload type
Returns
NotificationNameId (Future), necessary for sending and unregistering

Implements Arp::System::Nm::INonBlockingNotificationSending.

◆ NonBlockingSendNotification() [1/2]

Future< NotificationIdType > Arp::System::Nm::NotificationManager::NonBlockingSendNotification ( NotificationNameIdType  notificationNameId,
Arp::DateTime  timestamp,
const IPayload payload 
)
overridevirtual

Sends a notification (non-blocking)

Parameters
notificationNameIdid of the NotificationName to send
timestampCurrent timestamp
payloadpayload to send
Returns
NotificationId (Future)

Implements Arp::System::Nm::INonBlockingNotificationSending.

◆ NonBlockingSendNotification() [2/2]

Future< NotificationIdType > Arp::System::Nm::NotificationManager::NonBlockingSendNotification ( NotificationNameIdType  notificationNameId,
Arp::DateTime  timestamp,
const RawPayloadType payload 
)
overridevirtual

Sends a notification (non-blocking)

Parameters
notificationNameIdid of the NotificationName to send
timestampCurrent timestamp
payloadpayload to send
Returns
NotificationId (Future)

Implements Arp::System::Nm::INonBlockingNotificationSending.

◆ NonBlockingUnregisterNotification()

Future< void > Arp::System::Nm::NotificationManager::NonBlockingUnregisterNotification ( NotificationNameIdType  notificationNameId)
overridevirtual

Unregisters a Nototification (non-blocking)

Parameters
notificationNameIdid of the NotificationName to unregister
Returns
Future to check for exceptions or completion

Implements Arp::System::Nm::INonBlockingNotificationSending.

◆ RegisterNotification()

NotificationNameIdType Arp::System::Nm::NotificationManager::RegisterNotification ( const String notificationName,
const String senderName,
Severity  severity,
PayloadTypeIdType  payloadTypeId 
)
overridevirtual

Registers a new Notification

Parameters
notificationNamename of the notification (e.g. Arp.System.Nm.SomethingInterestingHappened)
senderNamename of the sender of the notification
severityseverity of the notification
payloadTypeIdid of the payload type
Returns
NotificationNameId, necessary for sending and unregistering

Implements Arp::System::Nm::INotificationSending.

◆ SendNotification() [1/2]

NotificationIdType Arp::System::Nm::NotificationManager::SendNotification ( NotificationNameIdType  notificationNameId,
Arp::DateTime  timestamp,
const IPayload payload 
)
overridevirtual

Sends a notification

Parameters
notificationNameIdid of the NotificationName to send
timestampCurrent timestamp
payloadpayload to send
Returns
NotificationId

Implements Arp::System::Nm::INotificationSending.

◆ SendNotification() [2/2]

NotificationIdType Arp::System::Nm::NotificationManager::SendNotification ( NotificationNameIdType  notificationNameId,
Arp::DateTime  timestamp,
const RawPayloadType payload 
)
overridevirtual

Sends a notification

Parameters
notificationNameIdid of the NotificationName to send
timestampCurrent timestamp
payloadpayload to send
Returns
NotificationId

Implements Arp::System::Nm::INotificationSending.

◆ Subscribe()

NotificationNameIdType Arp::System::Nm::NotificationManager::Subscribe ( const String notificationName,
INotificationSubscriber subscriber 
)
overridevirtual

Subscribe to a Notification

Parameters
notificationNameName of the Notification to subscribe to
subscriberPointer to the ISubscriber (!= nullptr)

Implements Arp::System::Nm::INotificationReceiving.

◆ UnregisterNotification()

void Arp::System::Nm::NotificationManager::UnregisterNotification ( NotificationNameIdType  notificationNameId)
overridevirtual

Unregisters a Nototification

Parameters
notificationNameIdid of the NotificationName to unregister

Implements Arp::System::Nm::INotificationSending.

◆ Unsubscribe()

void Arp::System::Nm::NotificationManager::Unsubscribe ( NotificationNameIdType  notificationNameId,
INotificationSubscriber subscriber 
)
overridevirtual

Unsubscribe from a Notification

Parameters
notificationNameName of the Notification to unsubscribe from
subscriberPointer to the ISubscriber (!= nullptr)

Implements Arp::System::Nm::INotificationReceiving.

◆ UnsubscribeFromAll()

void Arp::System::Nm::NotificationManager::UnsubscribeFromAll ( INotificationSubscriber subscriber)
overridevirtual

Unsubscribe from all Notification

Parameters
subscriberPointer to the ISubscriber (!= nullptr)

This function should be called before Subscriber is destructed!

Implements Arp::System::Nm::INotificationReceiving.


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