Route commands without path to suitable component
Use the trait name to find the first component that implements
that trait to send the command to.
BUG: 25917421
Change-Id: Ife284100fb7d0bf94416bf5ba2ab9b797076ce23
Reviewed-on: https://weave-review.googlesource.com/1783
Reviewed-by: Vitaly Buka <vitalybuka@google.com>
diff --git a/src/component_manager.h b/src/component_manager.h
index 2deaa30..031b88a 100644
--- a/src/component_manager.h
+++ b/src/component_manager.h
@@ -169,6 +169,14 @@
Token AddServerStateUpdatedCallback(
const base::Callback<void(UpdateID)>& callback);
+ // Helper method for legacy API to obtain first component that implements
+ // the given trait. This is useful for routing commands that have no component
+ // path specified.
+ // Returns empty string if no components are found.
+ // This method only searches for component on the top level of components
+ // tree. No sub-components are searched.
+ std::string FindComponentWithTrait(const std::string& trait) const;
+
private:
// A helper method to find a JSON element of component at |path| to add new
// sub-components to.