blob: aa6ff9f5198b1356096a35ff98a2a010fd4de8bb [file] [log] [blame]
Sampa Misra46ece062020-03-18 07:17:44 -05001#include "config.h"
2
John Wange2efdcc2020-02-12 17:02:06 +08003#include "bios_attribute.hpp"
4
Sampa Misra46ece062020-03-18 07:17:44 -05005#include "bios_config.hpp"
Deepak Kodihallid130e1a2020-06-17 05:55:32 -05006#include "common/utils.hpp"
John Wange2efdcc2020-02-12 17:02:06 +08007
8#include <iostream>
9#include <variant>
10
Brad Bishop5079ac42021-08-19 18:35:06 -040011using namespace pldm::utils;
12
John Wange2efdcc2020-02-12 17:02:06 +080013namespace pldm
14{
15namespace responder
16{
17namespace bios
18{
19
20BIOSAttribute::BIOSAttribute(const Json& entry,
21 DBusHandler* const dbusHandler) :
22 name(entry.at("attribute_name")),
George Liu92bb4022020-09-03 14:58:24 +080023 readOnly(false), displayName(entry.at("displayName")),
24 helpText(entry.at("helpText")), dbusHandler(dbusHandler)
John Wange2efdcc2020-02-12 17:02:06 +080025{
George Liudaa69232020-09-02 17:22:09 +080026 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
George Liu5bb9edb2021-08-05 20:10:32 +080035 try
John Wange2efdcc2020-02-12 17:02:06 +080036 {
George Liu5bb9edb2021-08-05 20:10:32 +080037 std::string objectPath = entry.at("dbus").at("object_path");
38 std::string interface = entry.at("dbus").at("interface");
39 std::string propertyName = entry.at("dbus").at("property_name");
40 std::string propertyType = entry.at("dbus").at("property_type");
John Wange2efdcc2020-02-12 17:02:06 +080041
George Liu5bb9edb2021-08-05 20:10:32 +080042 dBusMap = {objectPath, interface, propertyName, propertyType};
43 }
44 catch (const std::exception& e)
45 {
46 // No action required, dBusMap whill have no value
John Wange2efdcc2020-02-12 17:02:06 +080047 }
48}
49
Sampa Misra46ece062020-03-18 07:17:44 -050050std::optional<DBusMapping> BIOSAttribute::getDBusMap()
51{
52 return dBusMap;
53}
54
John Wange2efdcc2020-02-12 17:02:06 +080055} // namespace bios
56} // namespace responder
57} // namespace pldm