1 #pragma once 2 3 #include "types.hpp" 4 5 #include <nlohmann/json.hpp> 6 7 namespace phosphor 8 { 9 namespace fan 10 { 11 namespace monitor 12 { 13 14 using json = nlohmann::json; 15 16 /** 17 * @brief Create a condition function object 18 * 19 * @param[in] condition - The condition being created 20 * 21 * @return - The created condition function object 22 */ 23 template <typename T> 24 auto make_condition(T&& condition) 25 { 26 return Condition(std::forward<T>(condition)); 27 } 28 29 namespace condition 30 { 31 32 /** 33 * @brief A condition that checks all properties match the given values 34 * @details Checks each property entry against its given value where all 35 * property values must match their given value for the condition to pass 36 * 37 * @param[in] propStates - List of property identifiers and their value 38 * 39 * @return Condition lambda function 40 * A Condition function that checks all properties match 41 */ 42 Condition propertiesMatch(std::vector<PropertyState>&& propStates); 43 44 /** 45 * @brief Parse the propertiesMatch condition's parameters from the given JSON 46 * configuration 47 * @details Parses and verifies all the required parameters are given in the 48 * JSON configuration to construct and return a function pointer to the 49 * propertiesMatch condition function. 50 * 51 * @param[in] condParams - JSON object containing all the propertiesMatch 52 * condition parameters 53 * 54 * @return Condition lambda function 55 * The propertiesMatch condition function that checks all properties match 56 */ 57 Condition getPropertiesMatch(const json& condParams); 58 59 } // namespace condition 60 } // namespace monitor 61 } // namespace fan 62 } // namespace phosphor 63