diff options
author | Matthew Barth <msbarth@us.ibm.com> | 2017-09-11 16:07:58 -0500 |
---|---|---|
committer | Matthew Barth <msbarth@us.ibm.com> | 2017-09-18 10:35:10 -0500 |
commit | f9201abb8ca5a30220b05f3bbaa2db9343699a80 (patch) | |
tree | 35643a2081fc4be8f9d9c1f1576b4211294b04f4 /control/preconditions.hpp | |
parent | 6ad28430764b7d16ee7abcb9965b76ea5583008f (diff) | |
download | phosphor-fan-presence-f9201abb8ca5a30220b05f3bbaa2db9343699a80.tar.gz phosphor-fan-presence-f9201abb8ca5a30220b05f3bbaa2db9343699a80.zip |
Support a list of actions for a set speed event
Each set speed event will contain a list of one-to-many actions to
perform for the given event group's property. This reduces the amount of
code generated and properly handles property changed events against the
group.
Change-Id: If2b8c0d0b8ecf6e1c974c43d96e1c6e9e952022b
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
Diffstat (limited to 'control/preconditions.hpp')
-rw-r--r-- | control/preconditions.hpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/control/preconditions.hpp b/control/preconditions.hpp index 65eb0e2..f989f0d 100644 --- a/control/preconditions.hpp +++ b/control/preconditions.hpp @@ -28,7 +28,7 @@ namespace precondition * and either subscribe or unsubscribe a set speed event group. */ auto property_states_match(std::vector<PrecondGroup>&& pg, - SetSpeedEvent&& sse) + std::vector<SetSpeedEvent>&& sse) { return [pg = std::move(pg), sse = std::move(sse)](auto& zone, auto& group) @@ -56,13 +56,25 @@ auto property_states_match(std::vector<PrecondGroup>&& pg, if (precondState == pg.size()) { - // Init the event when all the precondition(s) are true - zone.initEvent(sse); + // Init the events when all the precondition(s) are true + std::for_each( + sse.begin(), + sse.end(), + [&zone](auto const& entry) + { + zone.initEvent(entry); + }); } else { - // Unsubscribe the event signals when any precondition is false - zone.removeEvent(sse); + // Unsubscribe the events' signals when any precondition is false + std::for_each( + sse.begin(), + sse.end(), + [&zone](auto const& entry) + { + zone.removeEvent(entry); + }); zone.setFullSpeed(); } // Update group's fan control active allowed |