1 #pragma once
2 #include "common/utils.hpp"
3 #include "pldmd/handler.hpp"
4 
5 namespace pldm
6 {
7 namespace responder
8 {
9 
10 namespace platform_config
11 {
12 using namespace pldm::utils;
13 
14 static constexpr auto compatibleInterface =
15     "xyz.openbmc_project.Inventory.Decorator.Compatible";
16 static constexpr auto namesProperty = "Names";
17 
18 using SystemTypeCallback = std::function<void(const std::string&, bool)>;
19 
20 class Handler : public CmdHandler
21 {
22   public:
Handler()23     Handler()
24     {
25         systemCompatibleMatchCallBack =
26             std::make_unique<sdbusplus::bus::match_t>(
27                 pldm::utils::DBusHandler::getBus(),
28                 sdbusplus::bus::match::rules::interfacesAdded() +
29                     sdbusplus::bus::match::rules::sender(
30                         "xyz.openbmc_project.EntityManager"),
31                 std::bind(&Handler::systemCompatibleCallback, this,
32                           std::placeholders::_1));
33         sysTypeCallback = nullptr;
34     }
35 
36     /** @brief Interface to get the system type information using Dbus query
37      *
38      *  @return - the system type information
39      */
40     virtual std::optional<std::filesystem::path> getPlatformName();
41 
42     /** @brief D-Bus Interface added signal match for Entity Manager */
43     void systemCompatibleCallback(sdbusplus::message_t& msg);
44 
45     /** @brief Registers the callback from other objects */
46     void registerSystemTypeCallback(SystemTypeCallback callback);
47 
48   private:
49     /** @brief system type/model */
50     std::string systemType;
51 
52     /** @brief D-Bus Interface added signal match for Entity Manager */
53     std::unique_ptr<sdbusplus::bus::match_t> systemCompatibleMatchCallBack;
54 
55     /** @brief Registered Callback */
56     SystemTypeCallback sysTypeCallback;
57 };
58 
59 } // namespace platform_config
60 
61 } // namespace responder
62 
63 } // namespace pldm
64