John Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 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 | |
Sampa Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 63 | /** @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 Wang | e2efdcc | 2020-02-12 17:02:06 +0800 | [diff] [blame] | 78 | /** @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 Misra | 46ece06 | 2020-03-18 07:17:44 -0500 | [diff] [blame] | 94 | } // namespace pldm |