John Wang | 95e6b3c | 2020-02-13 09:43:24 +0800 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include "bios_attribute.hpp" |
| 4 | |
| 5 | class TestBIOSIntegerAttribute; |
| 6 | |
| 7 | namespace pldm |
| 8 | { |
| 9 | namespace responder |
| 10 | { |
| 11 | namespace bios |
| 12 | { |
| 13 | |
| 14 | /** @class BIOSIntegerAttribute |
| 15 | * @brief Associate integer entry(attr table and attribute value table) and |
| 16 | * dbus attribute |
| 17 | */ |
| 18 | class 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 | */ |
Brad Bishop | 5079ac4 | 2021-08-19 18:35:06 -0400 | [diff] [blame] | 27 | BIOSIntegerAttribute(const Json& entry, |
| 28 | pldm::utils::DBusHandler* const dbusHandler); |
John Wang | 95e6b3c | 2020-02-13 09:43:24 +0800 | [diff] [blame] | 29 | |
| 30 | /** @brief Set Attribute value On Dbus according to the attribute value |
| 31 | * entry |
| 32 | * @param[in] attrValueEntry - The attribute value entry |
| 33 | * @param[in] attrEntry - The attribute entry corresponding to the |
| 34 | * attribute value entry |
| 35 | * @param[in] stringTable - The string table |
| 36 | */ |
| 37 | void |
| 38 | setAttrValueOnDbus(const pldm_bios_attr_val_table_entry* attrValueEntry, |
| 39 | const pldm_bios_attr_table_entry* attrEntry, |
| 40 | const BIOSStringTable& stringTable) override; |
| 41 | |
| 42 | /** @brief Construct corresponding entries at the end of the attribute table |
| 43 | * and attribute value tables |
| 44 | * @param[in] stringTable - The string Table |
| 45 | * @param[in,out] attrTable - The attribute table |
| 46 | * @param[in,out] attrValueTable - The attribute value table |
Tom Joseph | ca7b252 | 2020-11-18 12:27:11 +0530 | [diff] [blame] | 47 | * @param[in,out] optAttributeValue - init value of the attribute |
John Wang | 95e6b3c | 2020-02-13 09:43:24 +0800 | [diff] [blame] | 48 | */ |
| 49 | void constructEntry(const BIOSStringTable& stringTable, Table& attrTable, |
Tom Joseph | ca7b252 | 2020-11-18 12:27:11 +0530 | [diff] [blame] | 50 | Table& attrValueTable, |
| 51 | std::optional<std::variant<int64_t, std::string>> |
| 52 | optAttributeValue = std::nullopt) override; |
John Wang | 95e6b3c | 2020-02-13 09:43:24 +0800 | [diff] [blame] | 53 | |
George Liu | 1244acf | 2020-08-14 09:11:11 +0800 | [diff] [blame] | 54 | /** @brief Generate attribute entry by the spec DSP0247_1.0.0 Table 14 |
| 55 | * @param[in] attributevalue - attribute value(Enumeration, String and |
| 56 | * Integer) |
| 57 | * @param[in,out] attrValueEntry - attribute entry |
| 58 | */ |
| 59 | void generateAttributeEntry( |
| 60 | const std::variant<int64_t, std::string>& attributevalue, |
| 61 | Table& attrValueEntry) override; |
| 62 | |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 63 | int updateAttrVal(Table& newValue, uint16_t attrHdl, uint8_t attrType, |
Pavithra Barithaya | 165749d | 2023-07-10 01:05:26 -0500 | [diff] [blame] | 64 | const pldm::utils::PropertyValue& newPropVal) override; |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 65 | |
John Wang | 95e6b3c | 2020-02-13 09:43:24 +0800 | [diff] [blame] | 66 | private: |
| 67 | /** @brief Integer field from json */ |
| 68 | table::attribute::IntegerField integerInfo; |
| 69 | |
| 70 | /** @brief Get pldm value from dbus propertyValue */ |
Brad Bishop | 5079ac4 | 2021-08-19 18:35:06 -0400 | [diff] [blame] | 71 | uint64_t getAttrValue(const pldm::utils::PropertyValue& value); |
John Wang | 95e6b3c | 2020-02-13 09:43:24 +0800 | [diff] [blame] | 72 | |
| 73 | /** @brief Get value on dbus */ |
| 74 | uint64_t getAttrValue(); |
| 75 | }; |
| 76 | |
| 77 | } // namespace bios |
| 78 | } // namespace responder |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 79 | } // namespace pldm |