1 #pragma once 2 3 #include <functional> 4 #include <vector> 5 #include "fan.hpp" 6 #include "rpolicy.hpp" 7 8 namespace phosphor 9 { 10 namespace fan 11 { 12 namespace presence 13 { 14 15 class PresenceSensor; 16 17 /** 18 * @class AnyOf 19 * @brief AnyOf redundancy policy. 20 * 21 * The any of redundancy policy monitors all sensor 22 * states in the redundancy set and reports true when any 23 * sensor in the set reports true. 24 */ 25 class AnyOf : public RedundancyPolicy 26 { 27 public: 28 AnyOf() = delete; 29 AnyOf(const AnyOf&) = default; 30 AnyOf& operator=(const AnyOf&) = default; 31 AnyOf(AnyOf&&) = default; 32 AnyOf& operator=(AnyOf&&) = default; 33 ~AnyOf() = default; 34 35 /** 36 * @brief Construct an any of bitwise policy. 37 * 38 * @param[in] fan - The fan associated with the policy. 39 * @param[in] s - The set of sensors associated with the policy. 40 */ 41 AnyOf( 42 const Fan& fan, 43 const std::vector<std::reference_wrapper<PresenceSensor>>& s); 44 45 /** 46 * @brief stateChanged 47 * 48 * Update the inventory and execute the fallback 49 * policy. 50 * 51 * @param[in] present - The new presence state according 52 * to the specified sensor. 53 * @param[in] sensor - The sensor reporting the new state. 54 */ 55 void stateChanged(bool present, PresenceSensor& sensor) override; 56 57 /** 58 * @brief monitor 59 * 60 * Start monitoring the fan. 61 */ 62 void monitor() override; 63 64 private: 65 66 /** @brief All presence sensors in the redundancy set. */ 67 std::vector< 68 std::tuple< 69 std::reference_wrapper<PresenceSensor>, 70 bool>> state; 71 }; 72 73 } // namespace presence 74 } // namespace fan 75 } // namespace phosphor 76