summaryrefslogtreecommitdiffstats
path: root/dcmihandler.cpp
diff options
context:
space:
mode:
authorWilliam A. Kennington III <wak@google.com>2018-10-12 17:18:14 -0700
committerWilliam A. Kennington III <wak@google.com>2018-10-18 15:08:55 -0700
commit4c0080287f2bb19ecfbe5cdd4a334f8769e7d0cd (patch)
treef2edadbb00b55c212c280c90f0cb35d96702bf4e /dcmihandler.cpp
parent1181af741589db873676f177ed85d6bc04884aa1 (diff)
downloadphosphor-host-ipmid-4c0080287f2bb19ecfbe5cdd4a334f8769e7d0cd.tar.gz
phosphor-host-ipmid-4c0080287f2bb19ecfbe5cdd4a334f8769e7d0cd.zip
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 <wak@google.com>
Diffstat (limited to 'dcmihandler.cpp')
-rw-r--r--dcmihandler.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/dcmihandler.cpp b/dcmihandler.cpp
index d01787e..6ea7dd8 100644
--- a/dcmihandler.cpp
+++ b/dcmihandler.cpp
@@ -14,6 +14,7 @@
#include <phosphor-logging/elog-errors.hpp>
#include <phosphor-logging/log.hpp>
#include <sdbusplus/bus.hpp>
+#include <sdbusplus/message/types.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
using namespace phosphor::logging;
@@ -56,6 +57,7 @@ constexpr auto SENSOR_VALUE_PROP = "Value";
constexpr auto SENSOR_SCALE_PROP = "Scale";
using namespace phosphor::logging;
+namespace variant_ns = sdbusplus::message::variant_ns;
namespace dcmi
{
@@ -83,7 +85,7 @@ uint32_t getPcap(sdbusplus::bus::bus& bus)
sdbusplus::message::variant<uint32_t> pcap;
reply.read(pcap);
- return pcap.get<uint32_t>();
+ return variant_ns::get<uint32_t>(pcap);
}
bool getPcapEnabled(sdbusplus::bus::bus& bus)
@@ -104,7 +106,7 @@ bool getPcapEnabled(sdbusplus::bus::bus& bus)
sdbusplus::message::variant<bool> pcapEnabled;
reply.read(pcapEnabled);
- return pcapEnabled.get<bool>();
+ return variant_ns::get<bool>(pcapEnabled);
}
void setPcap(sdbusplus::bus::bus& bus, const uint32_t powerCap)
@@ -203,7 +205,7 @@ std::string readAssetTag()
sdbusplus::message::variant<std::string> assetTag;
reply.read(assetTag);
- return assetTag.get<std::string>();
+ return variant_ns::get<std::string>(assetTag);
}
void writeAssetTag(const std::string& assetTag)
@@ -238,7 +240,7 @@ std::string getHostName(void)
auto value = ipmi::getDbusProperty(bus, service, networkConfigObj,
networkConfigIntf, hostNameProp);
- return value.get<std::string>();
+ return variant_ns::get<std::string>(value);
}
bool getDHCPEnabled()
@@ -253,7 +255,7 @@ bool getDHCPEnabled()
auto value = ipmi::getDbusProperty(bus, service, ethernetObj.first,
ethernetIntf, "DHCPEnabled");
- return value.get<bool>();
+ return variant_ns::get<bool>(value);
}
bool getDHCPOption(std::string prop)
@@ -263,7 +265,7 @@ bool getDHCPOption(std::string prop)
auto service = ipmi::getService(bus, dhcpIntf, dhcpObj);
auto value = ipmi::getDbusProperty(bus, service, dhcpObj, dhcpIntf, prop);
- return value.get<bool>();
+ return variant_ns::get<bool>(value);
}
void setDHCPOption(std::string prop, bool value)
@@ -801,10 +803,10 @@ Temperature readTemp(const std::string& dbusService,
sdbusplus::bus::bus bus{ipmid_get_sd_bus_connection()};
auto result = ipmi::getAllDbusProperties(
bus, dbusService, dbusPath, "xyz.openbmc_project.Sensor.Value");
- auto temperature = result.at("Value").get<int64_t>();
+ auto temperature = variant_ns::get<int64_t>(result.at("Value"));
uint64_t absTemp = std::abs(temperature);
- auto factor = result.at("Scale").get<int64_t>();
+ auto factor = variant_ns::get<int64_t>(result.at("Scale"));
uint64_t scale = std::pow(10, factor); // pow() returns float/double
unsigned long long tempDegrees = 0;
// Overflow safe multiplication when the scale is > 0
@@ -1056,8 +1058,8 @@ int64_t getPowerReading(sdbusplus::bus::bus& bus)
// Read the sensor value and scale properties
auto properties = ipmi::getAllDbusProperties(bus, service, objectPath,
SENSOR_VALUE_INTF);
- auto value = properties[SENSOR_VALUE_PROP].get<int64_t>();
- auto scale = properties[SENSOR_SCALE_PROP].get<int64_t>();
+ auto value = variant_ns::get<int64_t>(properties[SENSOR_VALUE_PROP]);
+ auto scale = variant_ns::get<int64_t>(properties[SENSOR_SCALE_PROP]);
// Power reading needs to be scaled with the Scale value using the
// formula Value * 10^Scale.
OpenPOWER on IntegriCloud