common: add entity manager interface
Define an EntityManager interface to fetch the serial port related
config or any device config from Entity Manager.
Change-Id: Ieeff4422903e3b4bcc3ce28cd493eecab5618f13
Signed-off-by: Jagpal Singh Gill <paligill@gmail.com>
diff --git a/common/entity_manager_interface.hpp b/common/entity_manager_interface.hpp
new file mode 100644
index 0000000..86e1ba9
--- /dev/null
+++ b/common/entity_manager_interface.hpp
@@ -0,0 +1,44 @@
+#pragma once
+
+#include <sdbusplus/async.hpp>
+#include <sdbusplus/message/native_types.hpp>
+
+#include <functional>
+#include <string>
+#include <vector>
+
+namespace entity_manager
+{
+
+using interface_list_t = std::vector<std::string>;
+
+class EntityManagerInterface
+{
+ public:
+ using Callback_t = std::function<sdbusplus::async::task<>(
+ const sdbusplus::message::object_path&, const std::string&)>;
+ static constexpr auto serviceName = "xyz.openbmc_project.EntityManager";
+
+ EntityManagerInterface() = delete;
+
+ explicit EntityManagerInterface(
+ sdbusplus::async::context& ctx, const interface_list_t& interfaceNames,
+ Callback_t addedCallback, Callback_t removedCallback);
+
+ /** Get the inventory info from Entity Manager */
+ auto handleInventoryGet() -> sdbusplus::async::task<>;
+
+ private:
+ /** @brief Handle async inventory add from Entity Manager */
+ auto handleInventoryAdded() -> sdbusplus::async::task<>;
+
+ /** @brief Handle async inventory remove from Entity Manager */
+ auto handleInventoryRemoved() -> sdbusplus::async::task<>;
+
+ sdbusplus::async::context& ctx;
+ interface_list_t interfaceNames;
+ Callback_t addedCallback;
+ Callback_t removedCallback;
+};
+
+} // namespace entity_manager