blob: 3a2d0a099a16a31f96b31e556fe53afe4cfe279a [file] [log] [blame]
Jagpal Singh Gillca8c7e92024-11-02 16:51:48 -07001#pragma once
2
3#include "CableConfig.hpp"
4#include "CableEvents.hpp"
5#include "EntityManagerInterface.hpp"
6#include "NotifyWatch.hpp"
7
8#include <sdbusplus/async.hpp>
9#include <sdbusplus/message/native_types.hpp>
10#include <xyz/openbmc_project/Inventory/Item/Cable/client.hpp>
11
12#include <string>
13
14namespace cable
15{
16
17class Monitor;
18
19using CableInventoryIntf =
20 sdbusplus::client::xyz::openbmc_project::inventory::item::Cable<>;
21
22class Monitor
23{
24 public:
25 Monitor() = delete;
26
27 explicit Monitor(sdbusplus::async::context& ctx);
28
29 private:
30 /** @brief Callback handler for new interfaces added to inventory */
31 auto inventoryAddedHandler(
32 const sdbusplus::message::object_path& objectPath,
33 const std::string& interfaceName) -> void;
34
35 /** @brief Callback handler for interfaces removed from inventory */
36 auto inventoryRemovedHandler(
37 const sdbusplus::message::object_path& objectPath,
38 const std::string& interfaceName) -> void;
39
40 /** @brief Callback handler for async updates to cable JSON configuration */
41 auto configUpdateHandler(std::string configFileName)
42 -> sdbusplus::async::task<>;
43
44 /** @brief Start the Cable Monitor */
45 auto start() -> sdbusplus::async::task<>;
46
47 /** @brief Asynchronously process cable inventory added */
48 auto processCableAddedAsync(sdbusplus::message::object_path objectPath)
49 -> sdbusplus::async::task<>;
50
51 /** @brief Asynchronously process cable inventory removed */
52 auto processCableRemovedAsync(sdbusplus::message::object_path objectPath)
53 -> sdbusplus::async::task<>;
54
55 /** @brief Reconcile connected and expected cable data */
56 auto reconcileCableData() -> void;
57
58 sdbusplus::async::context& ctx;
59 Config::Cables connectedCables;
60 Config::Cables expectedCables;
61 Events cableEvents;
62 entity_manager::EntityManagerInterface entityManager;
63 notify_watch::NotifyWatch notifyWatch;
64};
65
66} // namespace cable