/** * Build the script output for a single algorithm * * @param algHistory :: pointer to an algorithm history object * @returns std::string to run this algorithm */ const std::string ScriptBuilder::buildAlgorithmString(AlgorithmHistory_const_sptr algHistory) { std::ostringstream properties; const std::string name = algHistory->name(); std::string prop = ""; auto props = algHistory->getProperties(); for (auto propIter = props.begin(); propIter != props.end(); ++propIter) { prop = buildPropertyString(*propIter); if(prop.length() > 0) { properties << prop << ", "; } } std::string propStr = properties.str(); if (propStr.length() > 0) { //remove trailing comma & space propStr.erase(propStr.size()-1); propStr.erase(propStr.size()-1); } return name + "(" + propStr + ")"; }
/** * Build the script output for a single algorithm * * @param algHistory :: pointer to an algorithm history object * @returns std::string to run this algorithm */ const std::string ScriptBuilder::buildAlgorithmString(AlgorithmHistory_const_sptr algHistory) { std::ostringstream properties; const std::string name = algHistory->name(); std::string prop = ""; auto props = algHistory->getProperties(); for (auto propIter = props.begin(); propIter != props.end(); ++propIter) { prop = buildPropertyString(*propIter); if(prop.length() > 0) { properties << prop << ", "; } } //Three cases, we can either specify the version of every algorithm... if(m_versionSpecificity == "all") { properties << "Version=" << algHistory->version() << ", "; } else if(m_versionSpecificity == "old") { //...or only specify algorithm versions when they're not the newest version bool oldVersion = false; std::vector<Algorithm_descriptor> descriptors = AlgorithmFactory::Instance().getDescriptors(); for(auto dit = descriptors.begin(); dit != descriptors.end(); ++dit) { //If a newer version of this algorithm exists, then this must be an old version. if((*dit).name == algHistory->name() && (*dit).version > algHistory->version()) { oldVersion = true; break; } } if(oldVersion) { properties << "Version=" << algHistory->version() << ", "; } } //Third case is we never specify the version, so do nothing. std::string propStr = properties.str(); if (propStr.length() > 0) { //remove trailing comma & space propStr.erase(propStr.size()-1); propStr.erase(propStr.size()-1); } return name + "(" + propStr + ")"; }