blob: 75fe75b2082c9f435a49458261c504d831e32d06 [file] [log] [blame]
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -07001#pragma once
2
3#include "common/entity_manager_interface.hpp"
Jagpal Singh Gille92aba42025-10-16 00:00:13 -07004#include "device/base_device.hpp"
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -07005#include "inventory/modbus_inventory.hpp"
6#include "port/base_port.hpp"
7
8#include <sdbusplus/async.hpp>
9
10namespace phosphor::modbus::rtu
11{
12
13namespace InventoryIntf = phosphor::modbus::rtu::inventory;
14namespace PortIntf = phosphor::modbus::rtu::port;
Jagpal Singh Gille92aba42025-10-16 00:00:13 -070015namespace ModbusIntf = phosphor::modbus::rtu;
16namespace DeviceIntf = phosphor::modbus::rtu::device;
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070017
18class 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 Gille92aba42025-10-16 00:00:13 -070032
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070033 using port_map_t =
34 std::unordered_map<std::string, std::unique_ptr<PortIntf::BasePort>>;
35
Jagpal Singh Gille92aba42025-10-16 00:00:13 -070036 using device_map_t =
37 std::unordered_map<std::string,
38 std::unique_ptr<DeviceIntf::BaseDevice>>;
39
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070040 auto processConfigAdded(const sdbusplus::message::object_path& objectPath,
41 const std::string& interfaceName)
42 -> sdbusplus::async::task<>;
43
Jagpal Singh Gille92aba42025-10-16 00:00:13 -070044 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 Gillcad9ecf2025-10-22 19:53:16 -070056 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 Gille92aba42025-10-16 00:00:13 -070064 device_map_t devices; // Modbus devices
Jagpal Singh Gillcad9ecf2025-10-22 19:53:16 -070065};
66
67} // namespace phosphor::modbus::rtu