Instance is the smallest unit of manifests/matrices.
Introduce forEachInstance on HalManifest and CompatibilityMatrix,
because <hal> are no longer the smallest unit of tests, but
rather a ManifestInstance / MatrixInstance object.
Bug: 73556059
Bug: 74247301
Test: libvintf_test
Test: vintf_object_test
Change-Id: If7186617db52acd67f255ac6e6c99f34a7570206
diff --git a/ManifestHal.cpp b/ManifestHal.cpp
index 00d0d95..beffa4d 100644
--- a/ManifestHal.cpp
+++ b/ManifestHal.cpp
@@ -17,6 +17,8 @@
#include "ManifestHal.h"
#include <unordered_set>
+#include "MapValueIterator.h"
+
namespace android {
namespace vintf {
@@ -42,13 +44,6 @@
return true;
}
-bool ManifestHal::containsVersion(const Version& version) const {
- for (Version v : versions) {
- if (v.minorAtLeast(version)) return true;
- }
- return false;
-}
-
std::set<std::string> ManifestHal::getInstances(const std::string& interfaceName) const {
std::set<std::string> ret;
auto it = interfaces.find(interfaceName);
@@ -58,5 +53,24 @@
return ret;
}
+bool ManifestHal::forEachInstance(const std::function<bool(const ManifestInstance&)>& func) const {
+ // TODO(b/73556059): support <fqname> as well.
+ for (const auto& v : versions) {
+ for (const auto& intf : iterateValues(interfaces)) {
+ for (const auto& instance : intf.instances) {
+ // TODO(b/73556059): Store ManifestInstance as well to avoid creating temps
+ FqInstance fqInstance;
+ if (fqInstance.setTo(getName(), v.majorVer, v.minorVer, intf.name, instance)) {
+ if (!func(ManifestInstance(std::move(fqInstance),
+ TransportArch{transportArch}))) {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+
} // namespace vintf
} // namespace android