Wrap message handler registrations in class to subscribe/unsubscribe automatically.

This commit is contained in:
Jared Boone 2016-05-11 22:53:09 -07:00
parent e298e1ec5a
commit 7d4dd03418
18 changed files with 139 additions and 149 deletions

View file

@ -26,6 +26,8 @@
#include "ui_widget.hpp"
#include "ui_painter.hpp"
#include "event_m0.hpp"
#include "message.hpp"
#include <cstdint>
@ -43,9 +45,6 @@ public:
{
}
void on_show() override;
void on_hide() override;
void paint(Painter& painter) override;
private:
@ -53,6 +52,13 @@ private:
int32_t avg_;
int32_t max_;
MessageHandlerRegistration message_handler_stats {
Message::ID::RSSIStatistics,
[this](const Message* const p) {
this->on_statistics_update(static_cast<const RSSIStatisticsMessage*>(p)->statistics);
}
};
void on_statistics_update(const RSSIStatistics& statistics);
};