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/propertywatch.hpp b/src/propertywatch.hpp
index 3168abe..ecb8e9c 100644
--- a/src/propertywatch.hpp
+++ b/src/propertywatch.hpp
@@ -8,6 +8,7 @@
#pragma once
#include "data_types.hpp"
+#include "filters.hpp"
#include "watch.hpp"
namespace phosphor
@@ -116,14 +117,14 @@
PropertyWatchOfType& operator=(const PropertyWatchOfType&) = delete;
PropertyWatchOfType& operator=(PropertyWatchOfType&&) = default;
~PropertyWatchOfType() = default;
- PropertyWatchOfType(const std::vector<std::function<bool(T)>>& filterOps,
- const PropertyIndex& watchIndex, Callback& callback) :
+ PropertyWatchOfType(const PropertyIndex& watchIndex, Callback& callback,
+ Filters* filterOps = nullptr) :
PropertyWatch<DBusInterfaceType>(watchIndex, &callback),
filterOps(filterOps)
{
}
- PropertyWatchOfType(const std::vector<std::function<bool(T)>>& filterOps,
- const PropertyIndex& watchIndex) :
+ PropertyWatchOfType(const PropertyIndex& watchIndex,
+ Filters* filterOps = nullptr) :
PropertyWatch<DBusInterfaceType>(watchIndex, nullptr),
filterOps(filterOps)
{
@@ -176,8 +177,8 @@
const InterfacesAdded<T>& interfaces);
private:
- /** @brief List of filter operations to perform on property changes. */
- const std::vector<std::function<bool(T)>> filterOps;
+ /** @brief Optional filter operations to perform on property changes. */
+ Filters* const filterOps;
};
} // namespace monitoring