1 #include "port_factory.hpp" 2 3 #include "usb_port.hpp" 4 5 #include <xyz/openbmc_project/Configuration/USBPort/client.hpp> 6 7 namespace phosphor::modbus::rtu::port 8 { 9 10 using USBPortConfigIntf = 11 sdbusplus::client::xyz::openbmc_project::configuration::USBPort<>; 12 getInterfaces()13auto PortFactory::getInterfaces() -> std::vector<std::string> 14 { 15 return {USBPortConfigIntf::interface}; 16 } 17 getConfig(sdbusplus::async::context & ctx,const sdbusplus::message::object_path & objectPath,const std::string & interfaceName)18auto PortFactory::getConfig(sdbusplus::async::context& ctx, 19 const sdbusplus::message::object_path& objectPath, 20 const std::string& interfaceName) 21 -> sdbusplus::async::task<std::unique_ptr<config::PortFactoryConfig>> 22 { 23 if (interfaceName == USBPortConfigIntf::interface) 24 { 25 co_return co_await USBPort::getConfig(ctx, objectPath); 26 } 27 28 co_return std::nullptr_t(); 29 } 30 create(sdbusplus::async::context & ctx,const config::PortFactoryConfig & config)31auto PortFactory::create(sdbusplus::async::context& ctx, 32 const config::PortFactoryConfig& config) 33 -> std::unique_ptr<BasePort> 34 { 35 if (config.portType == config::PortType::usb) 36 { 37 return std::make_unique<USBPort>(ctx, config); 38 } 39 40 return nullptr; 41 } 42 43 } // namespace phosphor::modbus::rtu::port 44