From 7e9e04d10d74377a13d36d3f945b1cbc1aaf1a50 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 20 Mar 2018 13:06:00 -0700 Subject: regex-instance: HalInterface: add regex API and hide public fields is added under an tag, which is represented by an HalInterface object. Add API for looping over all s / s under it. With this API, HalInterface can hide its public fields. Bug: 73738616 Test: libvintf_test Test: vintf_object_test Test: vts_treble_vintf_test Change-Id: Ia072dd7e946c28789797db8a46fd968bc7872dca --- ManifestHal.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'ManifestHal.cpp') diff --git a/ManifestHal.cpp b/ManifestHal.cpp index c0f4c8e..2d0e246 100644 --- a/ManifestHal.cpp +++ b/ManifestHal.cpp @@ -51,15 +51,20 @@ bool ManifestHal::operator==(const ManifestHal &other) const { bool ManifestHal::forEachInstance(const std::function& func) const { for (const auto& v : versions) { for (const auto& intf : iterateValues(interfaces)) { - for (const auto& instance : intf.instances) { + bool cont = intf.forEachInstance([&](const auto& interface, const auto& instance, + bool /* isRegex */) { // 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 (fqInstance.setTo(getName(), v.majorVer, v.minorVer, interface, instance)) { if (!func(ManifestInstance(std::move(fqInstance), TransportArch{transportArch}, format))) { return false; } } + return true; + }); + if (!cont) { + return false; } } } @@ -135,5 +140,12 @@ bool ManifestHal::insertInstances(const std::set& fqInstances, std:: return true; } +void ManifestHal::insertLegacyInstance(const std::string& interface, const std::string& instance) { + auto it = interfaces.find(interface); + if (it == interfaces.end()) + it = interfaces.emplace(interface, HalInterface{interface, {}}).first; + it->second.insertInstance(instance, false /* isRegex */); +} + } // namespace vintf } // namespace android -- cgit v1.2.3-54-g00ecf