NS_IMETHODIMP sbPlayQueueExternalLibraryListener::OnItemUpdated(sbIMediaList* aMediaList, sbIMediaItem* aMediaItem, sbIPropertyArray* aProperties, PRBool* aNoMoreForBatch) { TRACE(("%s[%p]", __FUNCTION__, this)); nsresult rv; Updates updates; sbPropertyUpdate update(aMediaItem, aProperties); { nsAutoLock lock(mUpdateLock); UpdateIter it; it = std::find(mUpdates.begin(), mUpdates.end(), update); if (it != mUpdates.end()) { // This update is already being handled. return NS_OK; } rv = GenerateUpdates(aMediaItem, aProperties, updates); NS_ENSURE_SUCCESS(rv, rv); if (updates.size() == 0) { // No duplicates to update. return NS_OK; } for (it = updates.begin(); it != updates.end(); it++) { mUpdates.push_back(*it); } } // Get the updated properties from the item and apply them to the items we // need to update. nsCOMPtr<sbIPropertyArray> props; rv = aMediaItem->GetProperties(aProperties, getter_AddRefs(props)); NS_ENSURE_SUCCESS(rv, rv); for (UpdateIter it = updates.begin(); it != updates.end(); it++) { rv = it->mItem->SetProperties(props); NS_ENSURE_SUCCESS(rv, rv); } { nsAutoLock lock(mUpdateLock); for (UpdateIter it = updates.begin(); it != updates.end(); it++) { mUpdates.remove(*it); } } return NS_OK; }
void LoadLocaleMPQFiles(int const locale) { char filename[512]; // first base old version of dbc files sprintf(filename, "%s/Data/%s/locale-%s.MPQ", input_path, langs[locale], langs[locale]); HANDLE localeMpqHandle; if (!OpenArchive(filename, &localeMpqHandle)) { printf("Error open archive: %s\n\n", filename); return; } // prepare sorted list patches in locale dir and Data root Updates updates; // now update to newer view, locale AppendPatchMPQFilesToList(langs[locale], langs[locale], NULL, updates); // now update to newer view, root AppendPatchMPQFilesToList(NULL, NULL, langs[locale], updates); for (Updates::const_iterator itr = updates.begin(); itr != updates.end(); ++itr) { if (!itr->second.second) sprintf(filename, "%s/Data/%s/%s", input_path, langs[locale], itr->second.first.c_str()); else sprintf(filename, "%s/Data/%s", input_path, itr->second.first.c_str()); //if (!OpenArchive(filename)) if (!SFileOpenPatchArchive(localeMpqHandle, filename, itr->second.second ? itr->second.second : "", 0)) printf("Error open patch archive: %s\n\n", filename); } }
void pushUpdate(const DataPackage& p) { NodeMap::iterator f = nodeMap.find(p.node.get()); if(f != nodeMap.end()) { *f->second = p; } else { updates.push_back(p); Updates::iterator& last = nodeMap[p.node.get()] = updates.end(); --last; } }
void LoadBaseMPQFiles() { char filename[512]; HANDLE worldMpqHandle; printf("Loaded MPQ files for map extraction:\n"); for (int i = 1; i <= WORLD_COUNT; i++) { sprintf(filename, "%s/Data/World%s.MPQ", input_path, (i == 2 ? "2" : "")); printf("%s\n", filename); if (!OpenArchive(filename, &worldMpqHandle)) { printf("Error open archive: %s\n\n", filename); return; } } for (int i = 1; i <= EXPANSION_COUNT; i++) { sprintf(filename, "%s/Data/Expansion%i.MPQ", input_path, i); printf("%s\n", filename); if (!OpenArchive(filename, &worldMpqHandle)) { printf("Error open archive: %s\n\n", filename); return; } } // prepare sorted list patches in Data root Updates updates; // now update to newer view, root -base AppendPatchMPQFilesToList(NULL, NULL, "base", updates); // now update to newer view, root -base AppendPatchMPQFilesToList(NULL, "base", NULL, updates); for (Updates::const_iterator itr = updates.begin(); itr != updates.end(); ++itr) { sprintf(filename, "%s/Data/%s", input_path, itr->second.first.c_str()); printf("%s\n", filename); if (!OpenArchive(filename, &worldMpqHandle)) { printf("Error open patch archive: %s\n\n", filename); return; } } }
void Persistent::update(Updates& updates) { for (Updates::iterator i = updates.begin(); i != updates.end(); i++) { UpdateQuery uq(i->first); uq.where(RawExpr(LITESQL_L("id_ = '") + toString(oldKey) + LITESQL_L("'"))); bool notEmpty = false; for (std::vector<std::pair<FieldType, LITESQL_String> >::iterator i2 = i->second.begin(); i2 != i->second.end(); i2++) { uq.set(i2->first, i2->second); notEmpty = true; } if (notEmpty) db->query(uq); } }
/// Push all pending updates to the conditions store void ConditionsManagerObject::pushUpdates() { Updates entries; { dd4hep_lock_t lock(m_updateLock); m_updatePool->popEntries(entries); } // Lock global pool so that no other updates happen in the meanwhile // which could kill the pool's containers dd4hep_lock_t lock(m_poolLock); for(Updates::const_iterator iov_iter=entries.begin(); iov_iter!=entries.end(); ++iov_iter) { typedef UpdatePool::ConditionEntries _E; const _E& ents = (*iov_iter).second; if ( !ents.empty() ) { for(_E::const_iterator j=ents.begin(); j != ents.end(); ++j) { (*j)->pool->insert(*j); } } } }
void Persistent::prepareUpdate(Updates& updates, LITESQL_String table) { if (updates.find(table) == updates.end()) { updates[table] = std::vector<std::pair<FieldType, LITESQL_String> >(); } }
void Persistent::prepareUpdate(Updates& updates, const string& table) { if (updates.find(table) == updates.end()) { updates[table] = vector<pair<FieldType, string> >(); } }