blob: 3ca214db0d01375a3256eefd6ab328a1f3a7dc6e [file] [log] [blame]
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +00001#pragma once
2
3#include <nlohmann/json.hpp>
4
5#include <set>
6#include <unordered_map>
7
8using Association = std::tuple<std::string, std::string, std::string>;
9
10class Topology
11{
12 public:
13 explicit Topology() = default;
14
15 void addBoard(const std::string& path, const std::string& boardType,
Matt Spinler6eb60972023-08-14 16:36:20 -050016 const std::string& boardName,
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +000017 const nlohmann::json& exposesItem);
Alexander Hansen0519f572025-08-19 18:11:04 +020018 std::unordered_map<std::string, std::set<Association>> getAssocs(
Patrick Williams5a807032025-03-03 11:20:39 -050019 const std::map<std::string, std::string>& boards);
Matt Spinler6eb60972023-08-14 16:36:20 -050020 void remove(const std::string& boardName);
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +000021
22 private:
23 using Path = std::string;
24 using BoardType = std::string;
Matt Spinler6eb60972023-08-14 16:36:20 -050025 using BoardName = std::string;
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +000026 using PortType = std::string;
27
Alexander Hansenec938ad2025-08-19 16:48:44 +020028 void addDownstreamPort(const Path& path, const nlohmann::json& exposesItem);
29
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +000030 std::unordered_map<PortType, std::vector<Path>> upstreamPorts;
31 std::unordered_map<PortType, std::vector<Path>> downstreamPorts;
Jeff Linb02752f2023-12-01 11:23:54 +080032 std::set<Path> powerPaths;
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +000033 std::unordered_map<Path, BoardType> boardTypes;
Matt Spinler6eb60972023-08-14 16:36:20 -050034 std::unordered_map<BoardName, Path> boardNames;
Benjamin Fairf2f5b7a2022-09-09 19:45:02 +000035};