Skip to content

Commit 2d007ee

Browse files
committed
BLE - Devirtualize pal::SigningEventMonitor
The event handler has been extracted out of SigningEventMonitor declaration and SigningEventMonitor instantion requires the implementation and event handler type.
1 parent 50de4c8 commit 2d007ee

File tree

1 file changed

+55
-31
lines changed

1 file changed

+55
-31
lines changed

features/FEATURE_BLE/ble/pal/SigningEventMonitor.h

Lines changed: 55 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,55 +17,79 @@
1717
#ifndef MBED_BLE_SIGNING_EVENT_MONITOR
1818
#define MBED_BLE_SIGNING_EVENT_MONITOR
1919

20+
#include "ble/common/StaticInterface.h"
2021
#include "ble/BLETypes.h"
2122

2223
namespace ble {
2324
namespace pal {
2425

2526
/**
26-
* Implemented by classes that need to be notified of signing events.
27-
* Notification is done by calling functions in the passed in event handler
27+
* Implemented by classes that are reacting to signing events.
2828
*/
29-
class SigningEventMonitor {
29+
template<class Impl>
30+
class SigningMonitorEventHandler : public StaticInterface<Impl, SigningMonitorEventHandler> {
31+
32+
using StaticInterface<Impl, ble::pal::SigningMonitorEventHandler>::impl;
33+
3034
public:
3135
/**
32-
* Implemented by classes that are reacting to signing events.
36+
* Set new signed write peer counter.
37+
*
38+
* @param[in] connection connection handle
39+
* @param[in] sign_coutner counter received from peer
3340
*/
34-
class EventHandler {
35-
public:
36-
/**
37-
* Set new signed write peer counter.
38-
*
39-
* @param[in] connection connection handle
40-
* @param[in] sign_coutner counter received from peer
41-
*/
42-
virtual void on_signed_write_received(
43-
connection_handle_t connection,
44-
uint32_t sign_coutner
45-
) = 0;
41+
void on_signed_write_received(
42+
connection_handle_t connection,
43+
uint32_t sign_coutner
44+
) {
45+
impl()->on_signed_write_received_(
46+
connection,
47+
sign_coutner
48+
);
49+
}
4650

47-
/**
48-
* Indicate that signed data was rejected due to verification failure. This could
49-
* be due to an invalid CSRK key.
50-
*
51-
* @param[in] connection connection handle
52-
*/
53-
virtual void on_signed_write_verification_failure(
54-
connection_handle_t connection
55-
) = 0;
51+
/**
52+
* Indicate that signed data was rejected due to verification failure. This could
53+
* be due to an invalid CSRK key.
54+
*
55+
* @param[in] connection connection handle
56+
*/
57+
void on_signed_write_verification_failure(
58+
connection_handle_t connection
59+
) {
60+
impl()->on_signed_write_verification_failure(connection);
61+
}
5662

57-
/**
58-
* Notify a new signed write cmd was executed.
59-
*/
60-
virtual void on_signed_write() = 0;
61-
};
63+
/**
64+
* Notify a new signed write cmd was executed.
65+
*/
66+
void on_signed_write() {
67+
impl()->on_signed_write_();
68+
}
69+
};
70+
71+
72+
73+
/**
74+
* Implemented by classes that need to be notified of signing events.
75+
* Notification is done by calling functions in the passed in event handler
76+
*/
77+
template<class Impl, class EventHandler>
78+
class SigningEventMonitor {
79+
Impl* impl() {
80+
return static_cast<Impl*>(this);
81+
}
6282

83+
public:
6384
/**
6485
* Register a handler for singing events to be used internally and serviced first.
6586
*
6687
* @param[in] signing_event_handler Event handler being registered.
6788
*/
68-
virtual void set_signing_event_handler(EventHandler *signing_event_handler) = 0;
89+
void set_signing_event_handler(EventHandler *signing_event_handler)
90+
{
91+
impl()->set_signing_event_handler_(signing_event_handler);
92+
}
6993
};
7094

7195
} // namespace pal

0 commit comments

Comments
 (0)