PLCnext API Documentation  21.0.0.35466
NotificationManager.hpp
1 //
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/NonBlockingNotificationSendingAdapter.hpp"
18 #include "Arp/System/Nm/NotificationRegistration.hpp"
19 #include "Arp/System/Nm/NotificationSubscriber.hpp"
20 
21 
22 namespace Arp { namespace System { namespace Nm
23 {
24 
25 
44  : public AppDomainSingleton<NotificationManager>
45  , public INotificationSending
48  , public INotificationReceiving
49  , private Loggable<NotificationManager, true>
50 {
51  friend class AppDomainSingleton<NotificationManager>;
52 
53 private:
54  struct Impl;
55 
56 protected:
57  explicit NotificationManager(size_t nonBlockingNotificationSendingProxyQueueLength = 128);
58  ~NotificationManager() override;
59 
60 public:
61  NotificationManager(const NotificationManager&) = delete;
62  NotificationManager(NotificationManager&&) = delete;
63 
64  NotificationManager& operator=(const NotificationManager&) = delete;
65  NotificationManager& operator=(NotificationManager&&) = delete;
66 
67 
68  // High level operations using proxy objects
76  template<typename PayloadType>
78  const String& notificationName, const String& senderName, Severity severity);
79 
88  template<typename PayloadType>
90  const String& notificationName, const String& senderName, Severity severity);
91 
104  template<typename PayloadType>
106  const String& notificationName, const String& senderName, Severity severity);
107 
111 
112 
113  // Methods of INotificationSending
114  NotificationNameIdType RegisterNotification(const String& notificationName,
115  const String& senderName, Severity severity, PayloadTypeIdType payloadTypeId) override;
116  void UnregisterNotification(NotificationNameIdType notificationNameId) override;
117 
119  Arp::DateTime timestamp, const RawPayloadType& payload) override;
121  Arp::DateTime timestamp, const IPayload& payload) override;
122 
123 
124  // Methods of INonBlockingNotificationSending
126  const String& senderName, Severity severity, PayloadTypeIdType payloadTypeId) override;
127 
128  void NonBlockingRegisterNotification(const String& notificationName, const String& senderName,
129  Severity severity, PayloadTypeIdType payloadTypeId, Future<NotificationNameIdType> result);
130 
132  NotificationNameIdType notificationNameId) override;
133 
135  NotificationNameIdType notificationNameId, Future<void> result);
136 
138  NotificationNameIdType notificationNameId, Arp::DateTime timestamp,
139  const RawPayloadType& payload) override;
140 
141  void NonBlockingSendNotification(NotificationNameIdType notificationNameId,
142  Arp::DateTime timestamp, std::function<RawPayloadType()> createPayloadFunctor,
144 
146  NotificationNameIdType notificationNameId, Arp::DateTime timestamp,
147  const IPayload& payload) override;
148 
149 
150  // Methods of INotificationManagerInfo
151  const String GetNotificationName(NotificationNameIdType notificationNameId) const override;
152  const NotificationNameIdType GetNotificationNameId(const String& notificationName) override;
153 
155  const NotificationRegistrationStatus& status) const override;
158  NotificationNameIdType notificationNameId) const override;
159 
160  const PayloadTypeIdType GetPayloadTypeId(const String& payloadTypeName) override;
161  const String GetPayloadTypeName(const PayloadTypeIdType& payloadTypeId) const override;
162 
164 
165 
166  // Methods of INotificationReceiving
168  const String& notificationName, INotificationSubscriber* subscriber) override;
169  void Unsubscribe(
170  NotificationNameIdType notificationNameId, INotificationSubscriber* subscriber) override;
171  void UnsubscribeFromAll(INotificationSubscriber* subscriber) override;
172 
173  void ReplaceSubscriber(
174  INotificationSubscriber* oldSubscriber, INotificationSubscriber* newSubscriber);
175 
176 
177 private:
178  const std::unique_ptr<Impl> pImpl;
179 };
180 
181 
182 template<typename PayloadType>
184  const String& notificationName, const String& senderName, Severity severity)
185 {
186  return NotificationRegistration<PayloadType>(notificationName, senderName, severity, *(this));
187 }
188 
189 
190 template<typename PayloadType>
193  const String& notificationName, const String& senderName, Severity severity)
194 {
196  notificationName, senderName, severity, *this);
197 }
198 
199 
200 template<typename PayloadType>
203  const String& notificationName, const String& senderName, Severity severity)
204 {
206  notificationName, senderName, severity, new NonBlockingNotificationSendingAdapter(*this));
207 }
208 
209 
210 }}} // end of namespace Arp::System::Nm
Interface for non blocking sending of Notifications
Definition: INonBlockingNotificationSending.hpp:21
const PayloadTypeIdType GetPayloadTypeId(const String &payloadTypeName) override
Query an id for a given PayloadType
Interface for subscribers of Notifications
Definition: INotificationReceiving.hpp:19
Future< NotificationIdType > NonBlockingSendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType &payload) override
Sends a notification (non-blocking)
NotificationNameIdType RegisterNotification(const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId) override
Registers a new Notification
Interface for Paylo objects
Definition: IPayload.hpp:18
NotificationNameIdType Subscribe(const String &notificationName, INotificationSubscriber *subscriber) override
Subscribe to a Notification
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:191
The class contains date and time informations.
Definition: DateTime.hpp:44
Proxy object for a non-blocking NotificationRegistration
Definition: NonBlockingNotificationRegistration.hpp:32
NonBlockingNotificationRegistration< PayloadType > CreateNonBlockingNotificationRegistration2(const String &notificationName, const String &senderName, Severity severity)
Creates a NonBlockingNotificationRegistration proxy
Definition: NotificationManager.hpp:202
Future< NotificationNameIdType > NonBlockingRegisterNotification(const String &notificationName, const String &senderName, Severity severity, PayloadTypeIdType payloadTypeId) override
Registers a new Notification (non-blocking)
const NotificationNameIdList GetNotificationNameIdsByStatus(const NotificationRegistrationStatus &status) const override
Queries the ids of Notifications with a given NotificationRegistrationStatus
const String GetNotificationName(NotificationNameIdType notificationNameId) const override
Queries the NotifictionName
void UnregisterNotification(NotificationNameIdType notificationNameId) override
Unregisters a Nototification
NotificationRegistration< PayloadType > CreateNotificationRegistration(const String &notificationName, const String &senderName, Severity severity)
Creates a NotificationRegistration proxy
Definition: NotificationManager.hpp:183
Interface for sending of notifications
Definition: INotificationSending.hpp:20
const NotificationNameIdList GetAllKnownNotificationNameIds() const override
Queries of all known NotificationNameIds
const NotificationRegistrationInfo GetNotificationRegistration(NotificationNameIdType notificationNameId) const override
Queries information about an Notification
std::vector< Arp::System::Rsc::Services::RscVariant< RawPayloadTypeLength > > RawPayloadType
type for the internally transferred payloads
Definition: NotificationManagerTypes.hpp:34
Future< void > NonBlockingUnregisterNotification(NotificationNameIdType notificationNameId) override
Unregisters a Nototification (non-blocking)
NotificationIdType SendNotification(NotificationNameIdType notificationNameId, Arp::DateTime timestamp, const RawPayloadType &payload) override
Sends a notification
const String GetPayloadTypeName(const PayloadTypeIdType &payloadTypeId) const override
Query the payload type name of a given id
Interface for information about the Notification Manager
Definition: INotificationManagerInfo.hpp:20
NotificationRegistrationStatus
Enumeration to represent the status of the Notification
Definition: NotificationRegistrationStatus.hpp:16
Interface for subscribers of Notifications
Definition: INotificationSubscriber.hpp:19
Severity
Enumeration of Severities for notifications
Definition: Severity.hpp:15
Root namespace for the PLCnext API
Information about the registration of a Notification
Definition: NotificationRegistrationInfo.hpp:21
This class implements the singleton pattern for singletons with process wide scope.
Definition: AppDomainSingleton.hxx:24
std::uint64_t uint64
The Arp unsigned integer type of 8 byte size.
Definition: PrimitiveTypes.hpp:39
NotificationSubscriber CreateNotificationSubscriber(const String &notificationName)
Creates a NotificationSubscriber proxy
Proxy object for a NotificationRegistration
Definition: NotificationRegistration.hpp:29
void UnsubscribeFromAll(INotificationSubscriber *subscriber) override
Unsubscribe from all Notification
const NotificationNameIdType GetNotificationNameId(const String &notificationName) override
Queries the id of an NotificationName
Arp::uint64 GetNumberOfSubmittedNotifications() const override
Returns the number of Notifications submitted since startup of the controller
Future object as proxy for return value an asynchronous function call
Definition: Future.hpp:114
System components used by the System, Device, Plc or Io domains.
NonBlockingNotificationRegistration< PayloadType > CreateNonBlockingNotificationRegistration(const String &notificationName, const String &senderName, Severity severity)
Creates a NonBlockingNotificationRegistration proxy
Definition: NotificationManager.hpp:192
Adapter for INonBlockingNotificationSending with additional functions
Definition: NonBlockingNotificationSendingAdapter.hpp:24
std::vector< NotificationNameIdType > NotificationNameIdList
collection of Notification name ids
Definition: NotificationManagerTypes.hpp:25
Primary access to the NotificationManager
Definition: NotificationManager.hpp:43
void Unsubscribe(NotificationNameIdType notificationNameId, INotificationSubscriber *subscriber) override
Unsubscribe from a Notification
Proxy class for an subscriber of notifications
Definition: NotificationSubscriber.hpp:27