#include "settings.hpp" #include #include #include #include #include namespace settings { using namespace phosphor::logging; using namespace sdbusplus::error::xyz::openbmc_project::common; constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper"; constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper"; constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper"; Objects::Objects(sdbusplus::bus_t& bus, const std::vector& filter) : bus(bus) { auto depth = 0; auto mapperCall = bus.new_method_call(mapperService, mapperPath, mapperIntf, "GetSubTree"); mapperCall.append(root); mapperCall.append(depth); mapperCall.append(filter); using Interfaces = std::vector; using MapperResponse = std::map>; MapperResponse result; try { auto response = bus.call(mapperCall); response.read(result); } catch (const std::exception& e) { log("Error in mapper GetSubTree", entry("ERROR=%s", e.what())); elog(); } for (auto& iter : result) { const auto& path = iter.first; 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})); } } } } Service Objects::service(const Path& path, const Interface& interface) const { using Interfaces = std::vector; auto mapperCall = bus.new_method_call(mapperService, mapperPath, mapperIntf, "GetObject"); mapperCall.append(path); mapperCall.append(Interfaces({interface})); std::map result; try { auto response = bus.call(mapperCall); response.read(result); return result.begin()->first; } catch (const std::exception& e) { log("Invalid response from mapper", entry("ERROR=%s", e.what())); elog(); } } } // namespace settings