blob: 0923ab59dbc4d6690339ef7547189efa28bcaac7 [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
6#include <iostream>
7#include <variant>
8
Brad Bishop5079ac42021-08-19 18:35:06 -04009using namespace pldm::utils;
10
John Wange2efdcc2020-02-12 17:02:06 +080011namespace pldm
12{
13namespace responder
14{
15namespace bios
16{
17
18BIOSAttribute::BIOSAttribute(const Json& entry,
19 DBusHandler* const dbusHandler) :
20 name(entry.at("attribute_name")),
George Liu92bb4022020-09-03 14:58:24 +080021 readOnly(false), displayName(entry.at("displayName")),
22 helpText(entry.at("helpText")), dbusHandler(dbusHandler)
John Wange2efdcc2020-02-12 17:02:06 +080023{
George Liudaa69232020-09-02 17:22:09 +080024 try
25 {
26 readOnly = entry.at("readOnly");
27 }
28 catch (const std::exception& e)
29 {
30 // No action required, readOnly is initialised to false
31 }
32
George Liu5bb9edb2021-08-05 20:10:32 +080033 try
John Wange2efdcc2020-02-12 17:02:06 +080034 {
George Liu5bb9edb2021-08-05 20:10:32 +080035 std::string objectPath = entry.at("dbus").at("object_path");
36 std::string interface = entry.at("dbus").at("interface");
37 std::string propertyName = entry.at("dbus").at("property_name");
38 std::string propertyType = entry.at("dbus").at("property_type");
John Wange2efdcc2020-02-12 17:02:06 +080039
George Liu5bb9edb2021-08-05 20:10:32 +080040 dBusMap = {objectPath, interface, propertyName, propertyType};
41 }
42 catch (const std::exception& e)
43 {
44 // No action required, dBusMap whill have no value
John Wange2efdcc2020-02-12 17:02:06 +080045 }
46}
47
Sampa Misra46ece062020-03-18 07:17:44 -050048std::optional<DBusMapping> BIOSAttribute::getDBusMap()
49{
50 return dBusMap;
51}
52
John Wange2efdcc2020-02-12 17:02:06 +080053} // namespace bios
54} // namespace responder
55} // namespace pldm