PLCnext API Documentation  22.9.0.33
Public Member Functions | Protected 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

Public Member Functions

 NotificationManager (const NotificationManager &)=delete
 
 NotificationManager (NotificationManager &&)=delete
 
NotificationManageroperator= (const NotificationManager &)=delete
 
NotificationManageroperator= (NotificationManager &&)=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...
 
const String GetNotificationName (NotificationNameIdType notificationNameId) const override
 Queries the NotifictionName More...
 
const NotificationNameIdType GetNotificationNameId (const String &notificationName) override
 Queries the id of an NotificationName More...
 
const NotificationNameIdList GetNotificationNameIdsByStatus (const NotificationRegistrationStatus &status) const override
 Queries the ids of Notifications with a given NotificationRegistrationStatus More...
 
const NotificationNameIdList GetAllKnownNotificationNameIds () const override
 Queries of all known NotificationNameIds More...
 
const NotificationRegistrationInfo GetNotificationRegistration (NotificationNameIdType notificationNameId) const override
 Queries information about an Notification More...
 
const PayloadTypeIdType GetPayloadTypeId (const String &payloadTypeName) override
 Query an id for a given PayloadType More...
 
const 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)
 

Protected Member Functions

 NotificationManager (size_t nonBlockingNotificationSendingProxyQueueLength=128)
 
- Protected Member Functions inherited from Arp::AppDomainSingleton< NotificationManager >
 AppDomainSingleton (void)=default
 The protected default constructor. More...
 
 ~AppDomainSingleton (void)=default
 The protected default destructor. More...
 

Friends

class AppDomainSingleton< NotificationManager >
 
class NonBlockingNotificationSendingAdapter
 

Additional Inherited Members

- Static Public Member Functions inherited from Arp::AppDomainSingleton< NotificationManager >
static NotificationManager & CreateInstance (Args &&... args)
 Creates this singleton instance. More...
 
static bool IsCreated (void)
 Determines if this singleton instance is created yet. More...
 
static NotificationManager & GetInstance (void)
 Gets a reference of the singleton instance. More...
 
static NotificationManager * GetInstancePtr (void)
 Gets a pointer to the singleton instance. More...
 
static void DisposeInstance (void)
 Disposes this singleton instance. More...
 
- Protected Types inherited from Arp::AppDomainSingleton< NotificationManager >
typedef AppDomainSingleton< NotificationManager > SingletonBase
 Defines this type to be used from derived classes. More...
 

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()

const 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()

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

Queries the NotifictionName

Parameters
notificationNameIdNotificationNameId
Returns
NotificationName

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

◆ GetNotificationNameId()

const 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()

const 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()

const 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()

const 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()

const 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 file: