blob: 08f15d6bb324b80a59ef72dc53f0ce4c45a59ab0 [file] [log] [blame]
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -07001#pragma once
2
3#include "common/entity_manager_interface.hpp"
Jagpal Singh Gill71848052025-10-16 00:28:58 -07004#include "common/events.hpp"
Jagpal Singh Gille92aba42025-10-16 00:00:13 -07005#include "device/base_device.hpp"
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -07006#include "inventory/modbus_inventory.hpp"
7#include "port/base_port.hpp"
8
9#include <sdbusplus/async.hpp>
10
11namespace phosphor::modbus::rtu
12{
13
14namespace InventoryIntf = phosphor::modbus::rtu::inventory;
15namespace PortIntf = phosphor::modbus::rtu::port;
Jagpal Singh Gille92aba42025-10-16 00:00:13 -070016namespace ModbusIntf = phosphor::modbus::rtu;
17namespace DeviceIntf = phosphor::modbus::rtu::device;
Jagpal Singh Gill71848052025-10-16 00:28:58 -070018namespace EventIntf = phosphor::modbus::events;
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070019
20class 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>>;
Jagpal Singh Gille92aba42025-10-16 00:00:13 -070034
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070035 using port_map_t =
36 std::unordered_map<std::string, std::unique_ptr<PortIntf::BasePort>>;
37
Jagpal Singh Gille92aba42025-10-16 00:00:13 -070038 using device_map_t =
39 std::unordered_map<std::string,
40 std::unique_ptr<DeviceIntf::BaseDevice>>;
41
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070042 auto processConfigAdded(const sdbusplus::message::object_path& objectPath,
43 const std::string& interfaceName)
44 -> sdbusplus::async::task<>;
45
Jagpal Singh Gille92aba42025-10-16 00:00:13 -070046 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
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070058 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;
Jagpal Singh Gill71848052025-10-16 00:28:58 -070064 EventIntf::Events events;
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070065 inventory_device_map_t inventoryDevices;
66 port_map_t ports;
Jagpal Singh Gille92aba42025-10-16 00:00:13 -070067 device_map_t devices; // Modbus devices
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070068};
69
70} // namespace phosphor::modbus::rtu