blob: 7ae6af7a2eaf4becdfe10507e47236252b96e67a [file] [log] [blame]
John Wange2efdcc2020-02-12 17:02:06 +08001#include "bios_attribute.hpp"
2
Sampa Misra46ece062020-03-18 07:17:44 -05003#include "bios_config.hpp"
Deepak Kodihallid130e1a2020-06-17 05:55:32 -05004#include "common/utils.hpp"
John Wange2efdcc2020-02-12 17:02:06 +08005
John Wange2efdcc2020-02-12 17:02:06 +08006#include <variant>
7
Brad Bishop5079ac42021-08-19 18:35:06 -04008using namespace pldm::utils;
9
John Wange2efdcc2020-02-12 17:02:06 +080010namespace pldm
11{
12namespace responder
13{
14namespace bios
15{
16
17BIOSAttribute::BIOSAttribute(const Json& entry,
18 DBusHandler* const dbusHandler) :
19 name(entry.at("attribute_name")),
Archana Kakanid6608092024-05-23 01:14:56 -050020 readOnly(false), displayName(entry.at("display_name")),
21 helpText(entry.at("help_text")), dbusHandler(dbusHandler)
John Wange2efdcc2020-02-12 17:02:06 +080022{
George Liudaa69232020-09-02 17:22:09 +080023 try
24 {
Archana Kakanid6608092024-05-23 01:14:56 -050025 readOnly = entry.at("read_only");
George Liudaa69232020-09-02 17:22:09 +080026 }
Kamalkumar Patel58cbcaf2023-10-06 03:48:25 -050027 catch (const std::exception&)
George Liudaa69232020-09-02 17:22:09 +080028 {
29 // No action required, readOnly is initialised to false
30 }
31
George Liu5bb9edb2021-08-05 20:10:32 +080032 try
John Wange2efdcc2020-02-12 17:02:06 +080033 {
George Liu5bb9edb2021-08-05 20:10:32 +080034 std::string objectPath = entry.at("dbus").at("object_path");
35 std::string interface = entry.at("dbus").at("interface");
36 std::string propertyName = entry.at("dbus").at("property_name");
37 std::string propertyType = entry.at("dbus").at("property_type");
John Wange2efdcc2020-02-12 17:02:06 +080038
George Liu5bb9edb2021-08-05 20:10:32 +080039 dBusMap = {objectPath, interface, propertyName, propertyType};
40 }
Kamalkumar Patel58cbcaf2023-10-06 03:48:25 -050041 catch (const std::exception&)
George Liu5bb9edb2021-08-05 20:10:32 +080042 {
Manojkiran Eda2576aec2024-06-17 12:05:17 +053043 // No action required, dBusMap will have no value
John Wange2efdcc2020-02-12 17:02:06 +080044 }
45}
46
Sampa Misra46ece062020-03-18 07:17:44 -050047std::optional<DBusMapping> BIOSAttribute::getDBusMap()
48{
49 return dBusMap;
50}
51
John Wange2efdcc2020-02-12 17:02:06 +080052} // namespace bios
53} // namespace responder
54} // namespace pldm