From 32affb9879b18226b3a026072ce1753f03b7ca58 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Fri, 16 Feb 2018 16:11:13 -0600 Subject: optimize: Tach sensors as shared pointers The fan and trust group objects should utilize shared pointers to the tach sensor objects. This allows optimizing the storage of additional attributes associated with the tach sensors. e.g. An attribute to declare which sensors should be included in the trust determination. Tested: Current trust group associations & reactions are unchanged Change-Id: I249cc7debf467e8275fae7fa157ce97078b40802 Signed-off-by: Matthew Barth --- monitor/trust_group.hpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'monitor/trust_group.hpp') diff --git a/monitor/trust_group.hpp b/monitor/trust_group.hpp index e0db5c9..ff60508 100644 --- a/monitor/trust_group.hpp +++ b/monitor/trust_group.hpp @@ -57,7 +57,7 @@ class Group * * @param[in] sensor - the TachSensor to register */ - void registerSensor(std::unique_ptr& sensor) + void registerSensor(std::shared_ptr& sensor) { auto found = std::find_if( _names.begin(), @@ -89,7 +89,7 @@ class Group _sensors.end(), [&sensor](const auto& s) { - return sensor.name() == s.get()->name(); + return sensor.name() == s->name(); }) != _sensors.end()); } @@ -107,7 +107,7 @@ class Group _sensors.end(), [](const auto& s) { - s.get()->stopTimer(); + s->stopTimer(); }); } @@ -126,11 +126,11 @@ class Group { //If a sensor isn't functional, then its timer //already expired so don't bother starting it again - if (s.get()->functional() && - static_cast(s.get()->getInput()) != - s.get()->getTarget()) + if (s->functional() && + static_cast(s->getInput()) != + s->getTarget()) { - s.get()->startTimer(); + s->startTimer(); } }); } @@ -194,8 +194,7 @@ class Group * * Added by registerSensor(). */ - std::vector>> _sensors; + std::vector> _sensors; private: -- cgit v1.2.1