From 4c0080287f2bb19ecfbe5cdd4a334f8769e7d0cd Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Fri, 12 Oct 2018 17:18:14 -0700 Subject: Convert variant usage to std interface This is just a refactoring to use the c++17 std::variant interfaces instead of the mapbox::variant specific ones. We should be able to use mapbox::variant and std::variant interchangeably now. Tested: Built against sdbusplus with mapbox::variant and sbusplus using std::variant. Both variant compile and test out. Change-Id: I6fbaad3d12dd34968db6a10f3d74a65e07d0f0cc Signed-off-by: William A. Kennington III --- sensordatahandler.cpp | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'sensordatahandler.cpp') diff --git a/sensordatahandler.cpp b/sensordatahandler.cpp index c973f2e..4f552a3 100644 --- a/sensordatahandler.cpp +++ b/sensordatahandler.cpp @@ -5,8 +5,10 @@ #include "utils.hpp" #include +#include #include #include +#include #include #if __has_include() @@ -27,6 +29,8 @@ namespace ipmi namespace sensor { +namespace variant_ns = sdbusplus::message::variant_ns; + using namespace phosphor::logging; using InternalFailure = sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure; @@ -260,7 +264,7 @@ ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo) for (const auto& property : interface->second) { - Value tmp{sdbusplus::message::variant_ns::no_init()}; + std::optional tmp; for (const auto& value : std::get(property.second)) { if (bothSet.size() <= value.first || !bothSet.test(value.first)) @@ -281,14 +285,14 @@ ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo) } } - if (tmp.valid()) + if (tmp) { auto msg = makeDbusMsg("org.freedesktop.DBus.Properties", sensorInfo.sensorPath, "Set", sensorInfo.sensorInterface); msg.append(interface->first); msg.append(property.first); - msg.append(tmp); + msg.append(*tmp); auto rc = updateToDbus(msg); if (rc) @@ -348,7 +352,8 @@ ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo) { return IPMI_CC_OK; } - result = result && value.second.assert.get(); + result = + result && variant_ns::get(value.second.assert); valid = true; } else if (deassertionSet.test(value.first)) @@ -358,7 +363,8 @@ ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo) { return IPMI_CC_OK; } - result = result && value.second.deassert.get(); + result = + result && variant_ns::get(value.second.deassert); valid = true; } } @@ -367,11 +373,13 @@ ipmi_ret_t assertion(const SetSensorReadingReq& cmdData, const Info& sensorInfo) { if (assertionSet.test(value.first)) { - result = result && value.second.assert.get(); + result = + result && variant_ns::get(value.second.assert); } else if (deassertionSet.test(value.first)) { - result = result && value.second.deassert.get(); + result = + result && variant_ns::get(value.second.deassert); } } if (valid) -- cgit v1.2.1