1 #include "config.h"
2 
3 #include "bios_attribute.hpp"
4 
5 #include "bios_config.hpp"
6 #include "common/utils.hpp"
7 
8 #include <iostream>
9 #include <variant>
10 
11 using namespace pldm::utils;
12 
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")),
23     readOnly(false), displayName(entry.at("displayName")),
24     helpText(entry.at("helpText")), dbusHandler(dbusHandler)
25 {
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 
35     if (!readOnly)
36     {
37         try
38         {
39             std::string objectPath = entry.at("dbus").at("object_path");
40             std::string interface = entry.at("dbus").at("interface");
41             std::string propertyName = entry.at("dbus").at("property_name");
42             std::string propertyType = entry.at("dbus").at("property_type");
43 
44             dBusMap = {objectPath, interface, propertyName, propertyType};
45         }
46         catch (const std::exception& e)
47         {
48             // No action required, dBusMap whill have no value
49         }
50     }
51 }
52 
53 std::optional<DBusMapping> BIOSAttribute::getDBusMap()
54 {
55     return dBusMap;
56 }
57 
58 } // namespace bios
59 } // namespace responder
60 } // namespace pldm
61