From a6d8cea5c28afb13032a90b9047a801bee2d1bad Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 15 Sep 2015 11:59:09 +0200 Subject: [PATCH] Update DB IDO on changed object version (create, update, delete) refs #9927 --- lib/db_ido/dbobject.cpp | 13 +++++++++++++ lib/db_ido/dbobject.hpp | 2 ++ 2 files changed, 15 insertions(+) diff --git a/lib/db_ido/dbobject.cpp b/lib/db_ido/dbobject.cpp index 1689e91dc..3cb247056 100644 --- a/lib/db_ido/dbobject.cpp +++ b/lib/db_ido/dbobject.cpp @@ -49,6 +49,9 @@ void DbObject::StaticInitialize(void) /* triggered in ProcessCheckResult(), requires UpdateNextCheck() to be called before */ ConfigObject::OnStateChanged.connect(boost::bind(&DbObject::StateChangedHandler, _1)); CustomVarObject::OnVarsChanged.connect(boost::bind(&DbObject::VarsChangedHandler, _1)); + + /* triggered on create, update and delete objects */ + ConfigObject::OnVersionChanged.connect(boost::bind(&DbObject::VersionChangedHandler, _1)); } void DbObject::SetObject(const ConfigObject::Ptr& object) @@ -355,6 +358,16 @@ void DbObject::VarsChangedHandler(const CustomVarObject::Ptr& object) dbobj->SendVarsStatusUpdate(); } +void DbObject::VersionChangedHandler(const ConfigObject::Ptr& object) +{ + DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object); + + if (dbobj) { + dbobj->SendConfigUpdate(); + dbobj->SendStatusUpdate(); + } +} + boost::mutex& DbObject::GetStaticMutex(void) { static boost::mutex mutex; diff --git a/lib/db_ido/dbobject.hpp b/lib/db_ido/dbobject.hpp index 9e808b68f..e4cfd330d 100644 --- a/lib/db_ido/dbobject.hpp +++ b/lib/db_ido/dbobject.hpp @@ -106,6 +106,8 @@ private: static void StateChangedHandler(const ConfigObject::Ptr& object); static void VarsChangedHandler(const CustomVarObject::Ptr& object); + static void VersionChangedHandler(const ConfigObject::Ptr& object); + static boost::mutex& GetStaticMutex(void); friend class DbType; -- 2.40.0