Remove Configuration interface prefix from utils APIs
This eliminates some repetitive verbosity from daemons that handle a lot
of different sensor types (such as hwmontempsensor and psusensor). It
also positions us to more cleanly use a single data structure for both
existing APIs like GetSensorConfiguration() and
setupPropertiesChangedMatches(), as well as upcoming I2C
device-management support.
Tested: hwmontempsensor and adcsensor on romed8hm3 continue to behave as
they did previously.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I9d80475ca4160c8d2ff0afab942709496d51238d
diff --git a/include/Utils.hpp b/include/Utils.hpp
index 2d6bac3..b39492e 100644
--- a/include/Utils.hpp
+++ b/include/Utils.hpp
@@ -91,6 +91,14 @@
bool readingStateGood(const PowerState& powerState);
+constexpr const char* configInterfacePrefix =
+ "xyz.openbmc_project.Configuration.";
+
+inline std::string configInterfaceName(const std::string& type)
+{
+ return std::string(configInterfacePrefix) + type;
+}
+
namespace mapper
{
constexpr const char* busName = "xyz.openbmc_project.ObjectMapper";
@@ -258,7 +266,7 @@
interface);
}
- void getConfiguration(const std::vector<std::string>& interfaces,
+ void getConfiguration(const std::vector<std::string>& types,
size_t retries = 0)
{
if (retries > 5)
@@ -266,6 +274,12 @@
retries = 5;
}
+ std::vector<std::string> interfaces(types.size());
+ for (const auto& type : types)
+ {
+ interfaces.push_back(configInterfaceName(type));
+ }
+
std::shared_ptr<GetSensorConfiguration> self = shared_from_this();
dbusConnection->async_method_call(
[self, interfaces, retries](const boost::system::error_code ec,