parkspace_communicator.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // Created by zx on 2020/6/18.
  3. //
  4. #ifndef PARKSPACE_ALLOCATION_COMMUNICATOR_H
  5. #define PARKSPACE_ALLOCATION_COMMUNICATOR_H
  6. #include <mutex>
  7. #include "communication_socket_base.h"
  8. #include "singleton.h"
  9. #include "parkspace_allocation_message.pb.h"
  10. #include "error_code.h"
  11. class Parkspace_communicator: public Singleton<Parkspace_communicator>, public Communication_socket_base
  12. {
  13. friend Singleton<Parkspace_communicator>;
  14. private:
  15. Parkspace_communicator();
  16. public:
  17. virtual ~Parkspace_communicator();
  18. //外部调用,反馈结果消息
  19. Error_manager send_response(Communication_message* message);
  20. //封装反馈消息,加入队列父类自行发送
  21. virtual Error_manager encapsulate_msg(Communication_message* message);
  22. //封装发送消息
  23. virtual Error_manager encapsulate_msg(std::string message);
  24. protected:
  25. //解析车位分配请求消息具体内容,激活车位分配单例处理函数(不可阻塞),获得结果后由车位分配单例封装消息发送
  26. virtual Error_manager execute_msg(Communication_message* p_msg);
  27. //检查是否接收到本模块需要的消息,重载后父类自行调用判断
  28. virtual Error_manager check_msg(Communication_message* p_msg);
  29. //重载检查执行者函数,判断执行者状态
  30. virtual Error_manager check_executer(Communication_message* p_msg);
  31. //心跳与车位实时信息
  32. virtual Error_manager encapsulate_send_data();
  33. };
  34. #endif //PARKSPACE_ALLOCATION_COMMUNICATOR_H