blob: d090a2830092e7fae31f2562aaba674d953302a2 [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
11namespace 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
John Wange2efdcc2020-02-12 17:02:06 +080033 if (!readOnly)
34 {
George Liudaa69232020-09-02 17:22:09 +080035 try
36 {
37 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 Liudaa69232020-09-02 17:22:09 +080042 dBusMap = {objectPath, interface, propertyName, propertyType};
43 }
44 catch (const std::exception& e)
45 {
46 // No action required, dBusMap whill have no value
47 }
John Wange2efdcc2020-02-12 17:02:06 +080048 }
49}
50
Sampa Misra46ece062020-03-18 07:17:44 -050051std::optional<DBusMapping> BIOSAttribute::getDBusMap()
52{
53 return dBusMap;
54}
55
John Wange2efdcc2020-02-12 17:02:06 +080056} // namespace bios
57} // namespace responder
58} // namespace pldm