mirror of https://github.com/ARMmbed/mbed-os.git
BLE - Devirtualize pal::SigningEventMonitor
The event handler has been extracted out of SigningEventMonitor declaration and SigningEventMonitor instantion requires the implementation and event handler type.pull/9727/head
parent
50de4c8a44
commit
2d007eee42
|
@ -17,21 +17,20 @@
|
||||||
#ifndef MBED_BLE_SIGNING_EVENT_MONITOR
|
#ifndef MBED_BLE_SIGNING_EVENT_MONITOR
|
||||||
#define MBED_BLE_SIGNING_EVENT_MONITOR
|
#define MBED_BLE_SIGNING_EVENT_MONITOR
|
||||||
|
|
||||||
|
#include "ble/common/StaticInterface.h"
|
||||||
#include "ble/BLETypes.h"
|
#include "ble/BLETypes.h"
|
||||||
|
|
||||||
namespace ble {
|
namespace ble {
|
||||||
namespace pal {
|
namespace pal {
|
||||||
|
|
||||||
/**
|
|
||||||
* Implemented by classes that need to be notified of signing events.
|
|
||||||
* Notification is done by calling functions in the passed in event handler
|
|
||||||
*/
|
|
||||||
class SigningEventMonitor {
|
|
||||||
public:
|
|
||||||
/**
|
/**
|
||||||
* Implemented by classes that are reacting to signing events.
|
* Implemented by classes that are reacting to signing events.
|
||||||
*/
|
*/
|
||||||
class EventHandler {
|
template<class Impl>
|
||||||
|
class SigningMonitorEventHandler : public StaticInterface<Impl, SigningMonitorEventHandler> {
|
||||||
|
|
||||||
|
using StaticInterface<Impl, ble::pal::SigningMonitorEventHandler>::impl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Set new signed write peer counter.
|
* Set new signed write peer counter.
|
||||||
|
@ -39,10 +38,15 @@ public:
|
||||||
* @param[in] connection connection handle
|
* @param[in] connection connection handle
|
||||||
* @param[in] sign_coutner counter received from peer
|
* @param[in] sign_coutner counter received from peer
|
||||||
*/
|
*/
|
||||||
virtual void on_signed_write_received(
|
void on_signed_write_received(
|
||||||
connection_handle_t connection,
|
connection_handle_t connection,
|
||||||
uint32_t sign_coutner
|
uint32_t sign_coutner
|
||||||
) = 0;
|
) {
|
||||||
|
impl()->on_signed_write_received_(
|
||||||
|
connection,
|
||||||
|
sign_coutner
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicate that signed data was rejected due to verification failure. This could
|
* Indicate that signed data was rejected due to verification failure. This could
|
||||||
|
@ -50,22 +54,42 @@ public:
|
||||||
*
|
*
|
||||||
* @param[in] connection connection handle
|
* @param[in] connection connection handle
|
||||||
*/
|
*/
|
||||||
virtual void on_signed_write_verification_failure(
|
void on_signed_write_verification_failure(
|
||||||
connection_handle_t connection
|
connection_handle_t connection
|
||||||
) = 0;
|
) {
|
||||||
|
impl()->on_signed_write_verification_failure(connection);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notify a new signed write cmd was executed.
|
* Notify a new signed write cmd was executed.
|
||||||
*/
|
*/
|
||||||
virtual void on_signed_write() = 0;
|
void on_signed_write() {
|
||||||
|
impl()->on_signed_write_();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implemented by classes that need to be notified of signing events.
|
||||||
|
* Notification is done by calling functions in the passed in event handler
|
||||||
|
*/
|
||||||
|
template<class Impl, class EventHandler>
|
||||||
|
class SigningEventMonitor {
|
||||||
|
Impl* impl() {
|
||||||
|
return static_cast<Impl*>(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public:
|
||||||
/**
|
/**
|
||||||
* Register a handler for singing events to be used internally and serviced first.
|
* Register a handler for singing events to be used internally and serviced first.
|
||||||
*
|
*
|
||||||
* @param[in] signing_event_handler Event handler being registered.
|
* @param[in] signing_event_handler Event handler being registered.
|
||||||
*/
|
*/
|
||||||
virtual void set_signing_event_handler(EventHandler *signing_event_handler) = 0;
|
void set_signing_event_handler(EventHandler *signing_event_handler)
|
||||||
|
{
|
||||||
|
impl()->set_signing_event_handler_(signing_event_handler);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace pal
|
} // namespace pal
|
||||||
|
|
Loading…
Reference in New Issue