#pragma once #include #include #include using Association = std::tuple; using BoardPathsView = decltype(std::views::keys( std::declval&>())); class Topology { public: explicit Topology() = default; void addBoard(const std::string& path, const std::string& boardType, const std::string& boardName, const nlohmann::json& exposesItem); std::unordered_map> getAssocs( BoardPathsView boardPaths); void remove(const std::string& boardName); private: using Path = std::string; using BoardType = std::string; using BoardName = std::string; using PortType = std::string; void addDownstreamPort(const Path& path, const nlohmann::json& exposesItem); // e.g. contained_by, containing, powered_by, ... using AssocName = std::string; // @brief: fill associations map with the associations for a port identifier // such as 'MB Upstream Port' void fillAssocsForPortId( std::unordered_map>& result, BoardPathsView boardPaths, const std::set& upstreamPaths, const std::set& downstreamPaths); void fillAssocForPortId( std::unordered_map>& result, BoardPathsView boardPaths, const Path& upstream, const Path& downstream); static std::optional getOppositeAssoc( const AssocName& assocName); std::unordered_map> upstreamPorts; std::unordered_map> downstreamPorts; std::set powerPaths; std::unordered_map boardTypes; std::unordered_map boardNames; };