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