当前位置: 首页>>代码示例>>C++>>正文


C++ QueueItemPtr类代码示例

本文整理汇总了C++中QueueItemPtr的典型用法代码示例。如果您正苦于以下问题:C++ QueueItemPtr类的具体用法?C++ QueueItemPtr怎么用?C++ QueueItemPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QueueItemPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: serializeFileProperty

	json QueueFileUtils::serializeFileProperty(const QueueItemPtr& aFile, int aPropertyName) noexcept {
		switch (aPropertyName) {
		case PROP_SOURCES:
		{
			auto c = QueueManager::getInstance()->getSourceCount(aFile);
			return Serializer::serializeSourceCount(c);
		}

		case PROP_STATUS:
		{
			return {
				{ "finished", aFile->isSet(QueueItem::FLAG_FINISHED) },
				{ "str", formatDisplayStatus(aFile) },
			};
		}
		case PROP_PRIORITY: {
			return Serializer::serializePriority(*aFile.get());
		}
		case PROP_TYPE:
		{
			return Serializer::serializeFileType(aFile->getTarget());
		}
		}

		dcassert(0);
		return nullptr;
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:27,代码来源:QueueFileUtils.cpp

示例2: getQueuedFile

int FileQueue::isFileQueued(const TTHValue& aTTH, const string& fileName) noexcept {
	QueueItemPtr qi = getQueuedFile(aTTH, fileName);
	if (qi) {
		return (qi->isFinished() ? 2 : 1);
	}
	return 0;
}
开发者ID:BackupTheBerlios,项目名称:airdc-svn,代码行数:7,代码来源:FileQueue.cpp

示例3: on

	void ViewFileManager::on(QueueManagerListener::ItemFinished, const QueueItemPtr& aQI, const string&, const HintedUser&, int64_t /*aSpeed*/) noexcept {
		if (!isViewedItem(aQI))
			return;

		auto file = getFile(aQI->getTTH());
		if (file) {
			file->onRemovedQueue(aQI->getTarget(), true);
			fire(ViewFileManagerListener::FileFinished(), file);
		}
	}
开发者ID:Nordanvind,项目名称:airgit,代码行数:10,代码来源:ViewFileManager.cpp

示例4: 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);
	}
}
开发者ID:pavel-pimenov,项目名称:airgit,代码行数:31,代码来源:BundleQueue.cpp

示例5: 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;
		}
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:12,代码来源:QueueFileUtils.cpp

示例6: formatDisplayStatus

	std::string QueueFileUtils::formatDisplayStatus(const QueueItemPtr& aItem) noexcept {
		if (aItem->isSet(QueueItem::FLAG_FINISHED)) {
			return STRING(FINISHED);
		} 
		
		auto percentage = aItem->getPercentage(QueueManager::getInstance()->getDownloadedBytes(aItem));
		if (aItem->isPausedPrio()) {
			return STRING_F(PAUSED_PCT, percentage);
		} else if (QueueManager::getInstance()->isWaiting(aItem)) {
			return STRING_F(WAITING_PCT, percentage);
		} else {
			return STRING_F(RUNNING_PCT, percentage);
		}
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:14,代码来源:QueueFileUtils.cpp

示例7: 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;
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:34,代码来源:QueueFileUtils.cpp

示例8: on

void DirectoryListingManager::on(QueueManagerListener::ItemRemoved, const QueueItemPtr& qi, bool aFinished) noexcept {
	if (!qi->isSet(QueueItem::FLAG_USER_LIST))
		return;

	auto u = qi->getSources()[0].getUser();
	if (qi->isSet(QueueItem::FLAG_DIRECTORY_DOWNLOAD) && !aFinished)
		removeDirectoryDownload(u, qi->getTempTarget(), qi->isSet(QueueItem::FLAG_PARTIAL_LIST));

	if (qi->isSet(QueueItem::FLAG_CLIENT_VIEW)) {
		DirectoryListingPtr dl = nullptr;

		{
			RLock l(cs);
			auto p = viewedLists.find(u);
			if (p == viewedLists.end()) {
				dcassert(0);
				return;
			}

			dl = p->second;
		}

		dl->onListRemovedQueue(qi->getTarget(), qi->getTempTarget(), aFinished);

		bool closing = (dl->getClosing() || !dl->hasCompletedDownloads());
		if (!aFinished && !dl->hasDownloads() && closing) {
			removeList(u);
		}
	}
}
开发者ID:Nordanvind,项目名称:airgit,代码行数:30,代码来源:DirectoryListingManager.cpp

示例9: 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());
		}
	}
}
开发者ID:Caraul,项目名称:airgit,代码行数:17,代码来源:UserQueue.cpp

示例10: 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());
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:airdc-svn,代码行数:19,代码来源:UserQueue.cpp

示例11: 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);
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:airdc-svn,代码行数:42,代码来源:UserQueue.cpp

示例12: 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();
	}
开发者ID:airdcpp,项目名称:airdcpp-webapi,代码行数:7,代码来源:QueueFileUtils.cpp

示例13: 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;
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:airdc-svn,代码行数:22,代码来源:FinishedManager.cpp

示例14: 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);
}
开发者ID:BackupTheBerlios,项目名称:airdc-svn,代码行数:9,代码来源:FileQueue.cpp

示例15:

pair<QueueItem::StringMap::const_iterator, bool> FileQueue::add(QueueItemPtr& qi) noexcept {
	dcassert(queueSize >= 0);
	auto ret = pathQueue.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();
		}

		tokenQueue.emplace(qi->getToken(), qi);
	}
	return ret;
}
开发者ID:sbraz,项目名称:airdcpp-webclient,代码行数:14,代码来源:FileQueue.cpp


注:本文中的QueueItemPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。