xref: /openbmc/phosphor-modbus/rtu/port/port_factory.hpp (revision b62e3dfe5505fdb8c2ab96156b62e3bfb878b7a6)
17f9d41ddSJagpal Singh Gill #pragma once
27f9d41ddSJagpal Singh Gill 
37f9d41ddSJagpal Singh Gill #include "base_port.hpp"
47f9d41ddSJagpal Singh Gill 
57f9d41ddSJagpal Singh Gill #include <sdbusplus/async.hpp>
67f9d41ddSJagpal Singh Gill 
77f9d41ddSJagpal Singh Gill #include <string>
87f9d41ddSJagpal Singh Gill #include <vector>
97f9d41ddSJagpal Singh Gill 
107f9d41ddSJagpal Singh Gill namespace phosphor::modbus::rtu::port
117f9d41ddSJagpal Singh Gill {
127f9d41ddSJagpal Singh Gill 
137f9d41ddSJagpal Singh Gill namespace config
147f9d41ddSJagpal Singh Gill {
157f9d41ddSJagpal Singh Gill 
167f9d41ddSJagpal Singh Gill enum class PortType
177f9d41ddSJagpal Singh Gill {
187f9d41ddSJagpal Singh Gill     usb,
197f9d41ddSJagpal Singh Gill     unknown
207f9d41ddSJagpal Singh Gill };
217f9d41ddSJagpal Singh Gill 
227f9d41ddSJagpal Singh Gill struct PortFactoryConfig : public Config
237f9d41ddSJagpal Singh Gill {
247f9d41ddSJagpal Singh Gill     PortType portType = PortType::unknown;
25*b62e3dfeSJagpal Singh Gill 
26*b62e3dfeSJagpal Singh Gill     virtual ~PortFactoryConfig() = default;
277f9d41ddSJagpal Singh Gill };
287f9d41ddSJagpal Singh Gill 
297f9d41ddSJagpal Singh Gill } // namespace config
307f9d41ddSJagpal Singh Gill 
317f9d41ddSJagpal Singh Gill class PortFactory
327f9d41ddSJagpal Singh Gill {
337f9d41ddSJagpal Singh Gill   public:
347f9d41ddSJagpal Singh Gill     static auto getInterfaces() -> std::vector<std::string>;
357f9d41ddSJagpal Singh Gill 
367f9d41ddSJagpal Singh Gill     static auto getConfig(sdbusplus::async::context& ctx,
377f9d41ddSJagpal Singh Gill                           const sdbusplus::message::object_path& objectPath,
387f9d41ddSJagpal Singh Gill                           const std::string& interfaceName)
39*b62e3dfeSJagpal Singh Gill         -> sdbusplus::async::task<std::unique_ptr<config::PortFactoryConfig>>;
407f9d41ddSJagpal Singh Gill 
417f9d41ddSJagpal Singh Gill     static auto create(sdbusplus::async::context& ctx,
42*b62e3dfeSJagpal Singh Gill                        const config::PortFactoryConfig& config)
437f9d41ddSJagpal Singh Gill         -> std::unique_ptr<BasePort>;
447f9d41ddSJagpal Singh Gill };
457f9d41ddSJagpal Singh Gill 
467f9d41ddSJagpal Singh Gill } // namespace phosphor::modbus::rtu::port
47