void DbObject::VersionChangedHandler(const ConfigObject::Ptr& object) { DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object); if (dbobj) { dbobj->SendConfigUpdate(); dbobj->SendStatusUpdate(); } }
void DbObject::StateChangedHandler(const ConfigObject::Ptr& object) { DbObject::Ptr dbobj = GetOrCreateByObject(object); if (!dbobj) return; dbobj->SendStatusUpdate(); }
void DbConnection::UpdateAllObjects(void) { DynamicType::Ptr type; BOOST_FOREACH(const DynamicType::Ptr& dt, DynamicType::GetTypes()) { BOOST_FOREACH(const DynamicObject::Ptr& object, dt->GetObjects()) { DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object); if (dbobj) { if (!GetObjectActive(dbobj)) ActivateObject(dbobj); dbobj->SendConfigUpdate(); dbobj->SendStatusUpdate(); } } }
void DbConnection::UpdateObject(const ConfigObject::Ptr& object) { if (!GetConnected()) return; DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object); if (dbobj) { bool active = object->IsActive(); if (active) { ActivateObject(dbobj); dbobj->SendConfigUpdate(); dbobj->SendStatusUpdate(); } else DeactivateObject(dbobj); } }
void DbConnection::UpdateObject(const ConfigObject::Ptr& object) { if (!GetConnected()) return; DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object); if (dbobj) { bool dbActive = GetObjectActive(dbobj); bool active = object->IsActive(); if (active && !dbActive) { ActivateObject(dbobj); dbobj->SendConfigUpdate(); dbobj->SendStatusUpdate(); } else if (!active) { /* Deactivate the deleted object no matter * which state it had in the database. */ DeactivateObject(dbobj); } } }
void DbConnection::UpdateObject(const ConfigObject::Ptr& object) { if (!GetConnected() || Application::IsShuttingDown()) return; DbObject::Ptr dbobj = DbObject::GetOrCreateByObject(object); if (dbobj) { bool dbActive = GetObjectActive(dbobj); bool active = object->IsActive(); if (active) { if (!dbActive) ActivateObject(dbobj); Dictionary::Ptr configFields = dbobj->GetConfigFields(); String configHash = dbobj->CalculateConfigHash(configFields); ASSERT(configHash.GetLength() <= 64); configFields->Set("config_hash", configHash); String cachedHash = GetConfigHash(dbobj); if (cachedHash != configHash) { dbobj->SendConfigUpdateHeavy(configFields); dbobj->SendStatusUpdate(); } else { dbobj->SendConfigUpdateLight(); } } else if (!active) { /* Deactivate the deleted object no matter * which state it had in the database. */ DeactivateObject(dbobj); } } }