#pragma once #include "bios_attribute.hpp" #include #include #include #include class TestBIOSEnumAttribute; namespace pldm { namespace responder { namespace bios { /** @class BIOSEnumAttribute * @brief Associate enum entry(attr table and attribute value table) and * dbus attribute */ class BIOSEnumAttribute : public BIOSAttribute { public: friend class ::TestBIOSEnumAttribute; /** @brief Construct a bios enum attribute * @param[in] entry - Json Object * @param[in] dbusHandler - Dbus Handler */ BIOSEnumAttribute(const Json& entry, pldm::utils::DBusHandler* const dbusHandler); /** @brief Set Attribute value On Dbus according to the attribute value * entry * @param[in] attrValueEntry - The attribute value entry * @param[in] attrEntry - The attribute entry corresponding to the * attribute value entry * @param[in] stringTable - The string table */ void setAttrValueOnDbus(const pldm_bios_attr_val_table_entry* attrValueEntry, const pldm_bios_attr_table_entry* attrEntry, const BIOSStringTable& stringTable) override; /** @brief Construct corresponding entries at the end of the attribute table * and attribute value tables * @param[in] stringTable - The string Table * @param[in,out] attrTable - The attribute table * @param[in,out] attrValueTable - The attribute value table * @param[in,out] optAttributeValue - init value of the attribute */ void constructEntry(const BIOSStringTable& stringTable, Table& attrTable, Table& attrValueTable, std::optional> optAttributeValue = std::nullopt) override; /** @brief Generate attribute entry by the spec DSP0247_1.0.0 Table 14 * @param[in] attributevalue - attribute value(Enumeration, String and * Integer) * @param[in,out] attrValueEntry - attribute entry */ void generateAttributeEntry( const std::variant& attributevalue, Table& attrValueEntry) override; int updateAttrVal(Table& newValue, uint16_t attrHdl, uint8_t attrType, const pldm::utils::PropertyValue& newPropVal) override; private: std::vector possibleValues; std::vector valueDisplayNames; std::string defaultValue; /** @brief Get index of the given value in possible values * @param[in] value - The given value * @param[in] pVs - The possible values * @return Index of the given value in possible values */ uint8_t getValueIndex(const std::string& value, const std::vector& pVs); /** @brief Get handles of possible values * @param[in] stringTable - The bios string table * @param[in] pVs - The possible values * @return The handles */ std::vector getPossibleValuesHandle(const BIOSStringTable& stringTable, const std::vector& pVs); /** @brief Method to populate the valueDisplayNamesMap * @param[in] attrHandle - attribute handle */ void populateValueDisplayNamesMap(uint16_t attrHandle); using ValMap = std::map; /** @brief Map of value on dbus and pldm */ ValMap valMap; /** @brief Build the map of dbus value to pldm enum value * @param[in] dbusVals - The dbus values in the json's dbus section */ void buildValMap(const Json& dbusVals); /** @brief Get index of the current value in possible values * @return The index of the current value in possible values */ uint8_t getAttrValueIndex(); /** @brief Get index of the property value in possible values * @param[in] propValue - property values * * @return The index of the property value in possible values */ uint8_t getAttrValueIndex(const pldm::utils::PropertyValue& propValue); }; } // namespace bios } // namespace responder } // namespace pldm