PLCnext API Documentation 23.0.2.9
NotificationSubscriber.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6
7#pragma once
8
9#include "Arp/System/Core/event.hxx"
10#include "Arp/System/Commons/Diagnostics/Logging/Loggable.hxx"
11#include "Arp/System/Commons/Threading/Mutex.hpp"
12#include "Arp/System/Nm/INotificationReceiving.hpp"
13#include "Arp/System/Nm/INotificationSubscriber.hpp"
14
15namespace Arp { namespace System { namespace Nm
16{
17
18
29 , public Arp::System::Commons::Diagnostics::Logging::Loggable<NotificationSubscriber>
30{
31public:
36
41 ARP_DEPRECATED("Use NotificationSubscriber(notificationName) instead. notificationReceiving is ignored.")
43 const String& notificationName, INotificationReceiving& notificationReceiving);
44
48 explicit NotificationSubscriber(const String& notificationName);
49
52 ~NotificationSubscriber() override;
53
54 NotificationSubscriber& operator=(const NotificationSubscriber&) = delete;
56
60
62 void Dispose() noexcept;
63
66 void Notify(const Notification& notification) override;
67
70
73
74private: // methods
75 void Initialize();
76 bool IsInitialized() const;
77 void TranferSubscriptionFrom(NotificationSubscriber& other);
78
79private: // fields
80
81 // NotificationReceiving is not used any more. It will be removed in future versions.
82 INotificationReceiving* NotificationReceiving = nullptr;
83
84 String NotificationName;
85 NotificationNameIdType NotificationNameId;
86
87 // Mutex is not used any more. It will be removed in future versions.
88 Arp::System::Commons::Threading::Mutex Mutex;
89};
90
91}}} // namespace Arp::System::Nm
Interface for subscribers of Notifications
Definition: INotificationReceiving.hpp:20
Interface for subscribers of Notifications
Definition: INotificationSubscriber.hpp:20
Proxy class for an subscriber of notifications
Definition: NotificationSubscriber.hpp:30
Arp::event< const Notification & > OnNotification
Event to be fired on a Notification
Definition: NotificationSubscriber.hpp:59
const NotificationNameIdType GetNotificationNameId() const
Returns the NotificationNameId
void Dispose() noexcept
Unsubscribe and release alll resources
NotificationSubscriber()=default
Creates an empty subscriber
void Notify(const Notification &notification) override
Called by the NotificationManager when a Notification is dipatched
const String GetNotificationName() const
Returns the NotificationName
Contains meta data and paylod of a Notification
Definition: Notification.hpp:22
Use this class to register and invoke several delegates (function pointer in OOP design).
Definition: event.hxx:33
@ System
System components used by the System, Device, Plc or Io domains.
Root namespace for the PLCnext API
class ARP_DEPRECATED("Use Arp::Enum<T> instead.") EnumStrings
The class implements an adapter for enums to define the string literals of the enum entries.
Definition: EnumStrings.hxx:38