topology: add initial module
To use this module, add information about boards and their exposes
records and then request a map of what resulting associations should be
exposed on D-Bus.
Tested: Unit tests pass
Signed-off-by: Benjamin Fair <benjaminfair@google.com>
Change-Id: I42cd79407ab476599f5010c11cc146a569694b24
diff --git a/include/topology.hpp b/include/topology.hpp
new file mode 100644
index 0000000..18c9244
--- /dev/null
+++ b/include/topology.hpp
@@ -0,0 +1,27 @@
+#pragma once
+
+#include <nlohmann/json.hpp>
+
+#include <set>
+#include <unordered_map>
+
+using Association = std::tuple<std::string, std::string, std::string>;
+
+class Topology
+{
+ public:
+ explicit Topology() = default;
+
+ void addBoard(const std::string& path, const std::string& boardType,
+ const nlohmann::json& exposesItem);
+ std::unordered_map<std::string, std::vector<Association>> getAssocs();
+
+ private:
+ using Path = std::string;
+ using BoardType = std::string;
+ using PortType = std::string;
+
+ std::unordered_map<PortType, std::vector<Path>> upstreamPorts;
+ std::unordered_map<PortType, std::vector<Path>> downstreamPorts;
+ std::unordered_map<Path, BoardType> boardTypes;
+};