diff options
Diffstat (limited to 'include/vintf/HalGroup.h')
-rw-r--r-- | include/vintf/HalGroup.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/include/vintf/HalGroup.h b/include/vintf/HalGroup.h index 033adf0..2a1e1c3 100644 --- a/include/vintf/HalGroup.h +++ b/include/vintf/HalGroup.h | |||
@@ -48,14 +48,7 @@ struct HalGroup { | |||
48 | } | 48 | } |
49 | 49 | ||
50 | // Add an hal to this HalGroup so that it can be constructed programatically. | 50 | // Add an hal to this HalGroup so that it can be constructed programatically. |
51 | virtual bool add(Hal&& hal) { | 51 | virtual bool add(Hal&& hal) { return addInternal(std::move(hal)) != nullptr; } |
52 | if (!shouldAdd(hal)) { | ||
53 | return false; | ||
54 | } | ||
55 | std::string name = hal.getName(); | ||
56 | mHals.emplace(std::move(name), std::move(hal)); // always succeed | ||
57 | return true; | ||
58 | } | ||
59 | 52 | ||
60 | // Get all hals with the given name (e.g "android.hardware.camera"). | 53 | // Get all hals with the given name (e.g "android.hardware.camera"). |
61 | // There could be multiple hals that matches the same given name. | 54 | // There could be multiple hals that matches the same given name. |
@@ -191,6 +184,15 @@ struct HalGroup { | |||
191 | } | 184 | } |
192 | return &(it->second); | 185 | return &(it->second); |
193 | } | 186 | } |
187 | |||
188 | Hal* addInternal(Hal&& hal) { | ||
189 | if (!shouldAdd(hal)) { | ||
190 | return nullptr; | ||
191 | } | ||
192 | std::string name = hal.getName(); | ||
193 | auto it = mHals.emplace(std::move(name), std::move(hal)); // always succeeds | ||
194 | return &it->second; | ||
195 | } | ||
194 | }; | 196 | }; |
195 | 197 | ||
196 | } // namespace vintf | 198 | } // namespace vintf |