summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYifan Hong2018-03-05 19:45:34 -0600
committerYifan Hong2018-03-12 12:35:42 -0500
commit2a90ffedf034d8605ddbb14db47fd8d878a31260 (patch)
treed2987d1b838d92ad2eb8649e35efe5742ef04c07 /ManifestHal.cpp
parent60068a1416d5bef74a7a78647fd8b8d45933e929 (diff)
downloadplatform-system-libvintf-2a90ffedf034d8605ddbb14db47fd8d878a31260.tar.gz
platform-system-libvintf-2a90ffedf034d8605ddbb14db47fd8d878a31260.tar.xz
platform-system-libvintf-2a90ffedf034d8605ddbb14db47fd8d878a31260.zip
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
Diffstat (limited to 'ManifestHal.cpp')
-rw-r--r--ManifestHal.cpp28
1 files changed, 21 insertions, 7 deletions
diff --git a/ManifestHal.cpp b/ManifestHal.cpp
index 00d0d95..beffa4d 100644
--- a/ManifestHal.cpp
+++ b/ManifestHal.cpp
@@ -17,6 +17,8 @@
17#include "ManifestHal.h" 17#include "ManifestHal.h"
18#include <unordered_set> 18#include <unordered_set>
19 19
20#include "MapValueIterator.h"
21
20namespace android { 22namespace android {
21namespace vintf { 23namespace vintf {
22 24
@@ -42,13 +44,6 @@ bool ManifestHal::operator==(const ManifestHal &other) const {
42 return true; 44 return true;
43} 45}
44 46
45bool ManifestHal::containsVersion(const Version& version) const {
46 for (Version v : versions) {
47 if (v.minorAtLeast(version)) return true;
48 }
49 return false;
50}
51
52std::set<std::string> ManifestHal::getInstances(const std::string& interfaceName) const { 47std::set<std::string> ManifestHal::getInstances(const std::string& interfaceName) const {
53 std::set<std::string> ret; 48 std::set<std::string> ret;
54 auto it = interfaces.find(interfaceName); 49 auto it = interfaces.find(interfaceName);
@@ -58,5 +53,24 @@ std::set<std::string> ManifestHal::getInstances(const std::string& interfaceName
58 return ret; 53 return ret;
59} 54}
60 55
56bool ManifestHal::forEachInstance(const std::function<bool(const ManifestInstance&)>& func) const {
57 // TODO(b/73556059): support <fqname> as well.
58 for (const auto& v : versions) {
59 for (const auto& intf : iterateValues(interfaces)) {
60 for (const auto& instance : intf.instances) {
61 // TODO(b/73556059): Store ManifestInstance as well to avoid creating temps
62 FqInstance fqInstance;
63 if (fqInstance.setTo(getName(), v.majorVer, v.minorVer, intf.name, instance)) {
64 if (!func(ManifestInstance(std::move(fqInstance),
65 TransportArch{transportArch}))) {
66 return false;
67 }
68 }
69 }
70 }
71 }
72 return true;
73}
74
61} // namespace vintf 75} // namespace vintf
62} // namespace android 76} // namespace android