1 #pragma once 2 3 #include "trust_group.hpp" 4 5 namespace phosphor 6 { 7 namespace fan 8 { 9 namespace trust 10 { 11 12 /** 13 * @class NonzeroSpeed 14 * 15 * A trust group where the sensors in the group are trusted as long 16 * as at least one of them has a nonzero speed. If all sensors 17 * have a speed of zero, then no sensor in the group is trusted. 18 */ 19 class NonzeroSpeed : public Group 20 { 21 public: 22 NonzeroSpeed() = delete; 23 ~NonzeroSpeed() = default; 24 NonzeroSpeed(const NonzeroSpeed&) = delete; 25 NonzeroSpeed& operator=(const NonzeroSpeed&) = delete; 26 NonzeroSpeed(NonzeroSpeed&&) = default; 27 NonzeroSpeed& operator=(NonzeroSpeed&&) = default; 28 29 /** 30 * Constructor 31 * 32 * @param[in] names - the names of the sensors and its inclusion in 33 * determining trust for the group 34 */ NonzeroSpeed(const std::vector<GroupDefinition> & names)35 explicit NonzeroSpeed(const std::vector<GroupDefinition>& names) : 36 Group(names) 37 {} 38 39 private: 40 /** 41 * Determines if the group is trusted by checking 42 * if any sensor included in the trust determination 43 * has a nonzero speed. If all the speeds of these sensors 44 * are zero, then no sensors in the group are trusted. 45 * 46 * @return bool - if group is trusted or not 47 */ checkGroupTrust()48 bool checkGroupTrust() override 49 { 50 return std::any_of(_sensors.begin(), _sensors.end(), [](const auto& s) { 51 return s.inTrust && s.sensor->getInput() != 0; 52 }); 53 } 54 }; 55 56 } // namespace trust 57 } // namespace fan 58 } // namespace phosphor 59