Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 1 | #pragma once |
| 2 | #include "common/utils.hpp" |
| 3 | #include "pldmd/handler.hpp" |
| 4 | |
| 5 | #include <phosphor-logging/lg2.hpp> |
| 6 | |
| 7 | PHOSPHOR_LOG2_USING; |
| 8 | |
| 9 | namespace pldm |
| 10 | { |
| 11 | namespace responder |
| 12 | { |
| 13 | |
| 14 | namespace platform_config |
| 15 | { |
| 16 | using namespace pldm::utils; |
| 17 | |
| 18 | static constexpr auto compatibleInterface = |
| 19 | "xyz.openbmc_project.Inventory.Decorator.Compatible"; |
| 20 | static constexpr auto namesProperty = "Names"; |
| 21 | |
Archana Kakani | 46f352e | 2024-03-17 08:21:08 -0500 | [diff] [blame] | 22 | using SystemTypeCallback = std::function<void(const std::string&, bool)>; |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 23 | |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 24 | class Handler : public CmdHandler |
| 25 | { |
| 26 | public: |
| 27 | Handler() |
| 28 | { |
| 29 | systemCompatibleMatchCallBack = |
Patrick Williams | 157f5d0 | 2024-02-13 02:36:55 -0600 | [diff] [blame] | 30 | std::make_unique<sdbusplus::bus::match_t>( |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 31 | 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 Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 37 | sysTypeCallback = nullptr; |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 38 | } |
| 39 | |
Archana Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 40 | /** @brief Interface to get the system type information using Dbus query |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 41 | * |
| 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 Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 49 | /** @brief Registers the callback from other objects */ |
| 50 | void registerSystemTypeCallback(SystemTypeCallback callback); |
| 51 | |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 52 | 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 Kakani | 62dd8ff | 2024-02-12 10:00:40 -0600 | [diff] [blame] | 58 | |
| 59 | /** @brief Registered Callback */ |
| 60 | SystemTypeCallback sysTypeCallback; |
Kamalkumar Patel | 3c50c82 | 2024-01-30 07:14:40 -0600 | [diff] [blame] | 61 | }; |
| 62 | |
| 63 | } // namespace platform_config |
| 64 | |
| 65 | } // namespace responder |
| 66 | |
| 67 | } // namespace pldm |