1 #include "bios_attribute.hpp"
2 
3 #include "bios_config.hpp"
4 #include "common/utils.hpp"
5 
6 #include <variant>
7 
8 using namespace pldm::utils;
9 
10 namespace pldm
11 {
12 namespace responder
13 {
14 namespace bios
15 {
16 
BIOSAttribute(const Json & entry,DBusHandler * const dbusHandler)17 BIOSAttribute::BIOSAttribute(const Json& entry,
18                              DBusHandler* const dbusHandler) :
19     name(entry.at("attribute_name")), readOnly(false),
20     displayName(entry.at("display_name")), helpText(entry.at("help_text")),
21     dbusHandler(dbusHandler)
22 {
23     try
24     {
25         readOnly = entry.at("read_only");
26     }
27     catch (const std::exception&)
28     {
29         // No action required, readOnly is initialised to false
30     }
31 
32     try
33     {
34         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");
38 
39         dBusMap = {objectPath, interface, propertyName, propertyType};
40     }
41     catch (const std::exception&)
42     {
43         // No action required, dBusMap will have no value
44     }
45 }
46 
getDBusMap()47 std::optional<DBusMapping> BIOSAttribute::getDBusMap()
48 {
49     return dBusMap;
50 }
51 
52 } // namespace bios
53 } // namespace responder
54 } // namespace pldm
55