//
// Created by huli on 2020/6/28.
//

#ifndef NNXX_TESTS_SYSTEM_COMMUNICATION_H
#define NNXX_TESTS_SYSTEM_COMMUNICATION_H

#include "../tool/singleton.h"
//#include "../communication/communication_socket_base.h"
#include "../rabbitmq/rabbitmq_base.h"

#define RABBITMQ_PARAMETER_PATH_A "../setting/rabbitmq_a.prototxt"
#define RABBITMQ_PARAMETER_PATH_B "../setting/rabbitmq_b.prototxt"
#define RABBITMQ_PARAMETER_PATH_C "../setting/rabbitmq_c.prototxt"


class System_communication:public Singleton<System_communication>, public Rabbitmq_base
{

// 子类必须把父类设定为友元函数，这样父类才能使用子类的私有构造函数。
   friend class Singleton<System_communication>;
private:
 // 父类的构造函数必须保护，子类的构造函数必须私有。
   System_communication();
public:
    //必须关闭拷贝构造和赋值构造，只能通过 get_instance 函数来进行操作唯一的实例。
    System_communication(const System_communication& other) = delete;
    System_communication& operator =(const System_communication& other) = delete;
    ~System_communication();
public://API functions
	//初始化 通信 模块。如下三选一
	virtual Error_manager communication_init();
	virtual Error_manager communication_init(int dispatch_id);
	//检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
	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();

public://get or set member variable

    
protected://member variable 

    
private:
    
};


#endif //NNXX_TESTS_SYSTEM_COMMUNICATION_H
