Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 1 | #include "config.h" |
| 2 | |
John Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 3 | #include "bios_attribute.hpp" |
| 4 | |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 5 | #include "bios_config.hpp" |
Deepak Kodihalli | d130e1a | 2020-06-17 05:55:32 -0500 | [diff] [blame] | 6 | #include "common/utils.hpp" |
John Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 7 | |
| 8 | #include <iostream> |
| 9 | #include <variant> |
| 10 | |
Brad Bishop | 5079ac4 | 2021-08-19 18:35:06 -0400 | [diff] [blame] | 11 | using namespace pldm::utils; |
| 12 | |
John Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 13 | namespace pldm |
| 14 | { |
| 15 | namespace responder |
| 16 | { |
| 17 | namespace bios |
| 18 | { |
| 19 | |
| 20 | BIOSAttribute::BIOSAttribute(const Json& entry, |
| 21 | DBusHandler* const dbusHandler) : |
| 22 | name(entry.at("attribute_name")), |
George Liu | 92bb402 | 2020-09-03 14:58:24 +0800 | [diff] [blame] | 23 | readOnly(false), displayName(entry.at("displayName")), |
| 24 | helpText(entry.at("helpText")), dbusHandler(dbusHandler) |
John Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 25 | { |
George Liu | daa6923 | 2020-09-02 17:22:09 +0800 | [diff] [blame] | 26 | try |
| 27 | { |
| 28 | readOnly = entry.at("readOnly"); |
| 29 | } |
| 30 | catch (const std::exception& e) |
| 31 | { |
| 32 | // No action required, readOnly is initialised to false |
| 33 | } |
| 34 | |
George Liu | 5bb9edb | 2021-08-05 20:10:32 +0800 | [diff] [blame] | 35 | try |
John Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 36 | { |
George Liu | 5bb9edb | 2021-08-05 20:10:32 +0800 | [diff] [blame] | 37 | std::string objectPath = entry.at("dbus").at("object_path"); |
| 38 | std::string interface = entry.at("dbus").at("interface"); |
| 39 | std::string propertyName = entry.at("dbus").at("property_name"); |
| 40 | std::string propertyType = entry.at("dbus").at("property_type"); |
John Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 41 | |
George Liu | 5bb9edb | 2021-08-05 20:10:32 +0800 | [diff] [blame] | 42 | dBusMap = {objectPath, interface, propertyName, propertyType}; |
| 43 | } |
| 44 | catch (const std::exception& e) |
| 45 | { |
| 46 | // No action required, dBusMap whill have no value |
John Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 47 | } |
| 48 | } |
| 49 | |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 50 | std::optional<DBusMapping> BIOSAttribute::getDBusMap() |
| 51 | { |
| 52 | return dBusMap; |
| 53 | } |
| 54 | |
John Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 55 | } // namespace bios |
| 56 | } // namespace responder |
| 57 | } // namespace pldm |