Move polling loop to state container
Base the polling loop on the state instance, rather than
SensorSet.
Change-Id: I104c730f1ad07b0680d87902e2ed39e5afa5e9d2
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/mainloop.cpp b/mainloop.cpp
index 8c21566..c1b3fe3 100644
--- a/mainloop.cpp
+++ b/mainloop.cpp
@@ -56,6 +56,12 @@
auto sensors = std::make_unique<SensorSet>(_path);
auto sensor_cache = std::make_unique<SensorCache>();
+ for (auto& i : *sensors)
+ {
+ auto value = std::make_tuple(std::move(i.second));
+ state[std::move(i.first)] = std::move(value);
+ }
+
{
struct Free
{
@@ -77,9 +83,10 @@
while (!_shutdown)
{
// Iterate through all the sensors.
- for (auto& i : *sensors)
+ for (auto& i : state)
{
- if (i.second.find(hwmon::entry::input) != i.second.end())
+ auto& attrs = std::get<0>(i.second);
+ if (attrs.find(hwmon::entry::input) != attrs.end())
{
// Read value from sensor.
int value = 0;