summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'include/vintf/HalGroup.h')
-rw-r--r--include/vintf/HalGroup.h47
1 files changed, 47 insertions, 0 deletions
diff --git a/include/vintf/HalGroup.h b/include/vintf/HalGroup.h
index 8ef6f38..e3f0c7c 100644
--- a/include/vintf/HalGroup.h
+++ b/include/vintf/HalGroup.h
@@ -18,8 +18,10 @@
18#define ANDROID_VINTF_HAL_GROUP_H 18#define ANDROID_VINTF_HAL_GROUP_H
19 19
20#include <map> 20#include <map>
21#include <set>
21 22
22#include "MapValueIterator.h" 23#include "MapValueIterator.h"
24#include "Version.h"
23 25
24namespace android { 26namespace android {
25namespace vintf { 27namespace vintf {
@@ -53,6 +55,51 @@ struct HalGroup {
53 return true; 55 return true;
54 } 56 }
55 57
58 // Get all hals with the given name (e.g "android.hardware.camera").
59 // There could be multiple hals that matches the same given name.
60 std::vector<const Hal*> getHals(const std::string& name) const {
61 std::vector<const Hal*> ret;
62 auto range = mHals.equal_range(name);
63 for (auto it = range.first; it != range.second; ++it) {
64 ret.push_back(&it->second);
65 }
66 return ret;
67 }
68
69 // Get all hals with the given name (e.g "android.hardware.camera").
70 // There could be multiple hals that matches the same given name.
71 // Non-const version of the above getHals() method.
72 std::vector<Hal*> getHals(const std::string& name) {
73 std::vector<Hal*> ret;
74 auto range = mHals.equal_range(name);
75 for (auto it = range.first; it != range.second; ++it) {
76 ret.push_back(&it->second);
77 }
78 return ret;
79 }
80
81 // Get the hal that matches the given name and version (e.g.
82 // "android.hardware.camera@2.4")
83 // There should be a single hal that matches the given name and version.
84 const Hal* getHal(const std::string& name, const Version& version) const {
85 for (const Hal* hal : getHals(name)) {
86 if (hal->containsVersion(version)) return hal;
87 }
88 return nullptr;
89 }
90
91 // Get all instance names for hal that matches the given component name, version
92 // and interface name (e.g. "android.hardware.camera@2.4::ICameraProvider").
93 // * If the component ("android.hardware.camera@2.4") does not exist, return empty set.
94 // * If the component ("android.hardware.camera@2.4") does exist,
95 // * If the interface (ICameraProvider) does not exist, return empty set.
96 // * Else return the list hal.interface.instance.
97 std::set<std::string> getInstances(const std::string& halName, const Version& version,
98 const std::string& interfaceName) const {
99 const Hal* hal = getHal(halName, version);
100 return hal->getInstances(interfaceName);
101 }
102
56 protected: 103 protected:
57 // sorted map from component name to the component. 104 // sorted map from component name to the component.
58 // The component name looks like: android.hardware.foo 105 // The component name looks like: android.hardware.foo