Create Filters class to store filter functions
Enhanced the generated code to now store the filter functions within an
array contained in a struct similar to other configured parameters.
This allows the generated property watches to use an index within that
array to access a pointer to a Filters class containing a given set of
filter functions. The set of filter functions would then be applied
against all the properties being watched.
Tested:
Generated code provides structure needed to access filter functions
Filter functions filter property values that fail the filter(s)
Change-Id: I8f1f882704de521f2ab393530ad7ef096314975d
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp
index c639210..a1b8d68 100644
--- a/src/propertywatchimpl.hpp
+++ b/src/propertywatchimpl.hpp
@@ -158,15 +158,15 @@
auto isFiltered = false;
const auto& storage = std::get<storageIndex>(item->second);
auto value = sdbusplus::message::variant_ns::get<T>(p.second);
- for (auto& filterOp : filterOps)
+ if (filterOps)
{
- if (!filterOp(value))
+ any_ns::any anyValue = value;
+ if ((*filterOps)(anyValue))
{
// Property value filtered, clear it from storage so
// callback functions do not use it
isFiltered = true;
std::get<valueIndex>(storage.get()).clear();
- break;
}
}
if (!isFiltered)