xref: /openbmc/phosphor-modbus/rtu/device_manager.hpp (revision cad9ecf69472f03f9ece64eff5d2d94bc51bcf90)
1*cad9ecf6SJagpal Singh Gill #pragma once
2*cad9ecf6SJagpal Singh Gill 
3*cad9ecf6SJagpal Singh Gill #include "common/entity_manager_interface.hpp"
4*cad9ecf6SJagpal Singh Gill #include "inventory/modbus_inventory.hpp"
5*cad9ecf6SJagpal Singh Gill #include "port/base_port.hpp"
6*cad9ecf6SJagpal Singh Gill 
7*cad9ecf6SJagpal Singh Gill #include <sdbusplus/async.hpp>
8*cad9ecf6SJagpal Singh Gill 
9*cad9ecf6SJagpal Singh Gill namespace phosphor::modbus::rtu
10*cad9ecf6SJagpal Singh Gill {
11*cad9ecf6SJagpal Singh Gill 
12*cad9ecf6SJagpal Singh Gill namespace InventoryIntf = phosphor::modbus::rtu::inventory;
13*cad9ecf6SJagpal Singh Gill namespace PortIntf = phosphor::modbus::rtu::port;
14*cad9ecf6SJagpal Singh Gill 
15*cad9ecf6SJagpal Singh Gill class DeviceManager
16*cad9ecf6SJagpal Singh Gill {
17*cad9ecf6SJagpal Singh Gill   public:
18*cad9ecf6SJagpal Singh Gill     DeviceManager() = delete;
19*cad9ecf6SJagpal Singh Gill     DeviceManager(const DeviceManager&) = delete;
20*cad9ecf6SJagpal Singh Gill     DeviceManager& operator=(const DeviceManager&) = delete;
21*cad9ecf6SJagpal Singh Gill     DeviceManager(DeviceManager&&) = delete;
22*cad9ecf6SJagpal Singh Gill     DeviceManager& operator=(DeviceManager&&) = delete;
23*cad9ecf6SJagpal Singh Gill 
24*cad9ecf6SJagpal Singh Gill     explicit DeviceManager(sdbusplus::async::context& ctx);
25*cad9ecf6SJagpal Singh Gill 
26*cad9ecf6SJagpal Singh Gill   private:
27*cad9ecf6SJagpal Singh Gill     using inventory_device_map_t =
28*cad9ecf6SJagpal Singh Gill         std::unordered_map<std::string, std::unique_ptr<InventoryIntf::Device>>;
29*cad9ecf6SJagpal Singh Gill     using port_map_t =
30*cad9ecf6SJagpal Singh Gill         std::unordered_map<std::string, std::unique_ptr<PortIntf::BasePort>>;
31*cad9ecf6SJagpal Singh Gill 
32*cad9ecf6SJagpal Singh Gill     auto processConfigAdded(const sdbusplus::message::object_path& objectPath,
33*cad9ecf6SJagpal Singh Gill                             const std::string& interfaceName)
34*cad9ecf6SJagpal Singh Gill         -> sdbusplus::async::task<>;
35*cad9ecf6SJagpal Singh Gill 
36*cad9ecf6SJagpal Singh Gill     auto processConfigRemoved(const sdbusplus::message::object_path& objectPath,
37*cad9ecf6SJagpal Singh Gill                               const std::string& interfaceName)
38*cad9ecf6SJagpal Singh Gill         -> sdbusplus::async::task<>;
39*cad9ecf6SJagpal Singh Gill 
40*cad9ecf6SJagpal Singh Gill     sdbusplus::async::context& ctx;
41*cad9ecf6SJagpal Singh Gill     entity_manager::EntityManagerInterface entityManager;
42*cad9ecf6SJagpal Singh Gill     inventory_device_map_t inventoryDevices;
43*cad9ecf6SJagpal Singh Gill     port_map_t ports;
44*cad9ecf6SJagpal Singh Gill };
45*cad9ecf6SJagpal Singh Gill 
46*cad9ecf6SJagpal Singh Gill } // namespace phosphor::modbus::rtu
47