blob: c519cb78fec276230be5a4ef0398abb73a7bdfec [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 Liudaa69232020-09-02 17:22:09 +080021 readOnly(false), dbusHandler(dbusHandler)
John Wange2efdcc2020-02-12 17:02:06 +080022{
George Liudaa69232020-09-02 17:22:09 +080023 try
24 {
25 readOnly = entry.at("readOnly");
26 }
27 catch (const std::exception& e)
28 {
29 // No action required, readOnly is initialised to false
30 }
31
John Wange2efdcc2020-02-12 17:02:06 +080032 if (!readOnly)
33 {
George Liudaa69232020-09-02 17:22:09 +080034 try
35 {
36 std::string objectPath = entry.at("dbus").at("object_path");
37 std::string interface = entry.at("dbus").at("interface");
38 std::string propertyName = entry.at("dbus").at("property_name");
39 std::string propertyType = entry.at("dbus").at("property_type");
John Wange2efdcc2020-02-12 17:02:06 +080040
George Liudaa69232020-09-02 17:22:09 +080041 dBusMap = {objectPath, interface, propertyName, propertyType};
42 }
43 catch (const std::exception& e)
44 {
45 // No action required, dBusMap whill have no value
46 }
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