HiveMind
BittyBuzzMessageHandler.h
Go to the documentation of this file.
1 #ifndef __BITTYBUZZMESSAGEHANDLER_H_
2 #define __BITTYBUZZMESSAGEHANDLER_H_
3 
6 #include <bsp/IBSP.h>
7 #include <cpp-common/ICircularQueue.h>
8 #include <logger/ILogger.h>
9 #include <pheromones/MessageDTO.h>
10 
12  public:
14  ICircularQueue<MessageDTO>& inputQueue,
15  ICircularQueue<MessageDTO>& hostQueue,
16  ICircularQueue<MessageDTO>& remoteQueue,
17  const IBSP& bsp,
18  ILogger& logger);
19 
20  ~BittyBuzzMessageHandler() override = default;
21 
22  bool processMessage() override;
23 
24  void clearMessages() override;
25 
26  uint16_t messageQueueLength() const override;
27 
28  private:
30  ICircularQueue<MessageDTO>& m_inputQueue;
31  ICircularQueue<MessageDTO>& m_hostQueue;
32  ICircularQueue<MessageDTO>& m_remoteQueue;
33  const IBSP& m_bsp;
35 
36  // handling funciton
37  FunctionListLengthResponseDTO handleFunctionListLengthRequest(
38  const FunctionListLengthRequestDTO& functionLengthRequest);
39  FunctionDescriptionResponseDTO handleFunctionDescriptionRequest(
40  const FunctionDescriptionRequestDTO& functionDescRequest);
41  FunctionCallResponseDTO handleFunctionCallRequest(
42  const FunctionCallRequestDTO& functionRequest);
43  UserCallResponseDTO handleUserCallRequest(const UserCallRequestDTO& userRequest);
44  ResponseDTO handleRequest(const RequestDTO& request);
45 
46  static bool handleUserCallResponse(const UserCallResponseDTO& response);
47  static bool handleGenericResponse(const GenericResponseDTO& response);
48  bool handleVmMessage(const VmMessageDTO& vmMsg);
49  bool handleBuzzMessages(const BuzzMessagesDTO& msg);
50  bool handleResponse(const ResponseDTO& response);
51 
52  bool handleMessage(const MessageDTO& message);
53 };
54 
55 #endif // __BITTYBUZZMESSAGEHANDLER_H_
BittyBuzzMessageHandler::handleResponse
bool handleResponse(const ResponseDTO &response)
Definition: BittyBuzzMessageHandler.cpp:221
BittyBuzzMessageHandler::m_remoteQueue
ICircularQueue< MessageDTO > & m_remoteQueue
Definition: BittyBuzzMessageHandler.h:32
BittyBuzzMessageHandler::handleRequest
ResponseDTO handleRequest(const RequestDTO &request)
Definition: BittyBuzzMessageHandler.cpp:162
BittyBuzzMessageHandler::~BittyBuzzMessageHandler
~BittyBuzzMessageHandler() override=default
IBittyBuzzClosureRegister
A class to register buzz function/closures id and associate them with a string.
Definition: IBittyBuzzClosureRegister.h:24
IBSP.h
BittyBuzzMessageHandler::handleGenericResponse
static bool handleGenericResponse(const GenericResponseDTO &response)
Definition: BittyBuzzMessageHandler.cpp:184
BittyBuzzMessageHandler::m_inputQueue
ICircularQueue< MessageDTO > & m_inputQueue
Definition: BittyBuzzMessageHandler.h:30
BittyBuzzMessageHandler::handleVmMessage
bool handleVmMessage(const VmMessageDTO &vmMsg)
Definition: BittyBuzzMessageHandler.cpp:190
BittyBuzzMessageHandler::handleBuzzMessages
bool handleBuzzMessages(const BuzzMessagesDTO &msg)
Definition: BittyBuzzMessageHandler.cpp:201
BittyBuzzMessageHandler::handleFunctionCallRequest
FunctionCallResponseDTO handleFunctionCallRequest(const FunctionCallRequestDTO &functionRequest)
Definition: BittyBuzzMessageHandler.cpp:74
BittyBuzzMessageHandler::messageQueueLength
uint16_t messageQueueLength() const override
gets the number of message to be processed in the queue
Definition: BittyBuzzMessageHandler.cpp:42
BittyBuzzMessageHandler::handleUserCallResponse
static bool handleUserCallResponse(const UserCallResponseDTO &response)
Definition: BittyBuzzMessageHandler.cpp:178
IBittyBuzzClosureRegister.h
IBSP
Definition: IBSP.h:6
BittyBuzzMessageHandler::processMessage
bool processMessage() override
process a message and sends a response if needed. A response is sent to the appropriate queue on a re...
Definition: BittyBuzzMessageHandler.cpp:20
BittyBuzzMessageHandler::m_logger
ILogger & m_logger
Definition: BittyBuzzMessageHandler.h:34
ILogger
A logger class with basic logging capabilities.
Definition: ILogger.h:35
BittyBuzzMessageHandler::m_hostQueue
ICircularQueue< MessageDTO > & m_hostQueue
Definition: BittyBuzzMessageHandler.h:31
BittyBuzzMessageHandler::clearMessages
void clearMessages() override
clears all the pending messages in the input queue without processing them
Definition: BittyBuzzMessageHandler.cpp:40
BittyBuzzMessageHandler::handleFunctionListLengthRequest
FunctionListLengthResponseDTO handleFunctionListLengthRequest(const FunctionListLengthRequestDTO &functionLengthRequest)
Definition: BittyBuzzMessageHandler.cpp:44
BittyBuzzMessageHandler
Definition: BittyBuzzMessageHandler.h:11
BittyBuzzMessageHandler::BittyBuzzMessageHandler
BittyBuzzMessageHandler(const IBittyBuzzClosureRegister &closureRegister, ICircularQueue< MessageDTO > &inputQueue, ICircularQueue< MessageDTO > &hostQueue, ICircularQueue< MessageDTO > &remoteQueue, const IBSP &bsp, ILogger &logger)
Definition: BittyBuzzMessageHandler.cpp:7
BittyBuzzMessageHandler::m_bsp
const IBSP & m_bsp
Definition: BittyBuzzMessageHandler.h:33
BittyBuzzMessageHandler::handleUserCallRequest
UserCallResponseDTO handleUserCallRequest(const UserCallRequestDTO &userRequest)
Definition: BittyBuzzMessageHandler.cpp:135
BittyBuzzMessageHandler::handleFunctionDescriptionRequest
FunctionDescriptionResponseDTO handleFunctionDescriptionRequest(const FunctionDescriptionRequestDTO &functionDescRequest)
Definition: BittyBuzzMessageHandler.cpp:50
IBittyBuzzMessageHandler
Handles messages destined to the bbvm.
Definition: IBittyBuzzMessageHandler.h:8
IBittyBuzzMessageHandler.h
BittyBuzzMessageHandler::m_closureRegister
const IBittyBuzzClosureRegister & m_closureRegister
Definition: BittyBuzzMessageHandler.h:29
BittyBuzzMessageHandler::handleMessage
bool handleMessage(const MessageDTO &message)
Definition: BittyBuzzMessageHandler.cpp:247
ILogger.h