本文整理汇总了C++中QueueItemPtr::getPriority方法的典型用法代码示例。如果您正苦于以下问题:C++ QueueItemPtr::getPriority方法的具体用法?C++ QueueItemPtr::getPriority怎么用?C++ QueueItemPtr::getPriority使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueueItemPtr
的用法示例。
在下文中一共展示了QueueItemPtr::getPriority方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: compareFiles
int QueueFileUtils::compareFiles(const QueueItemPtr& a, const QueueItemPtr& b, int aPropertyName) noexcept {
switch (aPropertyName) {
case PROP_NAME: {
return Util::pathSort(a->getTarget(), b->getTarget());
}
case PROP_TYPE: {
return Util::stricmp(Util::getFileExt(a->getTarget()), Util::getFileExt(b->getTarget()));
}
case PROP_PRIORITY: {
COMPARE_FINISHED(a, b);
return compare(static_cast<int>(a->getPriority()), static_cast<int>(b->getPriority()));
}
case PROP_STATUS: {
COMPARE_FINISHED(a, b);
return compare(
a->getPercentage(QueueManager::getInstance()->getDownloadedBytes(a)),
b->getPercentage(QueueManager::getInstance()->getDownloadedBytes(b))
);
}
case PROP_SOURCES: {
COMPARE_FINISHED(a, b);
auto countsA = QueueManager::getInstance()->getSourceCount(a);
auto countsB = QueueManager::getInstance()->getSourceCount(b);
return QueueItemBase::SourceCount::compare(countsA, countsB);
}
default:
dcassert(0);
}
return 0;
}
示例2: getStringInfo
std::string QueueFileUtils::getStringInfo(const QueueItemPtr& aItem, int aPropertyName) noexcept {
switch (aPropertyName) {
case PROP_NAME: return getDisplayName(aItem);
case PROP_TARGET: return aItem->getTarget();
case PROP_TYPE: return Format::formatFileType(aItem->getTarget());
case PROP_STATUS: return formatDisplayStatus(aItem);
case PROP_PRIORITY: return AirUtil::getPrioText(aItem->getPriority());
case PROP_SOURCES: return formatFileSources(aItem);
case PROP_TTH: return aItem->getTTH().toBase32();
default: dcassert(0); return Util::emptyString;
}
}
示例3: getNumericInfo
double QueueFileUtils::getNumericInfo(const QueueItemPtr& aItem, int aPropertyName) noexcept {
switch (aPropertyName) {
case PROP_SIZE: return (double)aItem->getSize();
case PROP_BYTES_DOWNLOADED: return (double)QueueManager::getInstance()->getDownloadedBytes(aItem);
case PROP_PRIORITY: return (double)aItem->getPriority();
case PROP_TIME_ADDED: return (double)aItem->getTimeAdded();
case PROP_TIME_FINISHED: return (double)aItem->getTimeFinished();
case PROP_SPEED: return (double)QueueManager::getInstance()->getAverageSpeed(aItem);
case PROP_SECONDS_LEFT: return (double)QueueManager::getInstance()->getSecondsLeft(aItem);
case PROP_BUNDLE: return (double)(aItem->getBundle() ? aItem->getBundle()->getToken() : -1);
default: dcassert(0); return 0;
}
}
示例4: addQI
void UserQueue::addQI(QueueItemPtr& qi, const HintedUser& aUser, bool aIsBadSource /*false*/) noexcept{
if (qi->getPriority() == QueueItem::HIGHEST) {
auto& l = userPrioQueue[aUser.user];
l.insert(upper_bound(l.begin(), l.end(), qi, QueueItem::SizeSortOrder()), qi);
}
BundlePtr bundle = qi->getBundle();
if (bundle) {
aUser.user->addQueued(qi->getSize());
if (bundle->addUserQueue(qi, aUser, aIsBadSource)) {
addBundle(bundle, aUser);
} else {
dcassert(userBundleQueue.find(aUser.user) != userBundleQueue.end());
}
}
}
示例5: addQI
void UserQueue::addQI(QueueItemPtr& qi, const HintedUser& aUser, bool newBundle /*false*/, bool isBadSource /*false*/) {
if (qi->getPriority() == QueueItem::HIGHEST) {
auto& l = userPrioQueue[aUser.user];
l.insert(upper_bound(l.begin(), l.end(), qi, QueueItem::SizeSortOrder()), qi);
}
BundlePtr bundle = qi->getBundle();
if (bundle) {
if (bundle->addUserQueue(qi, aUser, isBadSource)) {
addBundle(bundle, aUser);
if (!newBundle) {
QueueManager::getInstance()->fire(QueueManagerListener::BundleSources(), bundle);
}
} else {
dcassert(userBundleQueue.find(aUser.user) != userBundleQueue.end());
}
}
}
示例6: removeQI
void UserQueue::removeQI(QueueItemPtr& qi, const UserPtr& aUser, bool removeRunning /*true*/, bool addBad /*false*/, bool fireSources /*false*/) {
if(removeRunning) {
qi->removeDownloads(aUser);
}
dcassert(qi->isSource(aUser));
BundlePtr bundle = qi->getBundle();
if (bundle) {
if (!bundle->isSource(aUser)) {
return;
}
if (qi->getBundle()->removeUserQueue(qi, aUser, addBad)) {
removeBundle(bundle, aUser);
if (fireSources) {
QueueManager::getInstance()->fire(QueueManagerListener::BundleSources(), bundle);
}
} else {
dcassert(userBundleQueue.find(aUser) != userBundleQueue.end());
}
}
if (qi->getPriority() == QueueItem::HIGHEST) {
auto j = userPrioQueue.find(aUser);
dcassert(j != userPrioQueue.end());
if (j == userPrioQueue.end()) {
return;
}
auto& l = j->second;
auto i = find(l.begin(), l.end(), qi);
dcassert(i != l.end());
if (i == l.end()) {
return;
}
l.erase(i);
if(l.empty()) {
userPrioQueue.erase(j);
}
}
}
示例7: removeQI
void UserQueue::removeQI(QueueItemPtr& qi, const UserPtr& aUser, bool removeRunning /*true*/, Flags::MaskType reason) noexcept{
if(removeRunning) {
qi->removeDownloads(aUser);
}
dcassert(qi->isSource(aUser));
BundlePtr bundle = qi->getBundle();
if (bundle) {
if (!bundle->isSource(aUser)) {
return;
}
aUser->removeQueued(qi->getSize());
if (qi->getBundle()->removeUserQueue(qi, aUser, reason)) {
removeBundle(bundle, aUser);
} else {
dcassert(userBundleQueue.find(aUser) != userBundleQueue.end());
}
}
if (qi->getPriority() == QueueItem::HIGHEST) {
auto j = userPrioQueue.find(aUser);
dcassert(j != userPrioQueue.end());
if (j == userPrioQueue.end()) {
return;
}
auto& l = j->second;
auto i = find(l.begin(), l.end(), qi);
dcassert(i != l.end());
if (i == l.end()) {
return;
}
l.erase(i);
if(l.empty()) {
userPrioQueue.erase(j);
}
}
}