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