diff options
Diffstat (limited to 'src/propertywatch.hpp')
-rw-r--r-- | src/propertywatch.hpp | 19 |
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. * |