Hotwheels-Cluster 1.2
Creation of Cluster APP for SEA:ME project.
 
Loading...
Searching...
No Matches
CANMessageProcessor.hpp
Go to the documentation of this file.
1
16
17#ifndef CANMESSAGEPROCESSOR_HPP
18#define CANMESSAGEPROCESSOR_HPP
19
20#include <cstdint>
21#include <functional>
22#include <unordered_map>
23#include <vector>
24
30public:
31 using MessageHandler = std::function<void(const std::vector<uint8_t> &)>;
32
35 void registerHandler(uint16_t frameID, MessageHandler handler);
36 void processMessage(uint16_t frameID, const std::vector<uint8_t> &data);
37
38private:
40 std::unordered_map<uint16_t, MessageHandler> handlers;
41};
42
43#endif // CANMESSAGEPROCESSOR_HPP
void registerHandler(uint16_t frameID, MessageHandler handler)
Destroy the CANMessageProcessor::CANMessageProcessor object.
std::unordered_map< uint16_t, MessageHandler > handlers
Map of frame IDs to message handlers.
CANMessageProcessor()
Construct a new CANMessageProcessor::CANMessageProcessor object.
std::function< void(const std::vector< uint8_t > &)> MessageHandler
void processMessage(uint16_t frameID, const std::vector< uint8_t > &data)
Process a CAN message.
~CANMessageProcessor()=default