#pragma once #include "thread/singleton.h" #include "rabbitmq/rabbitmq_base.h" #include "detect/detect_manager.h" #include "Boundary.h" class RabbitmqCommunicationTof3D : public Singleton, public Rabbitmq_base { // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。 friend class Singleton; private: // 父类的构造函数必须保护,子类的构造函数必须私有。 RabbitmqCommunicationTof3D(); public: //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。 Error_manager rabbitmq_init_from_protobuf(std::string prototxt_path); RabbitmqCommunicationTof3D(const RabbitmqCommunicationTof3D &other) = delete; RabbitmqCommunicationTof3D &operator=(const RabbitmqCommunicationTof3D &other) = delete; ~RabbitmqCommunicationTof3D(); 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 execute_time_consume_msg(Rabbitmq_message *p_msg); //定时封装发送消息, 一般为心跳和状态信息, 需要子类重载 virtual Error_manager auto_encapsulate_status(); public://get or set member variable protected://member variable public: std::mutex m_lock; //锁, private: Boundary m_boundary; };