summaryrefslogtreecommitdiffstats
path: root/src/propertywatch.hpp
diff options
context:
space:
mode:
authorBrad Bishop <bradleyb@fuzziesquirrel.com>2017-05-22 21:11:09 -0400
committerBrad Bishop <bradleyb@fuzziesquirrel.com>2017-06-19 16:26:48 -0400
commitfccdc39fdf8f97ef4bf3de3b8ddcae28fef4bc8e (patch)
tree734c68fb96a00f64783f846e5a22eda1138ffe21 /src/propertywatch.hpp
parentb97bfff73e44e53571f8a00b80ec947496930d7b (diff)
downloadphosphor-dbus-monitor-fccdc39fdf8f97ef4bf3de3b8ddcae28fef4bc8e.tar.gz
phosphor-dbus-monitor-fccdc39fdf8f97ef4bf3de3b8ddcae28fef4bc8e.zip
Link watches to callbacks
Callbacks must ultimately be triggered when a property is updated by a watch. Add that support. Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com> Change-Id: I20130a11c19ddcf2c4ae45800f2068b31950bcd6
Diffstat (limited to 'src/propertywatch.hpp')
-rw-r--r--src/propertywatch.hpp19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/propertywatch.hpp b/src/propertywatch.hpp
index 59db599..3eb05df 100644
--- a/src/propertywatch.hpp
+++ b/src/propertywatch.hpp
@@ -17,6 +17,8 @@ namespace dbus
namespace monitoring
{
+class Callback;
+
/** @class PropertyWatch
* @brief Type agnostic, factored out logic for property watches.
*
@@ -33,8 +35,10 @@ class PropertyWatch : public Watch
PropertyWatch& operator=(const PropertyWatch&) = delete;
PropertyWatch& operator=(PropertyWatch&&) = default;
virtual ~PropertyWatch() = default;
- explicit PropertyWatch(const PropertyIndex& watchIndex)
- : Watch(), index(watchIndex), alreadyRan(false) {}
+ PropertyWatch(
+ const PropertyIndex& watchIndex,
+ Callback* cb = nullptr)
+ : Watch(), index(watchIndex), callback(cb), alreadyRan(false) {}
/** @brief Start the watch.
*
@@ -84,7 +88,8 @@ class PropertyWatch : public Watch
/** @brief Property names and their associated storage. */
const PropertyIndex& index;
- private:
+ /** @brief Optional callback method. */
+ Callback* const callback;
/** @brief The start method should only be invoked once. */
bool alreadyRan;
@@ -106,9 +111,13 @@ class PropertyWatchOfType : public PropertyWatch<DBusInterfaceType>
PropertyWatchOfType& operator=(const PropertyWatchOfType&) = delete;
PropertyWatchOfType& operator=(PropertyWatchOfType&&) = default;
~PropertyWatchOfType() = default;
- explicit PropertyWatchOfType(
+ PropertyWatchOfType(
+ const PropertyIndex& watchIndex, Callback& callback) :
+ PropertyWatch<DBusInterfaceType>(watchIndex, &callback) {}
+ PropertyWatchOfType(
const PropertyIndex& watchIndex) :
- PropertyWatch<DBusInterfaceType>(watchIndex) {}
+ PropertyWatch<DBusInterfaceType>(watchIndex, nullptr) {}
+
/** @brief PropertyMatch implementation for PropertyWatchOfType.
*
OpenPOWER on IntegriCloud