blob: bfc8e72957b144660aa428993b3e2bae17c349be [file] [log] [blame]
Patrick Venture02e32372019-08-16 10:50:18 -07001#pragma once
2
3#include <ipmid/types.hpp>
4#include <nlohmann/json.hpp>
5
Patrick Williamsfbc6c9d2023-05-10 07:50:16 -05006#include <memory>
7
Patrick Venture02e32372019-08-16 10:50:18 -07008namespace ipmi
9{
10namespace sensor
11{
12
13/**
Patrick Venture99bf1c42019-08-23 09:02:13 -070014 * @brief Grab a handle to the entity map.
15 */
16const EntityInfoMap& getIpmiEntityRecords();
17
18/**
Patrick Venturec2b7fc12019-08-19 11:53:22 -070019 * @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 */
24EntityInfoMap buildEntityMapFromFile();
25
26/**
Patrick Venture02e32372019-08-16 10:50:18 -070027 * @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 */
36EntityInfoMap buildJsonEntityMap(const nlohmann::json& data);
37
Patrick Venture87fd2cd2019-08-19 12:07:18 -070038/**
39 * @brief Owner of the EntityInfoMap.
40 */
41class 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 Williamsfbc6c9d2023-05-10 07:50:16 -050052 {}
Patrick Venture87fd2cd2019-08-19 12:07:18 -070053 EntityInfoMap entityRecords;
54};
55
Patrick Venture02e32372019-08-16 10:50:18 -070056} // namespace sensor
57} // namespace ipmi