1 #pragma once 2 3 #include "common/entity_manager_interface.hpp" 4 #include "device/base_device.hpp" 5 #include "inventory/modbus_inventory.hpp" 6 #include "port/base_port.hpp" 7 8 #include <sdbusplus/async.hpp> 9 10 namespace phosphor::modbus::rtu 11 { 12 13 namespace InventoryIntf = phosphor::modbus::rtu::inventory; 14 namespace PortIntf = phosphor::modbus::rtu::port; 15 namespace ModbusIntf = phosphor::modbus::rtu; 16 namespace DeviceIntf = phosphor::modbus::rtu::device; 17 18 class DeviceManager 19 { 20 public: 21 DeviceManager() = delete; 22 DeviceManager(const DeviceManager&) = delete; 23 DeviceManager& operator=(const DeviceManager&) = delete; 24 DeviceManager(DeviceManager&&) = delete; 25 DeviceManager& operator=(DeviceManager&&) = delete; 26 27 explicit DeviceManager(sdbusplus::async::context& ctx); 28 29 private: 30 using inventory_device_map_t = 31 std::unordered_map<std::string, std::unique_ptr<InventoryIntf::Device>>; 32 33 using port_map_t = 34 std::unordered_map<std::string, std::unique_ptr<PortIntf::BasePort>>; 35 36 using device_map_t = 37 std::unordered_map<std::string, 38 std::unique_ptr<DeviceIntf::BaseDevice>>; 39 40 auto processConfigAdded(const sdbusplus::message::object_path& objectPath, 41 const std::string& interfaceName) 42 -> sdbusplus::async::task<>; 43 44 auto processPortAdded(const sdbusplus::message::object_path& objectPath, 45 const std::string& interfaceName) 46 -> sdbusplus::async::task<>; 47 48 auto processInventoryAdded( 49 const sdbusplus::message::object_path& objectPath) 50 -> sdbusplus::async::task<>; 51 52 auto processDeviceAdded(const sdbusplus::message::object_path& objectPath, 53 const std::string& interfaceName) 54 -> sdbusplus::async::task<>; 55 56 auto processConfigRemoved(const sdbusplus::message::object_path& objectPath, 57 const std::string& interfaceName) 58 -> sdbusplus::async::task<>; 59 60 sdbusplus::async::context& ctx; 61 entity_manager::EntityManagerInterface entityManager; 62 inventory_device_map_t inventoryDevices; 63 port_map_t ports; 64 device_map_t devices; // Modbus devices 65 }; 66 67 } // namespace phosphor::modbus::rtu 68