reduce dbus string constants
There are a large number of dbus constants scattered throughout the
code that could/should be obtained from phosphor-dbus-interface values.
Perform minor refactoring to greatly reduce the number of string
constants.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Ie8700bc90611d21eee7160f4686bc978fe0a0eb4
diff --git a/settings.cpp b/settings.cpp
index 2e2e70a..a334a84 100644
--- a/settings.cpp
+++ b/settings.cpp
@@ -5,6 +5,7 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/exception.hpp>
+#include <xyz/openbmc_project/ObjectMapper/client.hpp>
namespace settings
{
@@ -14,17 +15,16 @@
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";
+using ObjectMapper = sdbusplus::client::xyz::openbmc_project::ObjectMapper<>;
Objects::Objects(sdbusplus::bus_t& bus, const Path& root) : bus(bus)
{
std::vector<std::string> settingsIntfs = {autoRebootIntf, powerRestoreIntf};
auto depth = 0;
- auto mapperCall = bus.new_method_call(mapperService, mapperPath, mapperIntf,
- "GetSubTree");
+ auto mapperCall = bus.new_method_call(
+ ObjectMapper::default_service, ObjectMapper::instance_path,
+ ObjectMapper::interface, "GetSubTree");
mapperCall.append(root);
mapperCall.append(depth);
mapperCall.append(settingsIntfs);
@@ -100,8 +100,9 @@
Service Objects::service(const Path& path, const Interface& interface) const
{
using Interfaces = std::vector<Interface>;
- auto mapperCall = bus.new_method_call(mapperService, mapperPath, mapperIntf,
- "GetObject");
+ auto mapperCall = bus.new_method_call(ObjectMapper::default_service,
+ ObjectMapper::instance_path,
+ ObjectMapper::interface, "GetObject");
mapperCall.append(path);
mapperCall.append(Interfaces({interface}));