/* * @Author: yct 18202736439@163.com * @Date: 2022-09-30 18:09:07 * @LastEditors: yct 18202736439@163.com * @LastEditTime: 2022-09-30 18:35:01 * @FilePath: /puai_wj_2021/system/system_communication_mq.h * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE */ // // Created by huli on 2020/6/28. // #ifndef NNXX_TESTS_SYSTEM_COMMUNICATION_MQ_H #define NNXX_TESTS_SYSTEM_COMMUNICATION_MQ_H #include "../tool/singleton.h" #include "../rabbitmq/rabbitmq_base.h" #include "../message/message.pb.h" #include #include class System_communication_mq:public Singleton, public Rabbitmq_base { // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。 friend class Singleton; private: // 父类的构造函数必须保护,子类的构造函数必须私有。 System_communication_mq(); public: //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。 System_communication_mq(const System_communication_mq& other) = delete; System_communication_mq& operator =(const System_communication_mq& other) = delete; ~System_communication_mq(); public://API functions //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的. virtual Error_manager check_msg(Rabbitmq_message* p_msg); //检查执行者的状态, 判断能否处理这条消息, 需要子类重载 virtual Error_manager check_executer(Rabbitmq_message* p_msg); //处理消息, 需要子类重载 virtual Error_manager execute_msg(Rabbitmq_message* p_msg); //定时封装发送消息, 一般为心跳和状态信息, 需要子类重载 virtual Error_manager auto_encapsulate_status(); //get dispatch status, save local Error_manager execute_dispatch_status_msg(Rabbitmq_message* p_msg); public://get or set member variable protected://member variable public: std::mutex m_lock; //锁, std::map dispatch_region_info_map; private: }; #endif //NNXX_TESTS_SYSTEM_COMMUNICATION_MQ_H