PLCnext API Documentation 23.0.2.9
NotificationManager.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6
7#pragma once
8
9#include "Arp/System/Core/AppDomainSingleton.hxx"
10#include "Arp/System/Commons/Logging.h"
11
12#include "Arp/System/Nm/INonBlockingNotificationSending.hpp"
13#include "Arp/System/Nm/INotificationManagerInfo.hpp"
14#include "Arp/System/Nm/INotificationReceiving.hpp"
15#include "Arp/System/Nm/INotificationSending.hpp"
16#include "Arp/System/Nm/NonBlockingNotificationRegistration.hpp"
17#include "Arp/System/Nm/NonBlockingNotificationRegistration3.hpp"
18#include "Arp/System/Nm/NonBlockingNotificationSendingAdapter.hpp"
19#include "Arp/System/Nm/NotificationRegistration.hpp"
20#include "Arp/System/Nm/NotificationSubscriber.hpp"
21
22namespace Arp { namespace System { namespace Nm
23{
24
43 : public AppDomainSingleton<NotificationManager>
48 , private Loggable<NotificationManager, true>
49{
52
53private:
54 class Impl;
55
56protected:
57 explicit NotificationManager(size_t nonBlockingNotificationSendingProxyQueueLength = 128);
58 ~NotificationManager() override;
59
60public:
63
64 NotificationManager& operator=(const NotificationManager&) = delete;
65 NotificationManager& operator=(NotificationManager&&) = delete;
66
67 // High level operations using proxy objects
75 template<typename PayloadType>
77 const String& notificationName, const String& senderName, Severity severity);
78
90 template<typename PayloadType>
92 const String& notificationName, const String& senderName, Severity severity);
93
109 template<typename PayloadType>
111 const String& notificationName, const String& senderName, Severity severity);
112
124 template<typename PayloadType, typename ArgumentsType = typename PayloadType::ArgumentsType>
126 const String& notificationName, const String& senderName, Severity severity,
127 size_t argumentsBufferCapacity = GetDefaultArgumentsBufferCapacity());
128
132
133 // Methods of INotificationSending
134 NotificationNameIdType RegisterNotification(const String& notificationName, const String& senderName,
135 Severity severity, PayloadTypeIdType payloadTypeId) override;
136 void UnregisterNotification(NotificationNameIdType notificationNameId) override;
137
139 NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType& payload) override;
141 NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload& payload) override;
142
143 // Methods of INonBlockingNotificationSending
145 const String& senderName, Severity severity, PayloadTypeIdType payloadTypeId) override;
146
147 void NonBlockingRegisterNotification(const String& notificationName, const String& senderName, Severity severity,
149
151
153
155 NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType& payload) override;
156
157 void NonBlockingSendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp,
158 std::function<RawPayloadType()> createPayloadFunctor, Future<NotificationIdType> result);
159
161 NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const IPayload& payload) override;
162
163private:
164 void NonBlockingSendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp,
165 NonBlockingNotificationSendingAdapter::CreatePayloadFunctor createPayloadFunctor,
168
169 static size_t GetDefaultArgumentsBufferCapacity();
170
171public:
172 // Methods of INotificationManagerInfo
173 const String GetNotificationName(NotificationNameIdType notificationNameId) const override;
174 const NotificationNameIdType GetNotificationNameId(const String& notificationName) override;
175
177 const NotificationRegistrationStatus& status) const override;
180 NotificationNameIdType notificationNameId) const override;
181
182 const PayloadTypeIdType GetPayloadTypeId(const String& payloadTypeName) override;
183 const String GetPayloadTypeName(const PayloadTypeIdType& payloadTypeId) const override;
184
186
187 // Methods of INotificationReceiving
188 NotificationNameIdType Subscribe(const String& notificationName, INotificationSubscriber* subscriber) override;
189 void Unsubscribe(NotificationNameIdType notificationNameId, INotificationSubscriber* subscriber) override;
190 void UnsubscribeFromAll(INotificationSubscriber* subscriber) override;
191
192 void ReplaceSubscriber(INotificationSubscriber* oldSubscriber, INotificationSubscriber* newSubscriber);
193
194private:
195 const std::unique_ptr<Impl> pImpl;
196};
197
198template<typename PayloadType>
200 const String& notificationName, const String& senderName, Severity severity)
201{
202 return NotificationRegistration<PayloadType>(notificationName, senderName, severity, *(this));
203}
204
205template<typename PayloadType>
207 const String& notificationName, const String& senderName, Severity severity)
208{
209 return NonBlockingNotificationRegistration<PayloadType>(notificationName, senderName, severity, *this);
210}
211
212template<typename PayloadType>
214 const String& notificationName, const String& senderName, Severity severity)
215{
217 notificationName, senderName, severity, new NonBlockingNotificationSendingAdapter(*this));
218}
219
220template<typename PayloadType, typename ArgumentsType>
223 const String& notificationName, const String& senderName, Severity severity, size_t argumentsBufferCapacity)
224{
225 return NonBlockingNotificationRegistration3<PayloadType, ArgumentsType>(notificationName, senderName, severity,
226 argumentsBufferCapacity, std::make_unique<NonBlockingNotificationSendingAdapter>(*this));
227}
228
229}}} // 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:45
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:191
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:114
Interface for non blocking sending of Notifications
Definition: INonBlockingNotificationSending.hpp:22
Interface for information about the Notification Manager
Definition: INotificationManagerInfo.hpp:21
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:20
Interface for Paylo objects
Definition: IPayload.hpp:19
Proxy object for a non-blocking NotificationRegistration
Definition: NonBlockingNotificationRegistration3.hpp:53
Proxy object for a non-blocking NotificationRegistration
Definition: NonBlockingNotificationRegistration.hpp:34
Adapter for INonBlockingNotificationSending with additional functions
Definition: NonBlockingNotificationSendingAdapter.hpp:25
Primary access to the NotificationManager
Definition: NotificationManager.hpp:49
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:213
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:199
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:206
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:222
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:31
Proxy class for an subscriber of notifications
Definition: NotificationSubscriber.hpp:30
std::uint64_t uint64
The Arp unsigned integer type of 8 byte size.
Definition: PrimitiveTypes.hpp:39
@ System
System components used by the System, Device, Plc or Io domains.
Severity
Enumeration of Severities for notifications
Definition: Severity.hpp:15
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
NotificationRegistrationStatus
Enumeration to represent the status of the Notification
Definition: NotificationRegistrationStatus.hpp:15
Root namespace for the PLCnext API
Definition: NonBlockingNotificationSendingAdapter.hpp:28