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