PLCnext API Documentation 23.0.2.9
NotificationRegistrationBase.hpp
1
2//
3// Copyright PHOENIX CONTACT Electronics GmbH
4//
6
7#pragma once
8
10#include "Arp/System/Nm/NotificationManagerTypes.hpp"
11#include "Arp/System/Nm/Severity.hpp"
12#include "Arp/System/Commons/Diagnostics/Logging/Loggable.hxx"
13
14namespace Arp { namespace System { namespace Nm
15{
16
17
20template<class Derived>
23 NotificationRegistrationBase<Derived >>
24{
25private:
26 friend Derived;
27
30 const String notificationName, const String senderName, Severity severity);
32
33public:
35
36 virtual ~NotificationRegistrationBase() = default;
37
40
42 void Dispose() noexcept;
43
46
49
51 const String GetSenderName() const;
52
55
58
59protected:
60 virtual void DisposeImpl() = 0;
61
62private:
63 String NotificationName;
64 String SenderName;
65 Severity severity = Severity::Default;
66};
67
68
69template<class Derived>
71 const String notificationName, const String senderName, Severity severity)
72 : NotificationName(std::move(notificationName)),
73 SenderName(std::move(senderName)),
74 severity(std::move(severity))
75{
76}
77
78
79template<class Derived>
81{
82 try
83 {
84 this->DisposeImpl();
85 }
86 catch (const Arp::Exception& e)
87 {
88 this->log.Error("Caught exception while unregistering notificationName={}: {}",
89 this->NotificationName, e.ToString());
90 }
91 catch (...)
92 {
93 this->log.Error(
94 "Caught exception while unregistering notificationName={}", this->NotificationName);
95 }
96}
97
98
99template<class Derived>
101{
102 return this->NotificationName;
103}
104
105
106template<class Derived>
108{
109 return this->SenderName;
110}
111
112
113template<class Derived>
115{
116 return this->severity;
117}
118
119
120template<class Derived>
122{
123 return Derived::payload_type::GetPayloadTypeId();
124}
125
126
127}}} // namespace Arp::System::Nm
This is the base class of all Arp exception classes.
Definition: Exception.hpp:16
String ToString(void) const
Gets a reasonable string representation of this exception.
Base class with common behavior of NotificationRegistration and NonBlockingNotificationRegistration
Definition: NotificationRegistrationBase.hpp:24
const String GetSenderName() const
Returns the sender name
Definition: NotificationRegistrationBase.hpp:107
Severity GetSeverity() const
Returns the Severity
Definition: NotificationRegistrationBase.hpp:114
PayloadTypeIdType GetPayloadTypeId() const
Returns the PayloadTypeId
Definition: NotificationRegistrationBase.hpp:121
virtual NotificationNameIdType GetNotificationNameId() const =0
Returns the notification name id
const String GetNotificationName() const
Returns the notification name
Definition: NotificationRegistrationBase.hpp:100
void Dispose() noexcept
Unregisters the Notification and release all resources
Definition: NotificationRegistrationBase.hpp:80
@ System
System components used by the System, Device, Plc or Io domains.
Severity
Enumeration of Severities for notifications
Definition: Severity.hpp:15
Root namespace for the PLCnext API
Namespace of the C++ standard library