本文整理汇总了C++中QueueItemPtr::getBundle方法的典型用法代码示例。如果您正苦于以下问题:C++ QueueItemPtr::getBundle方法的具体用法?C++ QueueItemPtr::getBundle怎么用?C++ QueueItemPtr::getBundle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueueItemPtr
的用法示例。
在下文中一共展示了QueueItemPtr::getBundle方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: removeBundleItem
void BundleQueue::removeBundleItem(QueueItemPtr& aQI, bool aDownloadFinished) noexcept {
dcassert(aQI->getBundle());
aQI->getBundle()->removeQueue(aQI, aDownloadFinished);
if (!aQI->getBundle()->isFileBundle()) {
forEachPath(aQI->getBundle(), aQI->getTarget(), [&](PathInfo& aInfo) {
if (aQI->isDownloaded()) {
aInfo.finishedFiles--;
} else {
aInfo.queuedFiles--;
}
if (!aDownloadFinished) {
aInfo.size -= aQI->getSize();
}
#ifdef _DEBUG
if (aInfo.queuedFiles == 0 && aInfo.finishedFiles == 0) {
dcassert(aInfo.size == 0);
}
dcassert(aInfo.size >= 0 && aInfo.finishedFiles >= 0 && aInfo.queuedFiles >= 0);
#endif
});
}
if (aDownloadFinished || !aQI->isDownloaded()) {
queueSize -= aQI->getSize();
dcassert(queueSize >= 0);
}
}
示例2: getDisplayName
string QueueFileUtils::getDisplayName(const QueueItemPtr& aItem) noexcept {
if (aItem->getBundle() && !aItem->getBundle()->isFileBundle()) {
return aItem->getTarget().substr(aItem->getBundle()->getTarget().size(), aItem->getTarget().size());
}
return aItem->getTargetFileName();
}
示例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: 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);
}
}
}
示例5: 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);
}
}
}
示例6: 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());
}
}
}
示例7: 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());
}
}
}
示例8: addBundleItem
void BundleQueue::addBundleItem(QueueItemPtr& aQI, BundlePtr& aBundle) noexcept {
dcassert(!aQI->getBundle());
aBundle->addQueue(aQI);
aQI->setBundle(aBundle);
if (!aBundle->isFileBundle()) {
forEachPath(aBundle, aQI->getTarget(), [&](PathInfo& aInfo) {
if (aQI->isDownloaded()) {
aInfo.finishedFiles++;
} else {
aInfo.queuedFiles++;
}
aInfo.size += aQI->getSize();
});
}
if (!aQI->isDownloaded()) {
queueSize += aQI->getSize();
}
}
示例9: remove
void FileQueue::remove(QueueItemPtr& qi) noexcept {
//TargetMap
auto f = pathQueue.find(const_cast<string*>(&qi->getTarget()));
if (f != pathQueue.end()) {
pathQueue.erase(f);
if (!qi->isSet(QueueItem::FLAG_USER_LIST) && (!qi->isSet(QueueItem::FLAG_FINISHED) || !qi->getBundle()) && !qi->isSet(QueueItem::FLAG_CLIENT_VIEW)) {
dcassert(qi->getSize() >= 0);
queueSize -= qi->getSize();
}
}
dcassert(queueSize >= 0);
//TTHIndex
auto s = tthIndex.equal_range(const_cast<TTHValue*>(&qi->getTTH()));
dcassert(s.first != s.second);
auto k = find(s | map_values, qi);
if (k.base() != s.second) {
tthIndex.erase(k.base());
}
// Tokens
tokenQueue.erase(qi->getToken());
}