blob: d839c0e739c5721dc72e132b58a52cf83bd8f421 [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")),
George Liu92bb4022020-09-03 14:58:24 +080020 readOnly(false), displayName(entry.at("displayName")),
21 helpText(entry.at("helpText")), dbusHandler(dbusHandler)
John Wange2efdcc2020-02-12 17:02:06 +080022{
George Liudaa69232020-09-02 17:22:09 +080023 try
24 {
25 readOnly = entry.at("readOnly");
26 }
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 {
43 // No action required, dBusMap whill 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