system_communication.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // Created by huli on 2020/6/28.
  3. //
  4. #ifndef NNXX_TESTS_SYSTEM_COMMUNICATION_H
  5. #define NNXX_TESTS_SYSTEM_COMMUNICATION_H
  6. #include "../tool/singleton.h"
  7. //#include "../communication/communication_socket_base.h"
  8. #include "../rabbitmq/rabbitmq_base.h"
  9. #define RABBITMQ_PARAMETER_PATH_A "../setting/rabbitmq_a.prototxt"
  10. #define RABBITMQ_PARAMETER_PATH_B "../setting/rabbitmq_b.prototxt"
  11. #define RABBITMQ_PARAMETER_PATH_C "../setting/rabbitmq_c.prototxt"
  12. class System_communication:public Singleton<System_communication>, public Rabbitmq_base
  13. {
  14. // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
  15. friend class Singleton<System_communication>;
  16. private:
  17. // 父类的构造函数必须保护,子类的构造函数必须私有。
  18. System_communication();
  19. public:
  20. //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
  21. System_communication(const System_communication& other) = delete;
  22. System_communication& operator =(const System_communication& other) = delete;
  23. ~System_communication();
  24. public://API functions
  25. //初始化 通信 模块。如下三选一
  26. virtual Error_manager communication_init();
  27. virtual Error_manager communication_init(int dispatch_id);
  28. //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
  29. virtual Error_manager check_msg(Rabbitmq_message* p_msg);
  30. //检查执行者的状态, 判断能否处理这条消息, 需要子类重载
  31. virtual Error_manager check_executer(Rabbitmq_message* p_msg);
  32. //处理消息, 需要子类重载
  33. virtual Error_manager execute_msg(Rabbitmq_message* p_msg);
  34. //定时封装发送消息, 一般为心跳和状态信息, 需要子类重载
  35. virtual Error_manager auto_encapsulate_status();
  36. public://get or set member variable
  37. protected://member variable
  38. private:
  39. };
  40. #endif //NNXX_TESTS_SYSTEM_COMMUNICATION_H