30 std::shared_ptr<boost::asio::io_context> external_ioc) {
32 [&external_ioc](
const auto& config) -> std::shared_ptr<interface::Channel> {
33 using T = std::decay_t<decltype(config)>;
35 if constexpr (std::is_same_v<T, config::TcpClientConfig>) {
36 return create_tcp_client(config, external_ioc);
37 }
else if constexpr (std::is_same_v<T, config::TcpServerConfig>) {
38 return create_tcp_server(config, external_ioc);
39 }
else if constexpr (std::is_same_v<T, config::SerialConfig>) {
40 return create_serial(config, external_ioc);
41 }
else if constexpr (std::is_same_v<T, config::UdpConfig>) {
42 return create_udp(config, external_ioc);
44 static_assert(std::is_same_v<T, void>,
"Unsupported config type");
51 std::shared_ptr<interface::Channel> ChannelFactory::create_tcp_server(
54 auto acceptor = std::make_unique<transport::BoostTcpAcceptor>(*external_ioc);
60 std::shared_ptr<interface::Channel> ChannelFactory::create_tcp_client(
61 const config::TcpClientConfig& cfg, std::shared_ptr<boost::asio::io_context> external_ioc) {
68 std::shared_ptr<interface::Channel> ChannelFactory::create_serial(
69 const config::SerialConfig& cfg, std::shared_ptr<boost::asio::io_context> external_ioc) {
76 std::shared_ptr<interface::Channel> ChannelFactory::create_udp(
const config::UdpConfig& cfg,
77 std::shared_ptr<boost::asio::io_context> external_ioc) {
std::variant< config::TcpClientConfig, config::TcpServerConfig, config::SerialConfig, config::UdpConfig > ChannelOptions
static std::shared_ptr< interface::Channel > create(const ChannelOptions &options, std::shared_ptr< boost::asio::io_context > external_ioc=nullptr)
static std::shared_ptr< Serial > create(const config::SerialConfig &cfg)
static std::shared_ptr< TcpClient > create(const TcpClientConfig &cfg)
static std::shared_ptr< TcpServer > create(const config::TcpServerConfig &cfg)
static std::shared_ptr< UdpChannel > create(const config::UdpConfig &cfg)