Add ability to get source aos::Node* from a Channel*
This makes it a lot easier to index by Node given a channel. And this
should be shared code anyways, not in an application.
Change-Id: Ia176e58f91a58a718b3eca8edd7ceb3bd36e441d
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/configuration.cc b/aos/configuration.cc
index 4de5332..3b50ab4 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -1636,6 +1636,13 @@
return nullptr;
}
+const Node *SourceNode(const Configuration *config, const Channel *channel) {
+ if (!MultiNode(config)) {
+ return nullptr;
+ }
+ return GetNode(config, channel->source_node()->string_view());
+}
+
std::vector<size_t> SourceNodeIndex(const Configuration *config) {
CHECK(config->has_channels());
std::vector<size_t> result;