xref: /openbmc/phosphor-modbus/common/entity_manager_interface.hpp (revision f69546b3c665e8ad83ede789c39e54cc0fc429c2)
1*f69546b3SJagpal Singh Gill #pragma once
2*f69546b3SJagpal Singh Gill 
3*f69546b3SJagpal Singh Gill #include <sdbusplus/async.hpp>
4*f69546b3SJagpal Singh Gill #include <sdbusplus/message/native_types.hpp>
5*f69546b3SJagpal Singh Gill 
6*f69546b3SJagpal Singh Gill #include <functional>
7*f69546b3SJagpal Singh Gill #include <string>
8*f69546b3SJagpal Singh Gill #include <vector>
9*f69546b3SJagpal Singh Gill 
10*f69546b3SJagpal Singh Gill namespace entity_manager
11*f69546b3SJagpal Singh Gill {
12*f69546b3SJagpal Singh Gill 
13*f69546b3SJagpal Singh Gill using interface_list_t = std::vector<std::string>;
14*f69546b3SJagpal Singh Gill 
15*f69546b3SJagpal Singh Gill class EntityManagerInterface
16*f69546b3SJagpal Singh Gill {
17*f69546b3SJagpal Singh Gill   public:
18*f69546b3SJagpal Singh Gill     using Callback_t = std::function<sdbusplus::async::task<>(
19*f69546b3SJagpal Singh Gill         const sdbusplus::message::object_path&, const std::string&)>;
20*f69546b3SJagpal Singh Gill     static constexpr auto serviceName = "xyz.openbmc_project.EntityManager";
21*f69546b3SJagpal Singh Gill 
22*f69546b3SJagpal Singh Gill     EntityManagerInterface() = delete;
23*f69546b3SJagpal Singh Gill 
24*f69546b3SJagpal Singh Gill     explicit EntityManagerInterface(
25*f69546b3SJagpal Singh Gill         sdbusplus::async::context& ctx, const interface_list_t& interfaceNames,
26*f69546b3SJagpal Singh Gill         Callback_t addedCallback, Callback_t removedCallback);
27*f69546b3SJagpal Singh Gill 
28*f69546b3SJagpal Singh Gill     /** Get the inventory info from Entity Manager */
29*f69546b3SJagpal Singh Gill     auto handleInventoryGet() -> sdbusplus::async::task<>;
30*f69546b3SJagpal Singh Gill 
31*f69546b3SJagpal Singh Gill   private:
32*f69546b3SJagpal Singh Gill     /** @brief Handle async inventory add from Entity Manager */
33*f69546b3SJagpal Singh Gill     auto handleInventoryAdded() -> sdbusplus::async::task<>;
34*f69546b3SJagpal Singh Gill 
35*f69546b3SJagpal Singh Gill     /** @brief Handle async inventory remove from Entity Manager */
36*f69546b3SJagpal Singh Gill     auto handleInventoryRemoved() -> sdbusplus::async::task<>;
37*f69546b3SJagpal Singh Gill 
38*f69546b3SJagpal Singh Gill     sdbusplus::async::context& ctx;
39*f69546b3SJagpal Singh Gill     interface_list_t interfaceNames;
40*f69546b3SJagpal Singh Gill     Callback_t addedCallback;
41*f69546b3SJagpal Singh Gill     Callback_t removedCallback;
42*f69546b3SJagpal Singh Gill };
43*f69546b3SJagpal Singh Gill 
44*f69546b3SJagpal Singh Gill } // namespace entity_manager
45