My Project
Loading...
Searching...
No Matches
HandlerDispatcher.hpp
1#pragma once
2
3#include <map>
4#include <memory>
5#include "control/IMessageHandler.hpp"
6#include "message/MessageFrame.hpp"
7
8// Forward declaration
9class System;
10
12private:
13 std::map<MessageType, IMessageHandler*> handlers;
14
15public:
21 void registerHandler(MessageType type, IMessageHandler* handler);
22
31 bool dispatch(const std::string& messageId, const std::string& payload, MessageType type, System& system);
32
38 bool hasHandler(MessageType type) const;
39
44 size_t getHandlerCount() const;
45};
Definition HandlerDispatcher.hpp:11
void registerHandler(MessageType type, IMessageHandler *handler)
Registers a handler for a specific message type.
Definition HandlerDispatcher.cpp:5
bool dispatch(const std::string &messageId, const std::string &payload, MessageType type, System &system)
Dispatches a message to the appropriate handler.
Definition HandlerDispatcher.cpp:14
bool hasHandler(MessageType type) const
Checks if a handler is registered for a message type.
Definition HandlerDispatcher.cpp:30
size_t getHandlerCount() const
Gets the number of registered handlers.
Definition HandlerDispatcher.cpp:34
Definition IMessageHandler.hpp:9
Definition System.hpp:14