HiveMind
MessageDispatcher.h
Go to the documentation of this file.
1 #ifndef __MESSAGEDISPATCHER_H_
2 #define __MESSAGEDISPATCHER_H_
3 
4 #include "IGreetSender.h"
7 #include "IMessageDispatcher.h"
8 #include <bsp/IBSP.h>
9 #include <cpp-common/ICircularQueue.h>
10 #include <logger/ILogger.h>
11 #include <pheromones/IHiveMindHostDeserializer.h>
12 #include <pheromones/MessageDTO.h>
13 
15  public:
16  MessageDispatcher(ICircularQueue<MessageDTO>& buzzOutputQ,
17  ICircularQueue<MessageDTO>& hostOutputQ,
18  ICircularQueue<MessageDTO>& remoteOutputQ,
19  ICircularQueue<MessageDTO>& interlocQ,
20  IHiveMindHostDeserializer& deserializer,
21  IHiveMindHostApiRequestHandler& hivemindApiReqHandler,
22  IHiveConnectHiveMindApiMessageHandler& hiveconnectApiMessageHandler,
23  IGreetSender& greetSender,
24  const IBSP& bsp,
25  ILogger& logger);
26 
27  ~MessageDispatcher() override = default;
28 
29  bool deserializeAndDispatch() override;
30 
31  private:
32  ICircularQueue<MessageDTO>& m_buzzOutputQueue;
33  ICircularQueue<MessageDTO>& m_hostOutputQueue;
34  ICircularQueue<MessageDTO>& m_remoteOutputQueue;
35  ICircularQueue<MessageDTO>& m_interlocQueue;
36  IHiveMindHostDeserializer& m_deserializer;
40  const IBSP& m_bsp;
42 
43  // handling funciton
44  bool dispatchUserCall(const MessageDTO& message, const UserCallTargetDTO& dest);
45  bool dispatchUserCallRequest(const MessageDTO& message, const UserCallRequestDTO& request);
46  bool dispatchUserCallResponse(const MessageDTO& message, const UserCallResponseDTO& response);
47  bool dispatchRequest(const MessageDTO& message, const RequestDTO& request);
48  bool dispatchResponse(const MessageDTO& message, const ResponseDTO& response);
49  bool dispatchBuzzMessage(const MessageDTO& message);
50  bool dispatchMessage(const MessageDTO& message);
51 };
52 
53 #endif // __MESSAGEDISPATCHER_H_
IGreetSender.h
MessageDispatcher::m_hiveconnectApiMessageHandler
IHiveConnectHiveMindApiMessageHandler & m_hiveconnectApiMessageHandler
Definition: MessageDispatcher.h:38
MessageDispatcher::m_greetSender
IGreetSender & m_greetSender
Definition: MessageDispatcher.h:39
MessageDispatcher::deserializeAndDispatch
bool deserializeAndDispatch() override
deserialize a message and dispatches it in the appropriate queue
Definition: MessageDispatcher.cpp:27
MessageDispatcher::m_buzzOutputQueue
ICircularQueue< MessageDTO > & m_buzzOutputQueue
Definition: MessageDispatcher.h:32
MessageDispatcher::dispatchRequest
bool dispatchRequest(const MessageDTO &message, const RequestDTO &request)
Definition: MessageDispatcher.cpp:96
MessageDispatcher::m_bsp
const IBSP & m_bsp
Definition: MessageDispatcher.h:40
MessageDispatcher::dispatchUserCall
bool dispatchUserCall(const MessageDTO &message, const UserCallTargetDTO &dest)
Definition: MessageDispatcher.cpp:60
MessageDispatcher::MessageDispatcher
MessageDispatcher(ICircularQueue< MessageDTO > &buzzOutputQ, ICircularQueue< MessageDTO > &hostOutputQ, ICircularQueue< MessageDTO > &remoteOutputQ, ICircularQueue< MessageDTO > &interlocQ, IHiveMindHostDeserializer &deserializer, IHiveMindHostApiRequestHandler &hivemindApiReqHandler, IHiveConnectHiveMindApiMessageHandler &hiveconnectApiMessageHandler, IGreetSender &greetSender, const IBSP &bsp, ILogger &logger)
Definition: MessageDispatcher.cpp:5
MessageDispatcher::~MessageDispatcher
~MessageDispatcher() override=default
IBSP.h
MessageDispatcher::dispatchUserCallResponse
bool dispatchUserCallResponse(const MessageDTO &message, const UserCallResponseDTO &response)
Definition: MessageDispatcher.cpp:90
IMessageDispatcher.h
IHiveMindHostApiRequestHandler
Handles HiveMindApi requests and sends the response to the appropriate target.
Definition: IHiveMindHostApiRequestHandler.h:10
IMessageDispatcher
A class to manage message dispatching to queues, sending messages at the right place.
Definition: IMessageDispatcher.h:6
MessageDispatcher::dispatchResponse
bool dispatchResponse(const MessageDTO &message, const ResponseDTO &response)
Definition: MessageDispatcher.cpp:118
IBSP
Definition: IBSP.h:6
IHiveConnectHiveMindApiMessageHandler
Handles HiveConnectHiveMindApi messages and makes the proper request.
Definition: IHiveConnectHiveMindApiMessageHandler.h:9
MessageDispatcher::dispatchUserCallRequest
bool dispatchUserCallRequest(const MessageDTO &message, const UserCallRequestDTO &request)
Definition: MessageDispatcher.cpp:84
MessageDispatcher::m_deserializer
IHiveMindHostDeserializer & m_deserializer
Definition: MessageDispatcher.h:36
MessageDispatcher::dispatchMessage
bool dispatchMessage(const MessageDTO &message)
Definition: MessageDispatcher.cpp:131
ILogger
A logger class with basic logging capabilities.
Definition: ILogger.h:35
MessageDispatcher::m_hostOutputQueue
ICircularQueue< MessageDTO > & m_hostOutputQueue
Definition: MessageDispatcher.h:33
MessageDispatcher::dispatchBuzzMessage
bool dispatchBuzzMessage(const MessageDTO &message)
MessageDispatcher::m_logger
ILogger & m_logger
Definition: MessageDispatcher.h:41
MessageDispatcher::m_interlocQueue
ICircularQueue< MessageDTO > & m_interlocQueue
Definition: MessageDispatcher.h:35
MessageDispatcher::m_remoteOutputQueue
ICircularQueue< MessageDTO > & m_remoteOutputQueue
Definition: MessageDispatcher.h:34
MessageDispatcher
Definition: MessageDispatcher.h:14
IHiveConnectHiveMindApiMessageHandler.h
IGreetSender
Definition: IGreetSender.h:4
MessageDispatcher::m_hivemindApiReqHandler
IHiveMindHostApiRequestHandler & m_hivemindApiReqHandler
Definition: MessageDispatcher.h:37
IHiveMindHostApiRequestHandler.h
ILogger.h