PLCnext API Documentation 24.0.0.71
NotificationSubscriber.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6
7#pragma once
8
10#include "Arp/System/Core/event.hxx"
11#include "Arp/System/Commons/Diagnostics/Logging/Loggable.hxx"
12#include "Arp/System/Commons/Threading/Mutex.hpp"
13#include "Arp/System/Nm/INotificationReceiving.hpp"
14#include "Arp/System/Nm/INotificationSubscriber.hpp"
15
16namespace Arp { namespace System { namespace Nm
17{
18
19
28class ARP_CXX_SYMBOL_EXPORT NotificationSubscriber
30 , public Arp::System::Commons::Diagnostics::Logging::Loggable<NotificationSubscriber>
31{
32public:
37
42 ARP_DEPRECATED("Use NotificationSubscriber(notificationName) instead. notificationReceiving is ignored.")
44 const String& notificationName, INotificationReceiving& notificationReceiving);
45
49 explicit NotificationSubscriber(const String& notificationName);
50
53 ~NotificationSubscriber() override;
54
55 NotificationSubscriber& operator=(const NotificationSubscriber&) = delete;
57
60 Arp::event<const Notification&> OnNotification;
61
63 void Dispose() noexcept;
64
67 void Notify(const Notification& notification) override;
68
70 const String GetNotificationName() const;
71
73 const NotificationNameIdType GetNotificationNameId() const;
74
75private: // methods
76 void Initialize();
77 bool IsInitialized() const;
78 void TranferSubscriptionFrom(NotificationSubscriber& other);
79
80private: // fields
81
82 // NotificationReceiving is not used any more. It will be removed in future versions.
83 INotificationReceiving* NotificationReceiving = nullptr;
84
85 String NotificationName;
86 NotificationNameIdType NotificationNameId;
87
88 // Mutex is not used any more. It will be removed in future versions.
89 Arp::System::Commons::Threading::Mutex Mutex;
90};
91
92}}} // namespace Arp::System::Nm
Interface for subscribers of Notifications
Definition: INotificationReceiving.hpp:20
Interface for subscribers of Notifications
Definition: INotificationSubscriber.hpp:21
Proxy class for an subscriber of notifications
Definition: NotificationSubscriber.hpp:31
NotificationSubscriber()=default
Creates an empty subscriber
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.
enum ARP_CXX_SYMBOL_EXPORT Default ARP_DEPRECATED("Use Internal instead")=0
Deprecated! Same as Internal
Root namespace for the PLCnext API