本文整理汇总了C++中pacc::xml::ConstIterator::getParent方法的典型用法代码示例。如果您正苦于以下问题:C++ ConstIterator::getParent方法的具体用法?C++ ConstIterator::getParent怎么用?C++ ConstIterator::getParent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pacc::xml::ConstIterator
的用法示例。
在下文中一共展示了ConstIterator::getParent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readWithContext
void TreeSTag::readWithContext(PACC::XML::ConstIterator inIter, Beagle::Context& ioContext){
Beagle_StackTraceBeginM();
GP::Context& lGPContext = castObjectT<GP::Context&>(ioContext);
if((inIter->getType()!=PACC::XML::eData) || (inIter->getValue()!="Genotype"))
throw Beagle_IOExceptionNodeM(*inIter, "tag <Genotype> expected!");
std::string lType = inIter->getAttribute("type").c_str();
if(lType.empty())
throw Beagle_IOExceptionNodeM(*inIter, "GP tree type of the genotype is not present!");
if(lType != "gptreetag")
throw Beagle_IOExceptionNodeM(*inIter, std::string("type of genotype mismatch, expected ")
+std::string("\"gptreetag\" but read \"")+lType+std::string("\" instead!"));
//Get structure id
std::string lStructureID = inIter->getAttribute("structureid").c_str();
mStructureID = str2uint(lStructureID);
// Get primitive set index
std::string lPrimitiveSetIndexText = inIter->getAttribute("primitiveSetIndex").c_str();
if(lPrimitiveSetIndexText.empty()) {
// No primitive set index was specified. This must be an old
// tree. Assume index is equal to tree's index
unsigned int lGenotypeIndex = ioContext.getGenotypeIndex();
if(lGenotypeIndex >= lGPContext.getSystem().getPrimitiveSuperSet().size()) {
throw Beagle_RunTimeExceptionM(std::string("In GP::Tree::readWithContext(): The ")+
std::string("'primitiveSetIndex' attribute was missing from an individual's genotype. ")+
std::string("It would normally be assumed that such a tree was to be mapped to the ")+
std::string("primitive set of the same index as the genotype. In this case that would ")+
std::string("result in an incorrect mapping because there are not enough primitive sets ")+
std::string("in the System. Perhaps this individual was not intended to be read with the ")+
std::string("current set of primitive sets?"));
}
setPrimitiveSetIndex(lGenotypeIndex);
}
else {
// primitiveSetIndex is a valid attribute.
unsigned int lPrimitiveSetIndex = str2uint(lPrimitiveSetIndexText);
if(lPrimitiveSetIndex >= lGPContext.getSystem().getPrimitiveSuperSet().size()) {
std::string lMessage = std::string("In GP::Tree::readWithContext(): The 'primitiveSetIndex' ")+
std::string("attribute contained the value '") + lPrimitiveSetIndexText +
std::string("' which was read as the number '") + uint2str(lPrimitiveSetIndex) +
std::string("'. This value is incorrect as there are not enough primitive sets in the ")+
std::string("System. Perhaps this individual was not intended to be read with the current ")+
std::string("set of primitive sets?");
throw Beagle_RunTimeExceptionM(lMessage);
}
setPrimitiveSetIndex(lPrimitiveSetIndex);
}
// Get numberArguments attribute
std::string lNumberArgumentsText = inIter->getAttribute("numberArguments").c_str();
if(lNumberArgumentsText.empty()) {
// numberArguments attribute wasn't defined. This must be an old
// tree. Assume the number of arguments is zero.
setNumberArguments(0);
}
else {
// numberArguments is a valid attribute.
setNumberArguments(str2uint(lNumberArgumentsText));
}
// Get size attribute and reserve size accordingly
std::string lSizeText = inIter->getAttribute("size").c_str();
if(lSizeText.empty()==false) reserve(str2uint(lSizeText));
PACC::XML::ConstIterator lChild = inIter->getFirstChild();
if((!lChild) || (lChild->getType()!=PACC::XML::eData))
throw Beagle_IOExceptionNodeM(*lChild, "expected a XML tag for the GP tree!");
clear();
readSubTree(lChild, lGPContext);
//Read BondGraph if any
const PACC::XML::Node* lParent = inIter->getParent();
PACC::XML::ConstFinder lIndivFinder = PACC::XML::ConstIterator(lParent);
PACC::XML::ConstIterator lBGTag = lIndivFinder.find("//BondGraph");
if(!lBGTag) {
return;
}
// mBondGraph = new GrowingHybridBondGraph;
// mBondGraph->read(lBGTag);
Beagle_StackTraceEndM("void GP::Tree::readWithContext(PACC::XML::ConstIterator inIter, Beagle::Context& ioContext)");
}