blob: 09f58527834820237580e4153d77b12def54c51c [file] [log] [blame]
Matthew Barth81748b12018-05-02 16:03:48 -05001#include "conditions.hpp"
Matthew Barth177fe982020-05-26 11:05:19 -05002
Matthew Barth81748b12018-05-02 16:03:48 -05003#include "sdbusplus.hpp"
4
Matthew Barth177fe982020-05-26 11:05:19 -05005#include <algorithm>
6
Matthew Barth81748b12018-05-02 16:03:48 -05007namespace phosphor
8{
9namespace fan
10{
11namespace monitor
12{
13namespace condition
14{
15
16Condition propertiesMatch(std::vector<PropertyState>&& propStates)
17{
Matthew Barth177fe982020-05-26 11:05:19 -050018 return [pStates = std::move(propStates)](sdbusplus::bus::bus& bus) {
Matthew Barth81748b12018-05-02 16:03:48 -050019 return std::all_of(
Matthew Barth177fe982020-05-26 11:05:19 -050020 pStates.begin(), pStates.end(), [&bus](const auto& p) {
21 return util::SDBusPlus::getPropertyVariant<PropertyValue>(
22 bus, std::get<propObj>(p.first),
23 std::get<propIface>(p.first),
24 std::get<propName>(p.first)) == p.second;
25 });
Matthew Barth81748b12018-05-02 16:03:48 -050026 };
27}
28
29} // namespace condition
30} // namespace monitor
31} // namespace fan
32} // namespace phosphor