settings: handle multiple objects/interfaces
Handle the fact that a settings object can now implement multiple
interfaces, and also the fact that multiple settings objects
can implement the same interface.
Change-Id: If8a3e20fb2e1d53515d96ceabce6326d91e8eb3e
Signed-off-by: Tom Joseph <tomjoseph@in.ibm.com>
diff --git a/settings.cpp b/settings.cpp
index cb86d99..59f9f33 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -46,8 +46,19 @@
for (auto& iter : result)
{
const auto& path = iter.first;
- auto& interface = iter.second.begin()->second[0];
- map.emplace(std::move(interface), path);
+ for (auto& interface : iter.second.begin()->second)
+ {
+ auto found = map.find(interface);
+ if (map.end() != found)
+ {
+ auto& paths = found->second;
+ paths.push_back(path);
+ }
+ else
+ {
+ map.emplace(std::move(interface), std::vector<Path>({path}));
+ }
+ }
}
}
diff --git a/settings.hpp b/settings.hpp
index 60ee4d4..ec1d913 100644
--- a/settings.hpp
+++ b/settings.hpp
@@ -42,12 +42,8 @@
*/
Service service(const Path& path, const Interface& interface) const;
- // TODO openbmc/openbmc#2058 - This will break when multiple settings,
- // or in general multiple objects implement a single setting interface.
- // For instance this will break for a 2-blade server, because we'd have
- // 2 sets of settings objects. Need to revisit and fix this.
/** @brief map of settings objects */
- std::map<Interface, Path> map;
+ std::map<Interface, std::vector<Path>> map;
/** @brief The Dbus bus object */
sdbusplus::bus::bus& bus;