Factor out getPowerState() helper function
This same pattern had been open-coded in many of the sensor daemons;
let's reduce the duplication a bit.
Signed-off-by: Zev Weiss <zev@bewilderbeest.net>
Change-Id: I8556af30fdcd53cdf06e5a4911f9152d3265c7af
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index cec0984..fe8334d 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -253,14 +253,7 @@
}
}
- auto findPowerOn = baseConfiguration->second.find("PowerState");
- PowerState readState = PowerState::always;
- if (findPowerOn != baseConfiguration->second.end())
- {
- std::string powerState =
- std::visit(VariantToStringVisitor(), findPowerOn->second);
- setReadState(powerState, readState);
- }
+ PowerState readState = getPowerState(baseConfiguration->second);
auto& sensor = sensors[sensorName];
sensor = nullptr;