blob: 3934c61fe3541d8f3c843581e36ff80b6a69ffa1 [file] [log] [blame]
Kamalkumar Patel3c50c822024-01-30 07:14:40 -06001#pragma once
2#include "common/utils.hpp"
3#include "pldmd/handler.hpp"
4
5#include <phosphor-logging/lg2.hpp>
6
7PHOSPHOR_LOG2_USING;
8
9namespace pldm
10{
11namespace responder
12{
13
14namespace platform_config
15{
16using namespace pldm::utils;
17
18static constexpr auto compatibleInterface =
19 "xyz.openbmc_project.Inventory.Decorator.Compatible";
20static constexpr auto namesProperty = "Names";
21
Archana Kakani62dd8ff2024-02-12 10:00:40 -060022using SystemTypeCallback = std::function<void(const std::string&)>;
23
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060024class Handler : public CmdHandler
25{
26 public:
27 Handler()
28 {
29 systemCompatibleMatchCallBack =
Patrick Williams157f5d02024-02-13 02:36:55 -060030 std::make_unique<sdbusplus::bus::match_t>(
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060031 pldm::utils::DBusHandler::getBus(),
32 sdbusplus::bus::match::rules::interfacesAdded() +
33 sdbusplus::bus::match::rules::sender(
34 "xyz.openbmc_project.EntityManager"),
35 std::bind(&Handler::systemCompatibleCallback, this,
36 std::placeholders::_1));
Archana Kakani62dd8ff2024-02-12 10:00:40 -060037 sysTypeCallback = nullptr;
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060038 }
39
Archana Kakani62dd8ff2024-02-12 10:00:40 -060040 /** @brief Interface to get the system type information using Dbus query
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060041 *
42 * @return - the system type information
43 */
44 virtual std::optional<std::filesystem::path> getPlatformName();
45
46 /** @brief D-Bus Interface added signal match for Entity Manager */
47 void systemCompatibleCallback(sdbusplus::message_t& msg);
48
Archana Kakani62dd8ff2024-02-12 10:00:40 -060049 /** @brief Registers the callback from other objects */
50 void registerSystemTypeCallback(SystemTypeCallback callback);
51
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060052 private:
53 /** @brief system type/model */
54 std::string systemType;
55
56 /** @brief D-Bus Interface added signal match for Entity Manager */
57 std::unique_ptr<sdbusplus::bus::match_t> systemCompatibleMatchCallBack;
Archana Kakani62dd8ff2024-02-12 10:00:40 -060058
59 /** @brief Registered Callback */
60 SystemTypeCallback sysTypeCallback;
Kamalkumar Patel3c50c822024-01-30 07:14:40 -060061};
62
63} // namespace platform_config
64
65} // namespace responder
66
67} // namespace pldm