Trap attempts to register more than one message handler at a time.

This commit is contained in:
Jared Boone 2015-11-09 11:57:25 -08:00
parent 47a3ffb15a
commit 850c847bbf

View File

@ -29,6 +29,8 @@
#include "utility.hpp" #include "utility.hpp"
#include "ch.h"
class Message { class Message {
public: public:
static constexpr size_t MAX_SIZE = 276; static constexpr size_t MAX_SIZE = 276;
@ -251,6 +253,9 @@ public:
using MessageHandler = std::function<void(Message* const p)>; using MessageHandler = std::function<void(Message* const p)>;
void register_handler(const Message::ID id, MessageHandler&& handler) { void register_handler(const Message::ID id, MessageHandler&& handler) {
if( map_[toUType(id)] != nullptr ) {
chDbgPanic("MsgDblReg");
}
map_[toUType(id)] = std::move(handler); map_[toUType(id)] = std::move(handler);
} }