本文整理汇总了C++中QueueItemPtr::getSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QueueItemPtr::getSize方法的具体用法?C++ QueueItemPtr::getSize怎么用?C++ QueueItemPtr::getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QueueItemPtr
的用法示例。
在下文中一共展示了QueueItemPtr::getSize方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: add
void FileQueue::add(QueueItemPtr& qi) noexcept {
if (!qi->isSet(QueueItem::FLAG_USER_LIST) && !qi->isSet(QueueItem::FLAG_CLIENT_VIEW) && !qi->isSet(QueueItem::FLAG_FINISHED)) {
dcassert(qi->getSize() >= 0);
queueSize += qi->getSize();
}
dcassert(queueSize >= 0);
queue.emplace(const_cast<string*>(&qi->getTarget()), qi);
tthIndex.emplace(const_cast<TTHValue*>(&qi->getTTH()), qi);
}
示例3:
pair<QueueItem::StringMap::const_iterator, bool> FileQueue::add(QueueItemPtr& qi) noexcept {
dcassert(queueSize >= 0);
auto ret = queue.emplace(const_cast<string*>(&qi->getTarget()), qi);
if (ret.second) {
tthIndex.emplace(const_cast<TTHValue*>(&qi->getTTH()), qi);
if (!qi->isSet(QueueItem::FLAG_USER_LIST) && !qi->isSet(QueueItem::FLAG_CLIENT_VIEW) && !qi->isSet(QueueItem::FLAG_FINISHED)) {
dcassert(qi->getSize() >= 0);
queueSize += qi->getSize();
}
}
return ret;
}
示例4: on
void ViewFileManager::on(QueueManagerListener::ItemAdded, const QueueItemPtr& aQI) noexcept {
if (!isViewedItem(aQI)) {
return;
}
auto file = createFile(aQI->getTarget(), aQI->getTTH(), aQI->isSet(QueueItem::FLAG_TEXT), false);
if (file) {
file->onAddedQueue(aQI->getTarget(), aQI->getSize());
}
}
示例5: remove
void FileQueue::remove(QueueItemPtr& qi) noexcept {
//TargetMap
auto f = queue.find(const_cast<string*>(&qi->getTarget()));
if (f != queue.end()) {
queue.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());
}
}
示例6: 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();
}
}
示例7: 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;
}
}
示例8: 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());
}
}
}
示例9: addQI
void UserQueue::addQI(QueueItemPtr& qi, const HintedUser& aUser, bool newBundle /*false*/, bool isBadSource /*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, isBadSource)) {
addBundle(bundle, aUser);
if (!newBundle) {
QueueManager::getInstance()->fire(QueueManagerListener::BundleSources(), bundle);
}
} else {
dcassert(userBundleQueue.find(aUser.user) != userBundleQueue.end());
}
}
}
示例10: 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);
}
}
}
示例11: on
void FinishedManager::on(QueueManagerListener::Finished, const QueueItemPtr& qi, const string&, const HintedUser& aUser, int64_t aSpeed) noexcept {
if(!qi->isSet(QueueItem::FLAG_USER_LIST) || SETTING(LOG_FILELIST_TRANSFERS)) {
FinishedItemPtr item = new FinishedItem(qi->getTarget(), aUser, qi->getSize(), static_cast<int64_t>(aSpeed), GET_TIME(), qi->getTTH().toBase32());
{
Lock l(cs);
downloads.push_back(item);
}
fire(FinishedManagerListener::AddedDl(), item);
if(SETTING(SYSTEM_SHOW_DOWNLOADS)) {
size_t BUF_SIZE = STRING(FINISHED_DOWNLOAD).size() + UNC_MAX_PATH + 128;
char* buf = new char[BUF_SIZE];
snprintf(buf, BUF_SIZE, CSTRING(FINISHED_DOWNLOAD), Util::getFileName(qi->getTarget()).c_str(),
Util::toString(ClientManager::getInstance()->getNicks(aUser)).c_str());
LogManager::getInstance()->message(buf, LogManager::LOG_INFO);
delete[] buf;
}
}
}
示例12: on
void FinishedManager::on(QueueManagerListener::Finished, const QueueItemPtr& qi, const string&, const DownloadPtr& p_download) noexcept
{
if (!ClientManager::isShutdown())
{
const bool isFile = !qi->isAnySet(QueueItem::FLAG_USER_LIST | QueueItem::FLAG_DCLST_LIST | QueueItem::FLAG_USER_GET_IP);
if (isFile)
{
PLAY_SOUND(SOUND_FINISHFILE);
}
if (isFile || (qi->isAnySet(QueueItem::FLAG_USER_LIST | QueueItem::FLAG_DCLST_LIST) && BOOLSETTING(LOG_FILELIST_TRANSFERS)))
{
auto item = std::make_shared<FinishedItem>(qi->getTarget(), p_download->getHintedUser(),
qi->getSize(), p_download->getRunningAverage(),
GET_TIME(), qi->getTTH(), p_download->getActual(), p_download->getUser()->getIPAsString());
if (SETTING(DB_LOG_FINISHED_DOWNLOADS))
{
CFlylinkDBManager::getInstance()->save_transfer_history(false, e_TransferDownload, item);
}
rotation_items(item, e_Download);
fly_fire2(FinishedManagerListener::AddedDl(), item, false);
log(p_download->getUser()->getCID(), qi->getTarget(), STRING(FINISHED_DOWNLOAD));
}
}
}