-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathentity_map_json.hpp
57 lines (48 loc) · 1.22 KB
/
entity_map_json.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once
#include <ipmid/types.hpp>
#include <nlohmann/json.hpp>
#include <memory>
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