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/MatrixHal.cpp b/MatrixHal.cpp
index 96dcf78..fbe9a5f 100644
--- a/MatrixHal.cpp
+++ b/MatrixHal.cpp
@@ -16,6 +16,8 @@
#include "MatrixHal.h"
+#include "MapValueIterator.h"
+
namespace android {
namespace vintf {
@@ -66,5 +68,22 @@
return true;
}
+bool MatrixHal::forEachInstance(const std::function<bool(const MatrixInstance&)>& func) const {
+ for (const auto& vr : versionRanges) {
+ for (const auto& intf : iterateValues(interfaces)) {
+ for (const auto& instance : intf.instances) {
+ // TODO(b/73556059): Store MatrixInstance as well to avoid creating temps
+ FqInstance fqInstance;
+ if (fqInstance.setTo(getName(), vr.majorVer, vr.minMinor, intf.name, instance)) {
+ if (!func(MatrixInstance(std::move(fqInstance), VersionRange(vr), optional))) {
+ return false;
+ }
+ }
+ }
+ }
+ }
+ return true;
+}
+
} // namespace vintf
} // namespace android