blob: 687dfeed229895c3e2d019ec9695574fec20bde1 [file] [log] [blame]
Matthew Barth81748b12018-05-02 16:03:48 -05001#pragma once
2
3#include "types.hpp"
4
Matthew Barth3ad14342020-06-08 16:17:42 -05005#include <nlohmann/json.hpp>
6
Matthew Barth81748b12018-05-02 16:03:48 -05007namespace phosphor
8{
9namespace fan
10{
11namespace monitor
12{
13
Matthew Barth3ad14342020-06-08 16:17:42 -050014using json = nlohmann::json;
15
Matthew Barth81748b12018-05-02 16:03:48 -050016/**
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 */
23template <typename T>
24auto make_condition(T&& condition)
25{
26 return Condition(std::forward<T>(condition));
27}
28
29namespace 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 */
42Condition propertiesMatch(std::vector<PropertyState>&& propStates);
43
Matthew Barth3ad14342020-06-08 16:17:42 -050044/**
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 */
57Condition getPropertiesMatch(const json& condParams);
58
Matthew Barth81748b12018-05-02 16:03:48 -050059} // namespace condition
60} // namespace monitor
61} // namespace fan
62} // namespace phosphor