PLCnext API Documentation 24.0.0.71
NotificationManager.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6
7#pragma once
8
10#include "Arp/System/Core/AppDomainSingleton.hxx"
11#include "Arp/System/Commons/Logging.h"
12
13#include "Arp/System/Nm/INonBlockingNotificationSending.hpp"
14#include "Arp/System/Nm/INotificationManagerInfo.hpp"
15#include "Arp/System/Nm/INotificationReceiving.hpp"
16#include "Arp/System/Nm/INotificationSending.hpp"
17#include "Arp/System/Nm/NonBlockingNotificationRegistration.hpp"
18#include "Arp/System/Nm/NonBlockingNotificationRegistration3.hpp"
19#include "Arp/System/Nm/NonBlockingNotificationSendingAdapter.hpp"
20#include "Arp/System/Nm/NotificationRegistration.hpp"
21#include "Arp/System/Nm/NotificationSubscriber.hpp"
22
23namespace Arp { namespace System { namespace Nm
24{
25
43class ARP_CXX_SYMBOL_EXPORT NotificationManager
44 : public AppDomainSingleton<NotificationManager>
49 , private Loggable<NotificationManager, true>
50{
53
54private:
55 class Impl;
56
57protected:
58 explicit NotificationManager(size_t nonBlockingNotificationSendingProxyQueueLength = 128);
59 ~NotificationManager() override;
60
61public:
64
65 NotificationManager& operator=(const NotificationManager&) = delete;
66 NotificationManager& operator=(NotificationManager&&) = delete;
67
68 // High level operations using proxy objects
76 template<typename PayloadType>
77 NotificationRegistration<PayloadType> CreateNotificationRegistration(
78 const String& notificationName, const String& senderName, Severity severity);
79
91 template<typename PayloadType>
92 NonBlockingNotificationRegistration<PayloadType> CreateNonBlockingNotificationRegistration(
93 const String& notificationName, const String& senderName, Severity severity);
94
110 template<typename PayloadType>
111 NonBlockingNotificationRegistration<PayloadType> CreateNonBlockingNotificationRegistration2(
112 const String& notificationName, const String& senderName, Severity severity);
113
125 template<typename PayloadType, typename ArgumentsType = typename PayloadType::ArgumentsType>
126 NonBlockingNotificationRegistration3<PayloadType, ArgumentsType> CreateNonBlockingNotificationRegistration3(
127 const String& notificationName, const String& senderName, Severity severity,
128 size_t argumentsBufferCapacity = GetDefaultArgumentsBufferCapacity());
129
133
134 // Methods of INotificationSending
135 NotificationNameIdType RegisterNotification(const String& notificationName, const String& senderName,
136 Severity severity, PayloadTypeIdType payloadTypeId) override;
137 void UnregisterNotification(NotificationNameIdType notificationNameId) override;
138
140 NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType& payload) override;
142 NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload& payload) override;
143
144 // Methods of INonBlockingNotificationSending
146 const String& senderName, Severity severity, PayloadTypeIdType payloadTypeId) override;
147
148 void NonBlockingRegisterNotification(const String& notificationName, const String& senderName, Severity severity,
150
152
153 void NonBlockingUnregisterNotification(NotificationNameIdType notificationNameId, Future<void> result);
154
156 NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType& payload) override;
157
158 void NonBlockingSendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp,
159 std::function<RawPayloadType()> createPayloadFunctor, Future<NotificationIdType> result);
160
162 NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload& payload) override;
163
164private:
165 void NonBlockingSendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp,
166 NonBlockingNotificationSendingAdapter::CreatePayloadFunctor createPayloadFunctor,
169
170 static size_t GetDefaultArgumentsBufferCapacity();
171
172public:
173 // Methods of INotificationManagerInfo
174 const String GetNotificationName(NotificationNameIdType notificationNameId) const override;
175 const NotificationNameIdType GetNotificationNameId(const String& notificationName) override;
176
178 const NotificationRegistrationStatus& status) const override;
181 NotificationNameIdType notificationNameId) const override;
182
183 const PayloadTypeIdType GetPayloadTypeId(const String& payloadTypeName) override;
184 const String GetPayloadTypeName(const PayloadTypeIdType& payloadTypeId) const override;
185
187
188 // Methods of INotificationReceiving
189 NotificationNameIdType Subscribe(const String& notificationName, INotificationSubscriber* subscriber) override;
190 void Unsubscribe(NotificationNameIdType notificationNameId, INotificationSubscriber* subscriber) override;
191 void UnsubscribeFromAll(INotificationSubscriber* subscriber) override;
192
193 void ReplaceSubscriber(INotificationSubscriber* oldSubscriber, INotificationSubscriber* newSubscriber);
194
195private:
196 const std::unique_ptr<Impl> pImpl;
197};
198
199template<typename PayloadType>
201 const String& notificationName, const String& senderName, Severity severity)
202{
203 return NotificationRegistration<PayloadType>(notificationName, senderName, severity, *(this));
204}
205
206template<typename PayloadType>
208 const String& notificationName, const String& senderName, Severity severity)
209{
210 return NonBlockingNotificationRegistration<PayloadType>(notificationName, senderName, severity, *this);
211}
212
213template<typename PayloadType>
215 const String& notificationName, const String& senderName, Severity severity)
216{
218 notificationName, senderName, severity, new NonBlockingNotificationSendingAdapter(*this));
219}
220
221template<typename PayloadType, typename ArgumentsType>
224 const String& notificationName, const String& senderName, Severity severity, size_t argumentsBufferCapacity)
225{
226 return NonBlockingNotificationRegistration3<PayloadType, ArgumentsType>(notificationName, senderName, severity,
227 argumentsBufferCapacity, std::make_unique<NonBlockingNotificationSendingAdapter>(*this));
228}
229
230}}} // end of namespace Arp::System::Nm
This class implements the singleton pattern for singletons with process wide scope.
Definition: AppDomainSingleton.hxx:25
The class contains date and time informations.
Definition: DateTime.hpp:46
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:192
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:115
Interface for non blocking sending of Notifications
Definition: INonBlockingNotificationSending.hpp:23
Interface for information about the Notification Manager
Definition: INotificationManagerInfo.hpp:22
Interface for subscribers of Notifications
Definition: INotificationReceiving.hpp:20
Interface for sending of notifications
Definition: INotificationSending.hpp:21
Interface for subscribers of Notifications
Definition: INotificationSubscriber.hpp:21
Interface for Paylo objects
Definition: IPayload.hpp:19
Proxy object for a non-blocking NotificationRegistration
Definition: NonBlockingNotificationRegistration3.hpp:54
Proxy object for a non-blocking NotificationRegistration
Definition: NonBlockingNotificationRegistration.hpp:35
Adapter for INonBlockingNotificationSending with additional functions
Definition: NonBlockingNotificationSendingAdapter.hpp:26
Primary access to the NotificationManager
Definition: NotificationManager.hpp:50
const String GetNotificationName(NotificationNameIdType notificationNameId) const override
Queries the NotifictionName
NonBlockingNotificationRegistration< PayloadType > CreateNonBlockingNotificationRegistration2(const String &notificationName, const String &senderName, Severity severity)
Creates a NonBlockingNotificationRegistration proxy
Definition: NotificationManager.hpp:214
NotificationSubscriber CreateNotificationSubscriber(const String &notificationName)
Creates a NotificationSubscriber proxy
NotificationNameIdType Subscribe(const String &notificationName, INotificationSubscriber *subscriber) override
Subscribe to a Notification
Future< NotificationIdType > NonBlockingSendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload &payload) override
Sends a notification (non-blocking)
Future< NotificationNameIdType > NonBlockingRegisterNotification(const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId) override
Registers a new Notification (non-blocking)
NotificationRegistration< PayloadType > CreateNotificationRegistration(const String &notificationName, const String &senderName, Severity severity)
Creates a NotificationRegistration proxy
Definition: NotificationManager.hpp:200
Future< NotificationIdType > NonBlockingSendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType &payload) override
Sends a notification (non-blocking)
void UnregisterNotification(NotificationNameIdType notificationNameId) override
Unregisters a Nototification
const PayloadTypeIdType GetPayloadTypeId(const String &payloadTypeName) override
Query an id for a given PayloadType
const String GetPayloadTypeName(const PayloadTypeIdType &payloadTypeId) const override
Query the payload type name of a given id
const NotificationRegistrationInfo GetNotificationRegistration(NotificationNameIdType notificationNameId) const override
Queries information about an Notification
Future< void > NonBlockingUnregisterNotification(NotificationNameIdType notificationNameId) override
Unregisters a Nototification (non-blocking)
const NotificationNameIdList GetAllKnownNotificationNameIds() const override
Queries of all known NotificationNameIds
const NotificationNameIdList GetNotificationNameIdsByStatus(const NotificationRegistrationStatus &status) const override
Queries the ids of Notifications with a given NotificationRegistrationStatus
const NotificationNameIdType GetNotificationNameId(const String &notificationName) override
Queries the id of an NotificationName
void Unsubscribe(NotificationNameIdType notificationNameId, INotificationSubscriber *subscriber) override
Unsubscribe from a Notification
NonBlockingNotificationRegistration< PayloadType > CreateNonBlockingNotificationRegistration(const String &notificationName, const String &senderName, Severity severity)
Creates a NonBlockingNotificationRegistration proxy
Definition: NotificationManager.hpp:207
NotificationIdType SendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType &payload) override
Sends a notification
Arp::uint64 GetNumberOfSubmittedNotifications() const override
Returns the number of Notifications submitted since startup of the controller
NonBlockingNotificationRegistration3< PayloadType, ArgumentsType > CreateNonBlockingNotificationRegistration3(const String &notificationName, const String &senderName, Severity severity, size_t argumentsBufferCapacity=GetDefaultArgumentsBufferCapacity())
Creates a NonBlockingNotificationRegistration3 proxy
Definition: NotificationManager.hpp:223
NotificationNameIdType RegisterNotification(const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId) override
Registers a new Notification
NotificationIdType SendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload &payload) override
Sends a notification
void UnsubscribeFromAll(INotificationSubscriber *subscriber) override
Unsubscribe from all Notification
Information about the registration of a Notification
Definition: NotificationRegistrationInfo.hpp:22
Proxy object for a NotificationRegistration
Definition: NotificationRegistration.hpp:32
Proxy class for an subscriber of notifications
Definition: NotificationSubscriber.hpp:31
std::uint64_t uint64
The Arp unsigned integer type of 8 byte size.
Definition: PrimitiveTypes.hpp:40
@ System
System components used by the System, Device, Plc or Io domains.
enum ARP_CXX_SYMBOL_EXPORT Severity
Enumeration of Severities for notifications
Definition: Severity.hpp:14
enum ARP_CXX_SYMBOL_EXPORT NotificationRegistrationStatus
Enumeration to represent the status of the Notification
Definition: NotificationRegistrationStatus.hpp:14
std::vector< NotificationNameIdType > NotificationNameIdList
collection of Notification name ids
Definition: NotificationManagerTypes.hpp:25
std::vector< Arp::System::Rsc::Services::RscVariant< RawPayloadTypeLength > > RawPayloadType
type for the internally transferred payloads
Definition: NotificationManagerTypes.hpp:34
Root namespace for the PLCnext API
Definition: NonBlockingNotificationSendingAdapter.hpp:29