1 #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 16 namespace pldm 17 { 18 namespace responder 19 { 20 namespace bios 21 { 22 23 using Json = nlohmann::json; 24 using namespace pldm::utils; 25 26 /** @class BIOSAttribute 27 * @brief Provide interfaces to implement specific types of attributes 28 */ 29 class 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 63 /** @brief Name of this attribute */ 64 const std::string name; 65 66 /** Weather this attribute is read-only */ 67 const bool readOnly; 68 69 protected: 70 /** @brief dbus backend, nullopt if this attribute is read-only*/ 71 std::optional<DBusMapping> dBusMap; 72 73 /** @brief dbus handler */ 74 DBusHandler* const dbusHandler; 75 }; 76 77 } // namespace bios 78 } // namespace responder 79 } // namespace pldm