1 #pragma once 2 3 #include <ipmid/types.hpp> 4 #include <nlohmann/json.hpp> 5 6 #include <memory> 7 8 namespace ipmi 9 { 10 namespace sensor 11 { 12 13 /** 14 * @brief Grab a handle to the entity map. 15 */ 16 const EntityInfoMap& getIpmiEntityRecords(); 17 18 /** 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 /** 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 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) 52 {} 53 EntityInfoMap entityRecords; 54 }; 55 56 } // namespace sensor 57 } // namespace ipmi 58