123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- //
- // Created by huli on 2023/1/3.
- //
- #ifndef NNXX_TESTS_DISPATCH_NETWORK_H
- #define NNXX_TESTS_DISPATCH_NETWORK_H
- #include "../tool/singleton.h"
- #include "../network_communication/network_base.h"
- class Dispatch_network:public Singleton<Dispatch_network>, public Network_base
- {
- // 子类必须把父类设定为友元函数,这样父类才能使用子类的私有构造函数。
- friend class Singleton<Dispatch_network>;
- public:
- #define NETKORK_PARAMETER_PATH_A "../setting/network_a.prototxt"
- #define NETKORK_PARAMETER_PATH_B "../setting/network_b.prototxt"
- #define NETKORK_PARAMETER_PATH_C "../setting/network_c.prototxt"
- private:
- // 父类的构造函数必须保护,子类的构造函数必须私有。
- Dispatch_network();
- public:
- //必须关闭拷贝构造和赋值构造,只能通过 get_instance 函数来进行操作唯一的实例。
- Dispatch_network(const Dispatch_network& other) = delete;
- Dispatch_network& operator =(const Dispatch_network& other) = delete;
- ~Dispatch_network();
- public://API functions
- //初始化 通信 模块。如下三选一
- virtual Error_manager network_init();
- virtual Error_manager network_init(int dispatch_id);
- //检查消息是否有效, 主要检查消息类型和接受者, 判断这条消息是不是给我的.
- virtual Error_manager check_msg(Network_message* p_msg);
- //检查执行者的状态, 判断能否处理这条消息, 需要子类重载
- virtual Error_manager check_executer(Network_message* p_msg);
- //处理消息, 需要子类重载
- virtual Error_manager execute_msg(Network_message* p_msg);
- //定时封装发送消息, 一般为心跳和状态信息, 需要子类重载
- virtual Error_manager auto_encapsulate_status();
- public://get or set member variable
- protected://member functions
- protected://member variable
- private:
- };
- #endif //NNXX_TESTS_DISPATCH_NETWORK_H
|