Add filters option to property watch class

Each property changed signal calls a defined callback, an optional set
of filters can be defined to filter out property values not intended to
be used within the callback. These filters can be setup to eliminate
property value(s) that should be ignored per property group and its
configured callback.

ex.) Handle errant sensor values that could occur from a faulty device
so these values do not cause unwanted results from a callback function.

Example config entry to throw out an ambient temperature less than 0C or
greater than 100C:

- name: watch ambient temps
  description: >
    'Filter the ambient temps, discarding any value that
    does not pass, then trigger the callback logic.'
  class: watch
  watch: property
  paths: ambient sensors
  properties: ambient temp
  callback: median temps
  filters:
    - op: '>='
      bound: 0
    - op: '<='
      bound: 100000

Tested:
    Generate a single filter function against a group of properties
    Generate multiple filter functions against a group of properties
    Property values are cleared when it fails to pass a filter
    Property values that pass all filters are updated

Change-Id: Id5126263096b4787a40befdb14cf3514038df3ed
Signed-off-by: Matthew Barth <msbarth@us.ibm.com>
diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp
index 94d6fd2..c639210 100644
--- a/src/propertywatchimpl.hpp
+++ b/src/propertywatchimpl.hpp
@@ -154,11 +154,28 @@
             continue;
         }
 
-        std::get<valueIndex>(std::get<storageIndex>(item->second).get()) =
-            sdbusplus::message::variant_ns::get<T>(p.second);
-
-        // Invoke callback if present.
-        this->callback(Context::SIGNAL);
+        // Run property value thru filter operations
+        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 (!filterOp(value))
+            {
+                // 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)
+        {
+            // Property value not filtered out, update
+            std::get<valueIndex>(storage.get()) = value;
+            // Invoke callback if present.
+            this->callback(Context::SIGNAL);
+        }
     }
 }