blob: 033c18f939daa1f17dd727b2222b3d244747769b [file] [log] [blame]
John Wang95e6b3c2020-02-13 09:43:24 +08001#pragma once
2
3#include "bios_attribute.hpp"
4
5class TestBIOSIntegerAttribute;
6
7namespace pldm
8{
9namespace responder
10{
11namespace bios
12{
13
14/** @class BIOSIntegerAttribute
15 * @brief Associate integer entry(attr table and attribute value table) and
16 * dbus attribute
17 */
18class BIOSIntegerAttribute : public BIOSAttribute
19{
20 public:
21 friend class ::TestBIOSIntegerAttribute;
22
23 /** @brief Construct a bios integer attribute
24 * @param[in] entry - Json Object
25 * @param[in] dbusHandler - Dbus Handler
26 */
27 BIOSIntegerAttribute(const Json& entry, DBusHandler* const dbusHandler);
28
29 /** @brief Set Attribute value On Dbus according to the attribute value
30 * entry
31 * @param[in] attrValueEntry - The attribute value entry
32 * @param[in] attrEntry - The attribute entry corresponding to the
33 * attribute value entry
34 * @param[in] stringTable - The string table
35 */
36 void
37 setAttrValueOnDbus(const pldm_bios_attr_val_table_entry* attrValueEntry,
38 const pldm_bios_attr_table_entry* attrEntry,
39 const BIOSStringTable& stringTable) override;
40
41 /** @brief Construct corresponding entries at the end of the attribute table
42 * and attribute value tables
43 * @param[in] stringTable - The string Table
44 * @param[in,out] attrTable - The attribute table
45 * @param[in,out] attrValueTable - The attribute value table
Tom Josephca7b2522020-11-18 12:27:11 +053046 * @param[in,out] optAttributeValue - init value of the attribute
John Wang95e6b3c2020-02-13 09:43:24 +080047 */
48 void constructEntry(const BIOSStringTable& stringTable, Table& attrTable,
Tom Josephca7b2522020-11-18 12:27:11 +053049 Table& attrValueTable,
50 std::optional<std::variant<int64_t, std::string>>
51 optAttributeValue = std::nullopt) override;
John Wang95e6b3c2020-02-13 09:43:24 +080052
George Liu1244acf2020-08-14 09:11:11 +080053 /** @brief Generate attribute entry by the spec DSP0247_1.0.0 Table 14
54 * @param[in] attributevalue - attribute value(Enumeration, String and
55 * Integer)
56 * @param[in,out] attrValueEntry - attribute entry
57 */
58 void generateAttributeEntry(
59 const std::variant<int64_t, std::string>& attributevalue,
60 Table& attrValueEntry) override;
61
Sampa Misra46ece062020-03-18 07:17:44 -050062 int updateAttrVal(Table& newValue, uint16_t attrHdl, uint8_t attrType,
63 const PropertyValue& newPropVal);
64
John Wang95e6b3c2020-02-13 09:43:24 +080065 private:
66 /** @brief Integer field from json */
67 table::attribute::IntegerField integerInfo;
68
69 /** @brief Get pldm value from dbus propertyValue */
Sampa Misra46ece062020-03-18 07:17:44 -050070 uint64_t getAttrValue(const PropertyValue& value);
John Wang95e6b3c2020-02-13 09:43:24 +080071
72 /** @brief Get value on dbus */
73 uint64_t getAttrValue();
74};
75
76} // namespace bios
77} // namespace responder
Sampa Misra46ece062020-03-18 07:17:44 -050078} // namespace pldm