From ce4fbe111da9375e9614e018547e90092df6ec4b Mon Sep 17 00:00:00 2001 From: Brad Bishop Date: Tue, 6 Jun 2017 23:58:09 -0400 Subject: expose watch callbacks Allow watch class users to explicitly invoke the watch callback. Since watches and callbacks share a common pool of state all watches must complete their initialization prior to invoking their callback methods. Change-Id: I62ebad64da88a145f3d5006b07c01381b0eb6728 Signed-off-by: Brad Bishop --- src/propertywatchimpl.hpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'src/propertywatchimpl.hpp') diff --git a/src/propertywatchimpl.hpp b/src/propertywatchimpl.hpp index d0153e4..67bbaff 100644 --- a/src/propertywatchimpl.hpp +++ b/src/propertywatchimpl.hpp @@ -108,6 +108,16 @@ void PropertyWatch::start() alreadyRan = true; } +template +void PropertyWatch::callback() +{ + // Invoke callback if present. + if (this->alreadyRan && this->cb) + { + (*this->cb)(); + } +} + template void PropertyWatchOfType::updateProperties( const std::string& busName, @@ -144,10 +154,7 @@ void PropertyWatchOfType::propertiesChanged( std::get<2>(item->second).get() = p.second.template get(); // Invoke callback if present. - if (this->alreadyRan && this->callback) - { - (*this->callback)(); - } + this->callback(); } } -- cgit v1.2.1