From a45e086dc57f51efb882bf864e78fe678238deea Mon Sep 17 00:00:00 2001 From: Ratan Gupta Date: Wed, 21 Feb 2018 19:03:13 +0530 Subject: Add callback contexts Add the notion of a callback context. This enables callbacks to have logic around the conditions they were invoked in. There are two context on which call back can be invoked 1) Startup: during startup all the call backs will be called 2) Signal: As part of condition match on the watched properties. Callback would behave differently based on the context. eg: eventCallback 1) Startup: Don't take any action. 2) Signal: Create the Dbus Object for the event. Change-Id: If455558798ac3e44bbd8a93de0ce1b09d2e308ae Signed-off-by: Ratan Gupta --- src/propertywatchimpl.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/propertywatchimpl.hpp') diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp index 3ef5de5..43875b9 100644 --- a/src/propertywatchimpl.hpp +++ b/src/propertywatchimpl.hpp @@ -104,12 +104,12 @@ void PropertyWatch::start() } template -void PropertyWatch::callback() +void PropertyWatch::callback(Context ctx) { // Invoke callback if present. if (this->alreadyRan && this->cb) { - (*this->cb)(); + (*this->cb)(ctx); } } @@ -149,7 +149,7 @@ void PropertyWatchOfType::propertiesChanged( std::get<2>(item->second).get() = p.second.template get(); // Invoke callback if present. - this->callback(); + this->callback(Context::SIGNAL); } } -- cgit v1.2.1