Patrick Venture | 02e3237 | 2019-08-16 10:50:18 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <ipmid/types.hpp> |
| 4 | #include <nlohmann/json.hpp> |
| 5 | |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 6 | #include <memory> |
| 7 | |
Patrick Venture | 02e3237 | 2019-08-16 10:50:18 -0700 | [diff] [blame] | 8 | namespace ipmi |
| 9 | { |
| 10 | namespace sensor |
| 11 | { |
| 12 | |
| 13 | /** |
Patrick Venture | 99bf1c4 | 2019-08-23 09:02:13 -0700 | [diff] [blame] | 14 | * @brief Grab a handle to the entity map. |
| 15 | */ |
| 16 | const EntityInfoMap& getIpmiEntityRecords(); |
| 17 | |
| 18 | /** |
Patrick Venture | c2b7fc1 | 2019-08-19 11:53:22 -0700 | [diff] [blame] | 19 | * @brief Open the default entity map json file, and if present and valid json, |
| 20 | * return a built entity map. |
| 21 | * |
| 22 | * @return the map |
| 23 | */ |
| 24 | EntityInfoMap buildEntityMapFromFile(); |
| 25 | |
| 26 | /** |
Patrick Venture | 02e3237 | 2019-08-16 10:50:18 -0700 | [diff] [blame] | 27 | * @brief Given json data validate the data matches the expected format for the |
| 28 | * entity map configuration and parse the data into a map of the entities. |
| 29 | * |
| 30 | * If any entry is invalid, the entire contents passed in is disregarded as |
| 31 | * possibly corrupt. |
| 32 | * |
| 33 | * @param[in] data - the json data |
| 34 | * @return the map |
| 35 | */ |
| 36 | EntityInfoMap buildJsonEntityMap(const nlohmann::json& data); |
| 37 | |
Patrick Venture | 87fd2cd | 2019-08-19 12:07:18 -0700 | [diff] [blame] | 38 | /** |
| 39 | * @brief Owner of the EntityInfoMap. |
| 40 | */ |
| 41 | class EntityInfoMapContainer |
| 42 | { |
| 43 | public: |
| 44 | /** Get ahold of the owner. */ |
| 45 | static EntityInfoMapContainer* getContainer(); |
| 46 | /** Get ahold of the records. */ |
| 47 | const EntityInfoMap& getIpmiEntityRecords(); |
| 48 | |
| 49 | private: |
| 50 | EntityInfoMapContainer(const EntityInfoMap& entityRecords) : |
| 51 | entityRecords(entityRecords) |
Patrick Williams | fbc6c9d | 2023-05-10 07:50:16 -0500 | [diff] [blame] | 52 | {} |
Patrick Venture | 87fd2cd | 2019-08-19 12:07:18 -0700 | [diff] [blame] | 53 | EntityInfoMap entityRecords; |
| 54 | }; |
| 55 | |
Patrick Venture | 02e3237 | 2019-08-16 10:50:18 -0700 | [diff] [blame] | 56 | } // namespace sensor |
| 57 | } // namespace ipmi |