| Jagpal Singh Gill | cad9ecf | 2025-10-22 19:53:16 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "common/entity_manager_interface.hpp" |
| Jagpal Singh Gill | e92aba4 | 2025-10-16 00:00:13 -0700 | [diff] [blame^] | 4 | #include "device/base_device.hpp" |
| Jagpal Singh Gill | cad9ecf | 2025-10-22 19:53:16 -0700 | [diff] [blame] | 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; |
| Jagpal Singh Gill | e92aba4 | 2025-10-16 00:00:13 -0700 | [diff] [blame^] | 15 | namespace ModbusIntf = phosphor::modbus::rtu; |
| 16 | namespace DeviceIntf = phosphor::modbus::rtu::device; |
| Jagpal Singh Gill | cad9ecf | 2025-10-22 19:53:16 -0700 | [diff] [blame] | 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>>; |
| Jagpal Singh Gill | e92aba4 | 2025-10-16 00:00:13 -0700 | [diff] [blame^] | 32 | |
| Jagpal Singh Gill | cad9ecf | 2025-10-22 19:53:16 -0700 | [diff] [blame] | 33 | using port_map_t = |
| 34 | std::unordered_map<std::string, std::unique_ptr<PortIntf::BasePort>>; |
| 35 | |
| Jagpal Singh Gill | e92aba4 | 2025-10-16 00:00:13 -0700 | [diff] [blame^] | 36 | using device_map_t = |
| 37 | std::unordered_map<std::string, |
| 38 | std::unique_ptr<DeviceIntf::BaseDevice>>; |
| 39 | |
| Jagpal Singh Gill | cad9ecf | 2025-10-22 19:53:16 -0700 | [diff] [blame] | 40 | auto processConfigAdded(const sdbusplus::message::object_path& objectPath, |
| 41 | const std::string& interfaceName) |
| 42 | -> sdbusplus::async::task<>; |
| 43 | |
| Jagpal Singh Gill | e92aba4 | 2025-10-16 00:00:13 -0700 | [diff] [blame^] | 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 | |
| Jagpal Singh Gill | cad9ecf | 2025-10-22 19:53:16 -0700 | [diff] [blame] | 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; |
| Jagpal Singh Gill | e92aba4 | 2025-10-16 00:00:13 -0700 | [diff] [blame^] | 64 | device_map_t devices; // Modbus devices |
| Jagpal Singh Gill | cad9ecf | 2025-10-22 19:53:16 -0700 | [diff] [blame] | 65 | }; |
| 66 | |
| 67 | } // namespace phosphor::modbus::rtu |