Replace tuple with struct for trust sensor group
To simplify sensor and trust access, utilize a struct in place of a
tuple for storing the trust group sensors and their inclusion in the
trust determination.
Tested: Current trust group associations & reactions are unchanged
Change-Id: Ifd5cf5d0540a3b2028ccf74e725d8ddd11982aee
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/monitor/trust_group.hpp b/monitor/trust_group.hpp
index 7f28f6c..a41520a 100644
--- a/monitor/trust_group.hpp
+++ b/monitor/trust_group.hpp
@@ -14,6 +14,12 @@
using GroupDefinition = std::tuple<std::string,
bool>;
+struct GroupSensor
+{
+ std::shared_ptr<monitor::TachSensor> sensor;
+ bool inTrust;
+};
+
/**
* @class Group
*
@@ -75,8 +81,7 @@
if (found != _names.end())
{
- auto gs = std::make_tuple(sensor, std::get<inTrust>(*found));
- _sensors.push_back(gs);
+ _sensors.push_back({sensor, std::get<inTrust>(*found)});
}
}
@@ -95,7 +100,7 @@
_sensors.end(),
[&sensor](const auto& s)
{
- return sensor.name() == std::get<0>(s)->name();
+ return sensor.name() == s.sensor->name();
}) != _sensors.end());
}
@@ -113,7 +118,7 @@
_sensors.end(),
[](const auto& s)
{
- std::get<0>(s)->stopTimer();
+ s.sensor->stopTimer();
});
}
@@ -132,11 +137,12 @@
{
//If a sensor isn't functional, then its timer
//already expired so don't bother starting it again
- if (std::get<0>(s)->functional() &&
- static_cast<uint64_t>(std::get<0>(s)->getInput()) !=
- std::get<0>(s)->getTarget())
+ if (s.sensor->functional() &&
+ static_cast<uint64_t>(
+ s.sensor->getInput()) !=
+ s.sensor->getTarget())
{
- std::get<0>(s)->startTimer();
+ s.sensor->startTimer();
}
});
}
@@ -200,9 +206,7 @@
*
* Added by registerSensor().
*/
- std::vector<std::tuple<
- std::shared_ptr<monitor::TachSensor>,
- bool>> _sensors;
+ std::vector<GroupSensor> _sensors;
private: