void RRDVisAnalyzer::analyzeFlow(const Flow* flow) { if (firstFlow) { initDatabases((uint64_t)(((uint64_t)flow->flowStart / 1000) / 60) * 60); firstFlow = false; } static char output[16]; lpm_lookup(tree, flow->srcIP, output); // VERMONT does not use the timestamps properly to determine which direction of the // flow did start the flow. It is therefore possible that the reverse flow direction // actually started the flow. Hence, we need to check this manually. if (flow->flowStart < flow->revFlowStart) { updateEntry(output, flow->flowStart, flow->flowEnd, flow->proto, flow->revBytes, flow->revPackets, flow->bytes, flow->packets); } else { updateEntry(output, flow->revFlowStart, flow->revFlowEnd, flow->proto, flow->bytes, flow->packets, flow->revBytes, flow->revPackets); } lpm_lookup(tree, flow->dstIP, output); if (flow->flowStart < flow->revFlowStart) { updateEntry(output, flow->revFlowStart, flow->revFlowEnd, flow->proto, flow->bytes, flow->packets, flow->revBytes, flow->revPackets); } else { updateEntry(output, flow->flowStart, flow->flowEnd, flow->proto, flow->revBytes, flow->revPackets, flow->bytes, flow->packets); } }
void refreshName(const std::vector<unsigned char> &inName) { LOCK(cs_main); NameTableEntry nameObj(ValtypeToString(inName), std::string(""), NameTableEntry::NAME_NON_EXISTING); CNameData data; { LOCK (cs_main); if (!pcoinsTip->GetName (inName, data)) { LogPrintf ("name not found: '%s'\n", ValtypeToString (inName).c_str()); return; } nameObj = NameTableEntry(ValtypeToString(inName), ValtypeToString(data.getValue ()), data.getHeight ()); } // Find name in model QList<NameTableEntry>::iterator lower = qLowerBound( cachedNameTable.begin(), cachedNameTable.end(), nameObj.name, NameTableEntryLessThan()); QList<NameTableEntry>::iterator upper = qUpperBound( cachedNameTable.begin(), cachedNameTable.end(), nameObj.name, NameTableEntryLessThan()); bool inModel = (lower != upper); if (inModel) { // In model - update or delete if (nameObj.nHeight != NameTableEntry::NAME_NON_EXISTING) { LogPrintf ("refreshName result : %s - refreshed in the table\n", qPrintable(nameObj.name)); updateEntry(nameObj.name, nameObj.value, nameObj.nHeight, CT_UPDATED); } else { LogPrintf("refreshName result : %s - deleted from the table\n", qPrintable(nameObj.name)); updateEntry(nameObj.name, nameObj.value, nameObj.nHeight, CT_DELETED); } } else { // Not in model - add or do nothing if (nameObj.nHeight != NameTableEntry::NAME_NON_EXISTING) { LogPrintf("refreshName result : %s - added to the table\n", qPrintable(nameObj.name)); updateEntry(nameObj.name, nameObj.value, nameObj.nHeight, CT_NEW); } else { LogPrintf("refreshName result : %s - ignored (not in the table)\n", qPrintable(nameObj.name)); } } }
/** * Stores the given value under the given name and queues it for * transmission to the server. * * @param name The name under which to store the given value. * @param type The type of the given value. * @param value The value to store. * @throws TableKeyExistsWithDifferentTypeException Thrown if an * entry already exists with the given name and is of a different type. */ void AbstractNetworkTableEntryStore::PutOutgoing(std::string& name, NetworkTableEntryType* type, EntryValue value){ { NTSynchronized sync(LOCK); std::map<std::string, NetworkTableEntry*>::iterator index = namedEntries.find(name); NetworkTableEntry* tableEntry; if(index == namedEntries.end())//if the name does not exist in the current entries { tableEntry = new NetworkTableEntry(name, type, value); if(addEntry(tableEntry)) { tableEntry->FireListener(listenerManager); outgoingReceiver->offerOutgoingAssignment(tableEntry); } } else { tableEntry = index->second; if(tableEntry->GetType()->id != type->id){ throw TableKeyExistsWithDifferentTypeException(name, tableEntry->GetType()); } EntryValue oldValue = tableEntry->GetValue(); if(!type->areEqual(value, oldValue)){ if(updateEntry(tableEntry, (SequenceNumber)(tableEntry->GetSequenceNumber() + 1), value)){ outgoingReceiver->offerOutgoingUpdate(tableEntry); } tableEntry->FireListener(listenerManager); } } } }
void AbstractNetworkTableEntryStore::offerIncomingUpdate(NetworkTableEntry* entry, SequenceNumber squenceNumber, EntryValue value){ { NTSynchronized sync(LOCK); if(updateEntry(entry, squenceNumber, value)){ entry->FireListener(listenerManager); incomingReceiver->offerOutgoingUpdate(entry); } } }
void AbstractNetworkTableEntryStore::PutOutgoing(NetworkTableEntry* tableEntry, EntryValue value){ { Synchronized sync(LOCK); if(updateEntry(tableEntry, (SequenceNumber)(tableEntry->GetSequenceNumber() + 1), value)){ outgoingReceiver->offerOutgoingUpdate(tableEntry); } tableEntry->FireListener(listenerManager); } }
/* Decides what to do with incoming UDP message */ void handleMessage(char *buf,ssize_t l) { char *p,*pp; char hostname[128]; char dbname[128]; char task[1024]; char stats[] = "stats/"; int r; struct pfstats incoming; /* db host count cpu cpusq real realsq eventdescription */ const char msgformat[]="%127s %127s %ld %lf %lf %lf %lf %1023[^\n]"; buf[l]=0; pp=buf; while((p=strsep(&pp,"\r\n"))) { if (p[0]=='\0') continue; if (!strcmp("-truncate",p)) { truncatedb(); return; } bzero(&incoming,sizeof(incoming)); r=sscanf(p,msgformat,(char *)&dbname,(char *)&hostname, &incoming.pf_count,&incoming.pf_cpu,&incoming.pf_cpu_sq, &incoming.pf_real,&incoming.pf_real_sq, (char *)&task); if (r<7) continue; // Update the DB-specific entry updateEntry(dbname, hostname, task, &incoming); // Update the aggregate entry if (!strncmp(dbname, stats, sizeof(stats) - 1)) { updateEntry("stats/all", "-", task, &incoming); } else { updateEntry("all", "-", task, &incoming); } } }
void LadderList::activateFrom(const LadderList * currentLadder_) { const LList* currentList = ¤tLadder_->ladder; for (LList::const_iterator lit(currentList->begin()); lit!=currentList->end(); lit++) { const LadderReferencedObject& referencedObject = lit->getReferencedObject(); updateEntry(lit->getUid(),lit->getPrimary(),lit->getSecondary(),lit->getTertiary(),referencedObject); referencedObject.activate(ladderKey); } return; }
void LLVOCache::removeFromCache(HeaderEntryInfo* entry) { if(mReadOnly) { llwarns << "Not removing cache for handle " << entry->mHandle << ": Cache is currently in read-only mode." << llendl; return ; } std::string filename; getObjectCacheFilename(entry->mHandle, filename); LLAPRFile::remove(filename, mLocalAPRFilePoolp); entry->mTime = INVALID_TIME ; updateEntry(entry) ; //update the head file. }
/** * Methode qui sauvegarde un document valider dans la base de données * @return true si l'enregistrement n'a pas poser de probleme, false sinon */ bool ValidDocument::save(){ QSqlDatabase base = QSqlDatabase::database(); bool retour=false; if(id==-1){ retour=createEntry(); } else{ retour=updateEntry(); } base.commit(); return retour; }
void AbstractNetworkTableEntryStore::PutOutgoing(NetworkTableEntry* tableEntry, EntryValue value){ { NTSynchronized sync(LOCK); NetworkTableEntryType* type = tableEntry->GetType(); EntryValue oldValue = tableEntry->GetValue(); if(!type->areEqual(value, oldValue)){ if(updateEntry(tableEntry, (SequenceNumber)(tableEntry->GetSequenceNumber() + 1), value)){ outgoingReceiver->offerOutgoingUpdate(tableEntry); } tableEntry->FireListener(listenerManager); } } }
void SKKEntry::SetEntry(const std::string& entry) { normal_entry_ = entry; if(!normal_entry_.empty()) { unsigned last_index = normal_entry_.size() - 1; // 見出し語末尾の prefix を取り除く(ex. "かk" → "か") if(normal_entry_.find_last_of(prefix_) == last_index) { normal_entry_.erase(last_index); } } updateEntry(); }
int AddressTableModel::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QAbstractTableModel::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: defaultAddressChanged((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 1: updateEntry((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])),(*reinterpret_cast< bool(*)>(_a[3])),(*reinterpret_cast< int(*)>(_a[4]))); break; default: ; } _id -= 2; } return _id; }
QStringList SyncProcess::updateDir(const QString & source, const QString & destination) { QDirIterator it(source, QDirIterator::Subdirectories); while (!closed && it.hasNext()) { QEventLoop loop; QTimer::singleShot(10, &loop, SLOT(quit())); loop.exec(); index++; progress->setInfo(tr("%1/%2 files").arg(index).arg(count)); progress->setValue(index); QString result = updateEntry(it.next(), source, destination); if (!result.isEmpty()) { errors << result; } } return errors; }
void ImageEntry::setImageData(const QString& path, const ImageSize& displaySize, const ImageSize& printSize, bool useDisplaySizeForPrinting) { if (path != m_imagePath) { m_imageWatcher->removePath(m_imagePath); m_imageWatcher->addPath(path); m_imagePath = path; } m_displaySize = displaySize; m_printSize = printSize; m_useDisplaySizeForPrinting = useDisplaySizeForPrinting; updateEntry(); }
void LayerCache::addInstance(Instance* instance) { if(m_instance_map.find(instance)!=m_instance_map.end()) { throw new Duplicate(instance->getId()); } RenderItem item; Entry entry; item.instance = instance; m_instances.push_back(item); m_instance_map[instance] = m_instances.size() - 1; entry.node = 0; entry.instance_index = m_instances.size() - 1; entry.entry_index = m_entries.size(); m_entries.push_back(entry); updateEntry(m_entries.back()); m_needupdate = true; }
///////////////////////////////////////////////////////////////////////////// // Public Methods ///////////////////////////////////////////////////////////////////////////// void CDlgMktDepth::updateMktDepth( int id, int position, CString marketMaker, int operation, int side, double price, int size) { if (!m_active) return; if (operation == OPERATION_INSERT ) { addEntry( (side == SIDE_BID ? &m_listBid : &m_listAsk), position, marketMaker, price, size); } else if (operation == OPERATION_UPDATE ) { updateEntry( (side == SIDE_BID ? &m_listBid : &m_listAsk), position, marketMaker, price, size); } else if (operation == OPERATION_DELETE) { deleteEntry( (side == SIDE_BID ? &m_listBid : &m_listAsk), position); } }
ImageEntry::ImageEntry(Worksheet* worksheet) : WorksheetEntry(worksheet) { m_imageItem = 0; m_textItem = new WorksheetTextItem(this); m_imageWatcher = new QFileSystemWatcher(this); m_displaySize.width = -1; m_displaySize.height = -1; m_printSize.width = -1; m_printSize.height = -1; m_displaySize.widthUnit = ImageSize::Auto; m_displaySize.heightUnit = ImageSize::Auto; m_printSize.widthUnit = ImageSize::Auto; m_printSize.heightUnit = ImageSize::Auto; m_useDisplaySizeForPrinting = true; connect(m_imageWatcher, &QFileSystemWatcher::fileChanged, this, &ImageEntry::updateEntry); setFlag(QGraphicsItem::ItemIsFocusable); updateEntry(); startConfigDialog(); }
void AccountListWidget::updateEntries( const QModelIndex& topLeft, const QModelIndex& bottomRight ) { for( int row = topLeft.row(); row <= bottomRight.row(); ++row ) { QPersistentModelIndex idx( m_model->index( row, 0 ) ); int newCount = idx.data( Tomahawk::Accounts::AccountModel::ChildrenOfFactoryRole ) .value< QList< Tomahawk::Accounts::Account* > >().count(); if( m_entries.value( idx ).count() == newCount ) { updateEntry( idx ); } else { removeEntries( idx.parent(), idx.row(), idx.row() ); insertEntries( idx.parent(), idx.row(), idx.row() ); } } }
bool Dynamic::save(const Entry &e) { if (e.name.isEmpty()) { return false; } QString string; QTextStream str(&string); if (e.ratingFrom!=0 || e.ratingTo!=0) { str << constRatingKey << constKeyValSep << e.ratingFrom << constRangeSep << e.ratingTo<< '\n'; } foreach (const Rule &rule, e.rules) { if (!rule.isEmpty()) { str << constRuleKey << '\n'; Rule::ConstIterator it(rule.constBegin()); Rule::ConstIterator end(rule.constEnd()); for (; it!=end; ++it) { str << it.key() << constKeyValSep << it.value() << '\n'; } } } if (isRemote()) { if (sendCommand(Save, QStringList() << e.name << string)) { currentSave=e; return true; } return false; } QFile f(Utils::dataDir(constDir, true)+e.name+constExtension); if (f.open(QIODevice::WriteOnly|QIODevice::Text)) { QTextStream out(&f); out.setCodec("UTF-8"); out << string; updateEntry(e); return true; } return false; }
void ImageEntry::setContent(const QDomElement& content, const KZip& file) { Q_UNUSED(file); static QStringList unitNames; if (unitNames.isEmpty()) unitNames << QLatin1String("(auto)") << QLatin1String("px") << QLatin1String("%"); QDomElement pathElement = content.firstChildElement(QLatin1String("Path")); QDomElement displayElement = content.firstChildElement(QLatin1String("Display")); QDomElement printElement = content.firstChildElement(QLatin1String("Print")); m_imagePath = pathElement.text(); m_displaySize.width = displayElement.attribute(QLatin1String("width")).toDouble(); m_displaySize.height = displayElement.attribute(QLatin1String("height")).toDouble(); m_displaySize.widthUnit = unitNames.indexOf(displayElement.attribute(QLatin1String("widthUnit"))); m_displaySize.heightUnit = unitNames.indexOf(displayElement.attribute(QLatin1String("heightUnit"))); m_useDisplaySizeForPrinting = printElement.attribute(QLatin1String("useDisplaySize")).toInt(); m_printSize.width = printElement.attribute(QLatin1String("width")).toDouble(); m_printSize.height = printElement.attribute(QLatin1String("height")).toDouble(); m_printSize.widthUnit = unitNames.indexOf(printElement.attribute(QLatin1String("widthUnit"))); m_printSize.heightUnit = unitNames.indexOf(printElement.attribute(QLatin1String("heightUnit"))); updateEntry(); }
HistoryContentsWidget::HistoryContentsWidget(Window *window) : ContentsWidget(window), m_model(new QStandardItemModel(this)), m_isLoading(true), m_ui(new Ui::HistoryContentsWidget) { m_ui->setupUi(this); QStringList groups; groups << tr("Today") << tr("Yesterday") << tr("Earlier This Week") << tr("Previous Week") << tr("Earlier This Month") << tr("Earlier This Year") << tr("Older"); for (int i = 0; i < groups.count(); ++i) { m_model->appendRow(new QStandardItem(Utils::getIcon(QLatin1String("inode-directory")), groups.at(i))); } QStringList labels; labels << tr("Address") << tr("Title") << tr("Date"); m_model->setHorizontalHeaderLabels(labels); m_model->setSortRole(Qt::DisplayRole); m_ui->historyView->setModel(m_model); m_ui->historyView->setItemDelegate(new ItemDelegate(this)); m_ui->historyView->header()->setTextElideMode(Qt::ElideRight); m_ui->historyView->header()->setSectionResizeMode(0, QHeaderView::Stretch); m_ui->historyView->expand(m_model->index(0, 0)); QTimer::singleShot(100, this, SLOT(populateEntries())); connect(HistoryManager::getInstance(), SIGNAL(cleared()), this, SLOT(populateEntries())); connect(HistoryManager::getInstance(), SIGNAL(entryAdded(qint64)), this, SLOT(addEntry(qint64))); connect(HistoryManager::getInstance(), SIGNAL(entryUpdated(qint64)), this, SLOT(updateEntry(qint64))); connect(HistoryManager::getInstance(), SIGNAL(entryRemoved(qint64)), this, SLOT(removeEntry(qint64))); connect(HistoryManager::getInstance(), SIGNAL(dayChanged()), this, SLOT(populateEntries())); connect(m_ui->filterLineEdit, SIGNAL(textChanged(QString)), this, SLOT(filterHistory(QString))); connect(m_ui->historyView, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openEntry(QModelIndex))); connect(m_ui->historyView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(showContextMenu(QPoint))); }
void DelayQueue::updateEntry(long tokenToFind, DelayInterval newDelay) { DelayQueueEntry* entry = findEntryByToken(tokenToFind); updateEntry(entry, newDelay); }
void LayerCache::updateInstance(Instance* instance) { Entry& entry = m_entries[m_instance_map[instance]]; updateEntry(entry); m_needupdate = true; }
void SKKEntry::SetOkuri(const std::string& prefix, const std::string& kana) { prefix_ = prefix; kana_ = kana; updateEntry(); }
void fileModified() { updateEntry(); }
void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) { llassert_always(mInitialized); if(mReadOnly) { return ; } HeaderEntryInfo* entry; handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ; if(iter == mHandleEntryMap.end()) //new entry { if(mNumEntries >= mCacheSize) { purgeEntries() ; } entry = new HeaderEntryInfo(); entry->mHandle = handle ; entry->mTime = time(NULL) ; entry->mIndex = mNumEntries++ ; mHeaderEntryQueue.insert(entry) ; mHandleEntryMap[handle] = entry ; } else { entry = iter->second ; entry->mTime = time(NULL) ; //resort mHeaderEntryQueue.erase(entry) ; mHeaderEntryQueue.insert(entry) ; } //update cache header if(!updateEntry(entry)) { return ; //update failed. } if(!dirty_cache) { return ; //nothing changed, no need to update. } //write to cache file std::string filename; getObjectCacheFilename(handle, filename); LLAPRFile* apr_file = new LLAPRFile(filename, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp); if(!checkWrite(apr_file, (void*)id.mData, UUID_BYTES)) { return ; } S32 num_entries = cache_entry_map.size() ; if(!checkWrite(apr_file, &num_entries, sizeof(S32))) { return ; } for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); iter != cache_entry_map.end(); ++iter) { if(!iter->second->writeToFile(apr_file)) { //failed delete apr_file ; removeCache() ; return ; } } delete apr_file ; return ; }
void LLVOCache::writeToCache(U64 handle, const LLUUID& id, const LLVOCacheEntry::vocache_entry_map_t& cache_entry_map, BOOL dirty_cache) { if(!mEnabled) { llwarns << "Not writing cache for handle " << handle << "): Cache is currently disabled." << llendl; return ; } llassert_always(mInitialized); if(mReadOnly) { llwarns << "Not writing cache for handle " << handle << "): Cache is currently in read-only mode." << llendl; return ; } HeaderEntryInfo* entry; handle_entry_map_t::iterator iter = mHandleEntryMap.find(handle) ; if(iter == mHandleEntryMap.end()) //new entry { if(mNumEntries >= mCacheSize - 1) { purgeEntries(mCacheSize - 1) ; } entry = new HeaderEntryInfo(); entry->mHandle = handle ; entry->mTime = time(NULL) ; entry->mIndex = mNumEntries++; mHeaderEntryQueue.insert(entry) ; mHandleEntryMap[handle] = entry ; } else { // Update access time. entry = iter->second ; //resort mHeaderEntryQueue.erase(entry) ; entry->mTime = time(NULL) ; mHeaderEntryQueue.insert(entry) ; } //update cache header if(!updateEntry(entry)) { llwarns << "Failed to update cache header index " << entry->mIndex << ". handle = " << handle << llendl; return ; //update failed. } if(!dirty_cache) { llwarns << "Skipping write to cache for handle " << handle << ": cache not dirty" << llendl; return ; //nothing changed, no need to update. } //write to cache file bool success = true ; { std::string filename; getObjectCacheFilename(handle, filename); LLAPRFile apr_file(filename, APR_CREATE|APR_WRITE|APR_BINARY, mLocalAPRFilePoolp); success = check_write(&apr_file, (void*)id.mData, UUID_BYTES) ; if(success) { S32 num_entries = cache_entry_map.size() ; success = check_write(&apr_file, &num_entries, sizeof(S32)); for (LLVOCacheEntry::vocache_entry_map_t::const_iterator iter = cache_entry_map.begin(); success && iter != cache_entry_map.end(); ++iter) { success = iter->second->writeToFile(&apr_file) ; } } } if(!success) { removeEntry(entry) ; } return ; }
/**Function******************************************************************** Synopsis [Exact variable ordering algorithm.] Description [Exact variable ordering algorithm. Finds an optimum order for the variables between lower and upper. Returns 1 if successful; 0 otherwise.] SideEffects [None] SeeAlso [] ******************************************************************************/ int cuddExact( DdManager * table, int lower, int upper) { int k, i, j; int maxBinomial, oldSubsets, newSubsets; int subsetCost; int size; /* number of variables to be reordered */ int unused, nvars, level, result; int upperBound, lowerBound, cost; int roots; char *mask = NULL; DdHalfWord *symmInfo = NULL; DdHalfWord **newOrder = NULL; DdHalfWord **oldOrder = NULL; int *newCost = NULL; int *oldCost = NULL; DdHalfWord **tmpOrder; int *tmpCost; DdHalfWord *bestOrder = NULL; DdHalfWord *order; #ifdef DD_STATS int ddTotalSubsets; #endif /* Restrict the range to be reordered by excluding unused variables ** at the two ends. */ while (table->subtables[lower].keys == 1 && table->vars[table->invperm[lower]]->ref == 1 && lower < upper) lower++; while (table->subtables[upper].keys == 1 && table->vars[table->invperm[upper]]->ref == 1 && lower < upper) upper--; if (lower == upper) return(1); /* trivial problem */ /* Apply symmetric sifting to get a good upper bound and to extract ** symmetry information. */ result = cuddSymmSiftingConv(table,lower,upper); if (result == 0) goto cuddExactOutOfMem; #ifdef DD_STATS (void) fprintf(table->out,"\n"); ddTotalShuffles = 0; ddTotalSubsets = 0; #endif /* Initialization. */ nvars = table->size; size = upper - lower + 1; /* Count unused variable among those to be reordered. This is only ** used to compute maxBinomial. */ unused = 0; for (i = lower + 1; i < upper; i++) { if (table->subtables[i].keys == 1 && table->vars[table->invperm[i]]->ref == 1) unused++; } /* Find the maximum number of subsets we may have to store. */ maxBinomial = getMaxBinomial(size - unused); if (maxBinomial == -1) goto cuddExactOutOfMem; newOrder = getMatrix(maxBinomial, size); if (newOrder == NULL) goto cuddExactOutOfMem; newCost = ALLOC(int, maxBinomial); if (newCost == NULL) goto cuddExactOutOfMem; oldOrder = getMatrix(maxBinomial, size); if (oldOrder == NULL) goto cuddExactOutOfMem; oldCost = ALLOC(int, maxBinomial); if (oldCost == NULL) goto cuddExactOutOfMem; bestOrder = ALLOC(DdHalfWord, size); if (bestOrder == NULL) goto cuddExactOutOfMem; mask = ALLOC(char, nvars); if (mask == NULL) goto cuddExactOutOfMem; symmInfo = initSymmInfo(table, lower, upper); if (symmInfo == NULL) goto cuddExactOutOfMem; roots = ddCountRoots(table, lower, upper); /* Initialize the old order matrix for the empty subset and the best ** order to the current order. The cost for the empty subset includes ** the cost of the levels between upper and the constants. These levels ** are not going to change. Hence, we count them only once. */ oldSubsets = 1; for (i = 0; i < size; i++) { oldOrder[0][i] = bestOrder[i] = (DdHalfWord) table->invperm[i+lower]; } subsetCost = table->constants.keys; for (i = upper + 1; i < nvars; i++) subsetCost += getLevelKeys(table,i); oldCost[0] = subsetCost; /* The upper bound is initialized to the current size of the BDDs. */ upperBound = table->keys - table->isolated; /* Now consider subsets of increasing size. */ for (k = 1; k <= size; k++) { #if DD_STATS (void) fprintf(table->out,"Processing subsets of size %d\n", k); fflush(table->out); #endif newSubsets = 0; level = size - k; /* offset of first bottom variable */ for (i = 0; i < oldSubsets; i++) { /* for each subset of size k-1 */ order = oldOrder[i]; cost = oldCost[i]; lowerBound = computeLB(table, order, roots, cost, lower, upper, level); if (lowerBound >= upperBound) continue; /* Impose new order. */ result = ddShuffle(table, order, lower, upper); if (result == 0) goto cuddExactOutOfMem; upperBound = updateUB(table,upperBound,bestOrder,lower,upper); /* For each top bottom variable. */ for (j = level; j >= 0; j--) { /* Skip unused variables. */ if (table->subtables[j+lower-1].keys == 1 && table->vars[table->invperm[j+lower-1]]->ref == 1) continue; /* Find cost under this order. */ subsetCost = cost + getLevelKeys(table, lower + level); newSubsets = updateEntry(table, order, level, subsetCost, newOrder, newCost, newSubsets, mask, lower, upper); if (j == 0) break; if (checkSymmInfo(table, symmInfo, order[j-1], level) == 0) continue; pushDown(order,j-1,level); /* Impose new order. */ result = ddShuffle(table, order, lower, upper); if (result == 0) goto cuddExactOutOfMem; upperBound = updateUB(table,upperBound,bestOrder,lower,upper); } /* for each bottom variable */ } /* for each subset of size k */ /* New orders become old orders in preparation for next iteration. */ tmpOrder = oldOrder; tmpCost = oldCost; oldOrder = newOrder; oldCost = newCost; newOrder = tmpOrder; newCost = tmpCost; #ifdef DD_STATS ddTotalSubsets += newSubsets; #endif oldSubsets = newSubsets; } result = ddShuffle(table, bestOrder, lower, upper); if (result == 0) goto cuddExactOutOfMem; #ifdef DD_STATS #ifdef DD_VERBOSE (void) fprintf(table->out,"\n"); #endif (void) fprintf(table->out,"#:S_EXACT %8d: total subsets\n", ddTotalSubsets); (void) fprintf(table->out,"#:H_EXACT %8d: total shuffles", ddTotalShuffles); #endif freeMatrix(newOrder); freeMatrix(oldOrder); FREE(bestOrder); FREE(oldCost); FREE(newCost); FREE(symmInfo); FREE(mask); return(1); cuddExactOutOfMem: if (newOrder != NULL) freeMatrix(newOrder); if (oldOrder != NULL) freeMatrix(oldOrder); if (bestOrder != NULL) FREE(bestOrder); if (oldCost != NULL) FREE(oldCost); if (newCost != NULL) FREE(newCost); if (symmInfo != NULL) FREE(symmInfo); if (mask != NULL) FREE(mask); table->errorCode = CUDD_MEMORY_OUT; return(0); } /* end of cuddExact */
void LayerCache::fullUpdate() { for(unsigned i=0; i!=m_entries.size(); ++i) { updateEntry(m_entries[i]); } }
void LayerCache::update(Camera::Transform transform, RenderList& renderlist) { const double OVERDRAW = 2.5; renderlist.clear(); m_needupdate = false; if(!m_layer->areInstancesVisible()) { FL_DBG(_log, "Layer instances hidden"); return; } bool isWarped = transform == Camera::WarpedTransform; if( isWarped ) { fullUpdate(); } Rect viewport = m_camera->getViewPort(); Rect screen_viewport = viewport; double zoom = m_camera->getZoom(); DoublePoint3D viewport_a = m_camera->screenToVirtualScreen(Point3D(viewport.x, viewport.y)); DoublePoint3D viewport_b = m_camera->screenToVirtualScreen(Point3D(viewport.right(), viewport.bottom())); viewport.x = static_cast<int32_t>(std::min(viewport_a.x, viewport_b.x)); viewport.y = static_cast<int32_t>(std::min(viewport_a.y, viewport_b.y)); viewport.w = static_cast<int32_t>(std::max(viewport_a.x, viewport_b.x) - viewport.x); viewport.h = static_cast<int32_t>(std::max(viewport_a.y, viewport_b.y) - viewport.y); uint8_t layer_trans = m_layer->getLayerTransparency(); double zmin = 0.0, zmax = 0.0; // FL_LOG(_log, LMsg("camera-update viewport") << viewport); std::vector<int32_t> index_list; collect(viewport, index_list); for(unsigned i=0; i!=index_list.size(); ++i) { Entry& entry = m_entries[index_list[i]]; // NOTE // An update is forced if the item has an animation/action. // This update only happens if it is _already_ included in the viewport // Nevertheless: Moving instances - which might move into the viewport will be updated // By the layer change listener. if(entry.force_update || !isWarped) { updateEntry(entry); } RenderItem& item = m_instances[entry.instance_index]; InstanceVisual* visual = item.instance->getVisual<InstanceVisual>(); bool visible = (visual->isVisible() != 0); uint8_t instance_trans = visual->getTransparency(); if(!item.image || !visible || (instance_trans == 255 && layer_trans == 0) || (instance_trans == 0 && layer_trans == 255)) { continue; } if(layer_trans != 0) { if(instance_trans != 0) { uint8_t calc_trans = layer_trans - instance_trans; if(calc_trans >= 0) { instance_trans = calc_trans; } else { instance_trans = 0; } } else { instance_trans = layer_trans; } } Point3D screen_point = m_camera->virtualScreenToScreen(item.screenpoint); // NOTE: // One would expect this to be necessary here, // however it works the same without, sofar // m_camera->calculateZValue(screen_point); // item.screenpoint.z = -screen_point.z; item.dimensions.x = screen_point.x; item.dimensions.y = screen_point.y; item.dimensions.w = item.bbox.w; item.dimensions.h = item.bbox.h; item.transparency = 255 - instance_trans; if (zoom != 1.0) { // NOTE: Due to image alignment, there is additional additions on image dimensions // There's probabaly some better solution for this, but works "good enough" for now. // In case additions are removed, gaps appear between tiles. item.dimensions.w = unsigned(double(item.bbox.w) * zoom + OVERDRAW); item.dimensions.h = unsigned(double(item.bbox.h) * zoom + OVERDRAW); } if (!m_need_sorting) { zmin = std::min(zmin, item.screenpoint.z); zmax = std::max(zmax, item.screenpoint.z); } if(item.dimensions.intersects(screen_viewport)) { renderlist.push_back(&item); } } if (m_need_sorting) { InstanceDistanceSort ids; std::stable_sort(renderlist.begin(), renderlist.end(), ids); } else { zmin -= 0.5; zmax += 0.5; // We want to put every z value in [-10,10] range. // To do it, we simply solve // { y1 = a*x1 + b // { y2 = a*x2 + b // where [y1,y2]' = [-10,10]' is required z range, // and [x1,x2]' is expected min,max z coords. double det = zmin - zmax; if (fabs(det) > FLT_EPSILON) { double det_a = -10.0 - 10.0; double det_b = 10.0 * zmin - (-10.0) * zmax; double a = static_cast<float>(det_a / det); double b = static_cast<float>(det_b / det); float estimate = sqrtf(static_cast<float>(renderlist.size())); float stack_delta = fabs(-10.0f - 10.0f) / estimate * 0.1f; RenderList::iterator it = renderlist.begin(); for ( ; it != renderlist.end(); ++it) { double& z = (*it)->screenpoint.z; z = a * z + b; InstanceVisual* vis = (*it)->instance->getVisual<InstanceVisual>(); z += vis->getStackPosition() * stack_delta; } } } // FL_LOG(_log, LMsg("camera-update ") << " N=" <<renderlist.size() << "/" << m_instances.size() << "/" << index_list.size()); }