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


C++ Tree::IsGood方法代码示例

本文整理汇总了C++中Tree::IsGood方法的典型用法代码示例。如果您正苦于以下问题:C++ Tree::IsGood方法的具体用法?C++ Tree::IsGood怎么用?C++ Tree::IsGood使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tree的用法示例。


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

示例1: ExecGetTrees

void BullShell::ExecGetTrees(const GetTreesOpts & gto) {
	errormsg.clear();
	BlockReaderList blocks = getBlocksFromFile(gto.filename, true);
	if (blocks.empty()) {
		errormsg << "No Trees Block found in " << gto.filename;
		throw XBull(errormsg);
	}
	
	unsigned ntreesInFile = 0;
	const unsigned ntreesBlocks = blocks.size();
	vector<NxsTreesBlockAPI *> trBlocks;
	for (BlockReaderList::iterator b = blocks.begin(); b != blocks.end(); ++b) {
		NxsTreesBlockAPI *tb = (NxsTreesBlockAPI *)(*b);
		trBlocks.push_back(tb);
		assert(tb);
		ntreesInFile += tb->GetNumTrees();
	}

	if (ntreesInFile < 1) {
		errormsg << "No Trees found in " << gto.filename;
		throw XBull(errormsg);
	}
	
	const unsigned toTree = (unsigned) (gto.toTree < 0 ? 0 : gto.toTree); 
	const unsigned fromTree = (unsigned) (gto.fromTree < 0 ? ntreesInFile - 1 : gto.fromTree);
	if (fromTree > toTree) {
		errormsg << "Cant get Trees from " << fromTree << " to " << toTree;
		throw XBull( errormsg);
	}

	// Store the specified trees
	// these trees are deleted in the for loop if there is an error, otherwise
	//	they are put under the control of the kernel
	vector<Tree *>	treesToBeAdded; 
	vector<NxsTreesBlockAPI *>::const_iterator tbIt = trBlocks.begin();
	NxsTreesBlockAPI * currTB = *tbIt;
	unsigned nTreesInThisBlock = currTB->GetNumTrees();
	int nleftInThisBlock = (int) nTreesInThisBlock;
	for (unsigned i = 0; i < toTree; i++, --nleftInThisBlock) {
		while (nleftInThisBlock < 1) {
			++tbIt;
			assert(tbIt != trBlocks.end());
			currTB = *tbIt;
			nTreesInThisBlock = currTB->GetNumTrees();
			nleftInThisBlock = (int) nTreesInThisBlock;
		}
		if (i >= fromTree) {
			const std::string newick = currTB->GetTranslatedTreeDescription((unsigned)(nTreesInThisBlock - nleftInThisBlock));
			Tree * temptree = new Tree(newick, gto.storeBrLensFromFile);
			if (!temptree->IsGood()) {
				for (unsigned j = 0; j < i - fromTree; j++)
					delete treesToBeAdded[j];
				errormsg << "Problem Reading Tree Description of " << currTB->GetTreeName(i);
				delete temptree;
				throw XBull(errormsg);
			}
			std::string s = currTB->GetTreeName(i);
			ToUpper(s);
			temptree->SetName(s);
			treesToBeAdded.push_back(temptree);
		}
	}

	ioObject.message.clear();
	ioObject.message << (int)(toTree - fromTree) << " trees read from " << ntreesBlocks << " TREES block(s) in " <<  gto.filename;
	ioObject.printMessage(BullIO::STATUS_MSG_LEVEL);

	assert(gto.mode <= 7 && gto.mode >= 0);
	kernel.updateTrees(treesToBeAdded, UpdateMode(gto.mode));
	for (BlockReaderList::iterator b = blocks.begin(); b != blocks.end(); ++b) {
		if (*b != this)
			delete *b;
	}
}		
开发者ID:mtholder,项目名称:bull,代码行数:74,代码来源:bull_parsers.cpp


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