#include #include #include "xyz/openbmc_project/Common/error.hpp" #include "settings.hpp" namespace settings { using namespace phosphor::logging; using namespace sdbusplus::xyz::openbmc_project::Common::Error; constexpr auto mapperService = "xyz.openbmc_project.ObjectMapper"; constexpr auto mapperPath = "/xyz/openbmc_project/object_mapper"; constexpr auto mapperIntf = "xyz.openbmc_project.ObjectMapper"; Objects::Objects() { auto bus = sdbusplus::bus::new_default(); std::vector settingsIntfs = {timeOwnerIntf, timeSyncIntf}; auto depth = 0; auto mapperCall = bus.new_method_call(mapperService, mapperPath, mapperIntf, "GetSubTree"); mapperCall.append(root); mapperCall.append(depth); mapperCall.append(settingsIntfs); auto response = bus.call(mapperCall); if (response.is_method_error()) { log("Error in mapper GetSubTree"); elog(); } using Interfaces = std::vector; using MapperResponse = std::map>; MapperResponse result; response.read(result); if (result.empty()) { log("Invalid response from mapper"); elog(); } for (const auto& iter : result) { const Path& path = iter.first; const Interface& interface = iter.second.begin()->second.front(); if (timeOwnerIntf == interface) { timeOwner = path; } else if (timeSyncIntf == interface) { timeSyncMethod = path; } } } Service Objects::service(const Path& path, const Interface& interface) const { auto bus = sdbusplus::bus::new_default(); using Interfaces = std::vector; auto mapperCall = bus.new_method_call(mapperService, mapperPath, mapperIntf, "GetObject"); mapperCall.append(path); mapperCall.append(Interfaces({interface})); auto response = bus.call(mapperCall); if (response.is_method_error()) { log("Error in mapper GetObject"); elog(); } std::map result; response.read(result); if (result.empty()) { log("Invalid response from mapper"); elog(); } return result.begin()->first; } } // namespace settings