Split out ApplicationShouldStart in aos/configuration.h
This lets us iterate through all applications and see which ones are
relevant a lot easier with less code duplication.
Change-Id: I4c5318bce1565b698cf2cb4a3f28987e856f3764
Signed-off-by: Austin Schuh <austin.schuh@bluerivertech.com>
diff --git a/aos/configuration.cc b/aos/configuration.cc
index 97f4d4b..046f7c1 100644
--- a/aos/configuration.cc
+++ b/aos/configuration.cc
@@ -1364,6 +1364,23 @@
return result;
}
+bool ApplicationShouldStart(const Configuration *config, const Node *my_node,
+ const Application *application) {
+ if (MultiNode(config)) {
+ // Ok, we need
+ CHECK(application->has_nodes());
+ CHECK(my_node != nullptr);
+ for (const flatbuffers::String *str : *application->nodes()) {
+ if (str->string_view() == my_node->name()->string_view()) {
+ return true;
+ }
+ }
+ return false;
+ } else {
+ return true;
+ }
+}
+
const Application *GetApplication(const Configuration *config,
const Node *my_node,
std::string_view application_name) {
@@ -1373,16 +1390,7 @@
application_name, CompareApplications);
if (application_iterator != config->applications()->cend() &&
EqualsApplications(*application_iterator, application_name)) {
- if (MultiNode(config)) {
- // Ok, we need
- CHECK(application_iterator->has_nodes());
- CHECK(my_node != nullptr);
- for (const flatbuffers::String *str : *application_iterator->nodes()) {
- if (str->string_view() == my_node->name()->string_view()) {
- return *application_iterator;
- }
- }
- } else {
+ if (ApplicationShouldStart(config, my_node, *application_iterator)) {
return *application_iterator;
}
}