blob: 3f3ab4df52e5f95d59a9d053eeb1cf3b36173576 [file] [log] [blame]
John Wange2efdcc2020-02-12 17:02:06 +08001#pragma once
2
3#include "bios_table.hpp"
4#include "utils.hpp"
5
6#include <cstdint>
7#include <filesystem>
8#include <memory>
9#include <nlohmann/json.hpp>
10#include <optional>
11#include <string>
12#include <vector>
13
14#include "bios_table.h"
15
16namespace pldm
17{
18namespace responder
19{
20namespace bios
21{
22
23using Json = nlohmann::json;
24using namespace pldm::utils;
25
26/** @class BIOSAttribute
27 * @brief Provide interfaces to implement specific types of attributes
28 */
29class BIOSAttribute
30{
31 public:
32 /** @brief Construct a bios attribute
33 * @param[in] entry - Json Object
34 * @param[in] dbusHandler - Dbus Handler
35 */
36 BIOSAttribute(const Json& entry, DBusHandler* const dbusHandler);
37
38 /** Virtual destructor
39 */
40 virtual ~BIOSAttribute() = default;
41
42 /** @brief Set Attribute value On Dbus according to the attribute value
43 * entry
44 * @param[in] attrValueEntry - The attribute value entry
45 * @param[in] attrEntry - The attribute entry corresponding to the
46 * attribute value entry
47 * @param[in] stringTable - The string table
48 */
49 virtual void
50 setAttrValueOnDbus(const pldm_bios_attr_val_table_entry* attrValueEntry,
51 const pldm_bios_attr_table_entry* attrEntry,
52 const BIOSStringTable& stringTable) = 0;
53
54 /** @brief Construct corresponding entries at the end of the attribute table
55 * and attribute value tables
56 * @param[in] stringTable - The string Table
57 * @param[in,out] attrTable - The attribute table
58 * @param[in,out] attrValueTable - The attribute value table
59 */
60 virtual void constructEntry(const BIOSStringTable& stringTable,
61 Table& attrTable, Table& attrValueTable) = 0;
62
Sampa Misra46ece062020-03-18 07:17:44 -050063 /** @brief Method to update the value for an attribute
64 * @param[in,out] newValue - An attribute value table row with the new
65 * value for the attribute
66 * @param[in] attrHdl - attribute handle
67 * @param[in] attrType - attribute type
68 * @param[in] newPropVal - The new value
69 * @return PLDM Success or failure status
70 */
71 virtual int updateAttrVal(Table& newValue, uint16_t attrHdl,
72 uint8_t attrType,
73 const PropertyValue& newPropVal) = 0;
74
75 /** @brief Method to return the D-Bus map */
76 std::optional<DBusMapping> getDBusMap();
77
John Wange2efdcc2020-02-12 17:02:06 +080078 /** @brief Name of this attribute */
79 const std::string name;
80
81 /** Weather this attribute is read-only */
82 const bool readOnly;
83
84 protected:
85 /** @brief dbus backend, nullopt if this attribute is read-only*/
86 std::optional<DBusMapping> dBusMap;
87
88 /** @brief dbus handler */
89 DBusHandler* const dbusHandler;
90};
91
92} // namespace bios
93} // namespace responder
Sampa Misra46ece062020-03-18 07:17:44 -050094} // namespace pldm