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