12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- //
- // 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"
- class System_communication:public Singleton<System_communication>, public Communication_socket_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 check_msg(Communication_message* p_msg);
- //检查执行者的状态, 判断能否处理这条消息, 需要子类重载
- virtual Error_manager check_executer(Communication_message* p_msg);
- //处理消息, 需要子类重载
- virtual Error_manager execute_msg(Communication_message* p_msg);
- //定时封装发送消息, 一般为心跳和状态信息, 需要子类重载
- virtual Error_manager encapsulate_send_data();
- public://get or set member variable
-
- protected://member variable
-
- private:
-
- };
- #endif //NNXX_TESTS_SYSTEM_COMMUNICATION_H
|