mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 23:09:26 -05:00
Un-const Message in message handler interfaces.
I want to modify in place the messages that are received. Naughty, but oh well.
This commit is contained in:
parent
5469a3a31d
commit
31ff13f1c0
@ -124,7 +124,7 @@ private:
|
||||
|
||||
void handle_application_queue() {
|
||||
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
||||
while(const Message* const message = shared_memory.application_queue.pop(message_buffer)) {
|
||||
while(Message* const message = shared_memory.application_queue.pop(message_buffer)) {
|
||||
context.message_map.send(message);
|
||||
}
|
||||
}
|
||||
|
@ -493,8 +493,8 @@ ReceiverView::~ReceiverView() {
|
||||
|
||||
void ReceiverView::on_show() {
|
||||
context().message_map.register_handler(Message::ID::FSKPacket,
|
||||
[](const Message* const p) {
|
||||
const auto message = static_cast<const FSKPacketMessage*>(p);
|
||||
[this](Message* const p) {
|
||||
auto message = static_cast<FSKPacketMessage*>(p);
|
||||
(void)message;
|
||||
}
|
||||
);
|
||||
|
@ -260,7 +260,7 @@ private:
|
||||
|
||||
void handle_baseband_queue() {
|
||||
std::array<uint8_t, Message::MAX_SIZE> message_buffer;
|
||||
while(const Message* const message = shared_memory.baseband_queue.pop(message_buffer)) {
|
||||
while(Message* const message = shared_memory.baseband_queue.pop(message_buffer)) {
|
||||
message_map.send(message);
|
||||
}
|
||||
}
|
||||
|
@ -245,7 +245,7 @@ public:
|
||||
|
||||
class MessageHandlerMap {
|
||||
public:
|
||||
using MessageHandler = std::function<void(const Message* const p)>;
|
||||
using MessageHandler = std::function<void(Message* const p)>;
|
||||
|
||||
void register_handler(const Message::ID id, MessageHandler&& handler) {
|
||||
map_[toUType(id)] = std::move(handler);
|
||||
@ -255,7 +255,7 @@ public:
|
||||
map_[toUType(id)] = nullptr;
|
||||
}
|
||||
|
||||
void send(const Message* const message) {
|
||||
void send(Message* const message) {
|
||||
if( message->id < Message::ID::MAX ) {
|
||||
auto& fn = map_[toUType(message->id)];
|
||||
if( fn ) {
|
||||
|
@ -47,8 +47,8 @@ public:
|
||||
return push(&message, sizeof(message));
|
||||
}
|
||||
|
||||
const Message* pop(std::array<uint8_t, Message::MAX_SIZE>& buf) {
|
||||
const Message* const p = reinterpret_cast<Message*>(buf.data());
|
||||
Message* pop(std::array<uint8_t, Message::MAX_SIZE>& buf) {
|
||||
Message* const p = reinterpret_cast<Message*>(buf.data());
|
||||
return fifo.out_r(buf.data(), buf.size()) ? p : nullptr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user