diff options
Diffstat (limited to 'entity_map_json.hpp')
-rw-r--r-- | entity_map_json.hpp | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/entity_map_json.hpp b/entity_map_json.hpp new file mode 100644 index 0000000..3ab4ff2 --- /dev/null +++ b/entity_map_json.hpp @@ -0,0 +1,57 @@ +#pragma once + +#include <ipmid/types.hpp> +#include <memory> +#include <nlohmann/json.hpp> + +namespace ipmi +{ +namespace sensor +{ + +/** + * @brief Grab a handle to the entity map. + */ +const EntityInfoMap& getIpmiEntityRecords(); + +/** + * @brief Open the default entity map json file, and if present and valid json, + * return a built entity map. + * + * @return the map + */ +EntityInfoMap buildEntityMapFromFile(); + +/** + * @brief Given json data validate the data matches the expected format for the + * entity map configuration and parse the data into a map of the entities. + * + * If any entry is invalid, the entire contents passed in is disregarded as + * possibly corrupt. + * + * @param[in] data - the json data + * @return the map + */ +EntityInfoMap buildJsonEntityMap(const nlohmann::json& data); + +/** + * @brief Owner of the EntityInfoMap. + */ +class EntityInfoMapContainer +{ + public: + /** Get ahold of the owner. */ + static EntityInfoMapContainer* getContainer(); + /** Get ahold of the records. */ + const EntityInfoMap& getIpmiEntityRecords(); + + private: + EntityInfoMapContainer(const EntityInfoMap& entityRecords) : + entityRecords(entityRecords) + { + } + EntityInfoMap entityRecords; +}; + +} // namespace sensor +} // namespace ipmi |