blob: 3ab4ff24dda1ea67fa59f5716657935e9aa0a25d [file] [log] [blame]
Patrick Venture02e32372019-08-16 10:50:18 -07001#pragma once
2
3#include <ipmid/types.hpp>
Patrick Venture87fd2cd2019-08-19 12:07:18 -07004#include <memory>
Patrick Venture02e32372019-08-16 10:50:18 -07005#include <nlohmann/json.hpp>
6
7namespace ipmi
8{
9namespace sensor
10{
11
12/**
Patrick Venture99bf1c42019-08-23 09:02:13 -070013 * @brief Grab a handle to the entity map.
14 */
15const EntityInfoMap& getIpmiEntityRecords();
16
17/**
Patrick Venturec2b7fc12019-08-19 11:53:22 -070018 * @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 */
23EntityInfoMap buildEntityMapFromFile();
24
25/**
Patrick Venture02e32372019-08-16 10:50:18 -070026 * @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 */
35EntityInfoMap buildJsonEntityMap(const nlohmann::json& data);
36
Patrick Venture87fd2cd2019-08-19 12:07:18 -070037/**
38 * @brief Owner of the EntityInfoMap.
39 */
40class 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 Venture02e32372019-08-16 10:50:18 -070056} // namespace sensor
57} // namespace ipmi