#pragma once #include #include #include #include "String.DString.hpp" #include "IO.Profile.hpp" #include "IO.Profile.BUS.Define.hpp" namespace ECOM::IO { class Link; } namespace ECOM::ServiceBus::Controller { namespace Role { using IOLink = ECOM::IO::Link; //----------------------------------------------------------------------------- // Sender //----------------------------------------------------------------------------- class _IO_Profile_BUS_API Sender { public: Sender (); virtual ~Sender (); public: // !! 返回值一定非空. 但是不能保证返回的 Link 一定是 Connected virtual auto NewLink () -> std::unique_ptr = 0; // 命令端口. public: int GetNbOfChannel () const; // 总共有多少个通道 ? virtual int GetCommandPort () const = 0; virtual eSTR::DString ToString () const = 0; }; //----------------------------------------------------------------------------- // Receiver // 此对象需要设计成线程安全的, 或者说一旦构造完毕就是只读的. // 因为对象需要在线程之间共享, BUSY::FireOnMessage () 等函数中, 把这个对象直接传递到异步线程中. //----------------------------------------------------------------------------- class _IO_Profile_BUS_API Receiver { public: Receiver (); virtual ~Receiver (); public: // !! 返回值一定非空. 但是不能保证返回的 Link 一定是 Connected virtual auto NewLink () -> std::unique_ptr = 0; // 状态端口, 接收 virtual auto NewLinkForCommand () -> std::unique_ptr = 0; // 命令端口, 发送. virtual auto NewLinkForAck () -> std::unique_ptr = 0; // 命令端口, 发送 Ack. public: int GetNbOfChannel () const; // 总共有多少个通道 ? virtual int GetStatusPort () const = 0; virtual eSTR::DString ToString () const = 0; // 返回格式: 192.168.1.100 -> 6631, 用于 Log 等 }; } } //namespace IOPBUS = ECOM::IO::Profile::ServiceBus;