blob: bc646cae5f86099b42bad3bd8700d3f5c194f6e1 [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
John Wange2efdcc2020-02-12 17:02:06 +080035 if (!readOnly)
36 {
George Liudaa69232020-09-02 17:22:09 +080037 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");
John Wange2efdcc2020-02-12 17:02:06 +080043
George Liudaa69232020-09-02 17:22:09 +080044 dBusMap = {objectPath, interface, propertyName, propertyType};
45 }
46 catch (const std::exception& e)
47 {
48 // No action required, dBusMap whill have no value
49 }
John Wange2efdcc2020-02-12 17:02:06 +080050 }
51}
52
Sampa Misra46ece062020-03-18 07:17:44 -050053std::optional<DBusMapping> BIOSAttribute::getDBusMap()
54{
55 return dBusMap;
56}
57
John Wange2efdcc2020-02-12 17:02:06 +080058} // namespace bios
59} // namespace responder
60} // namespace pldm