xref: /openbmc/entity-manager/src/topology.hpp (revision b02752f7)
1 #pragma once
2 
3 #include <nlohmann/json.hpp>
4 
5 #include <set>
6 #include <unordered_map>
7 
8 using Association = std::tuple<std::string, std::string, std::string>;
9 
10 class Topology
11 {
12   public:
13     explicit Topology() = default;
14 
15     void addBoard(const std::string& path, const std::string& boardType,
16                   const std::string& boardName,
17                   const nlohmann::json& exposesItem);
18     std::unordered_map<std::string, std::vector<Association>>
19         getAssocs(const std::map<std::string, std::string>& boards);
20     void remove(const std::string& boardName);
21 
22   private:
23     using Path = std::string;
24     using BoardType = std::string;
25     using BoardName = std::string;
26     using PortType = std::string;
27 
28     std::unordered_map<PortType, std::vector<Path>> upstreamPorts;
29     std::unordered_map<PortType, std::vector<Path>> downstreamPorts;
30     std::set<Path> powerPaths;
31     std::unordered_map<Path, BoardType> boardTypes;
32     std::unordered_map<BoardName, Path> boardNames;
33 };
34