Esempio n. 1
0
/**
 * Write out an algorithm to the script.
 *
 * If the entry is unrolled this will recurse and output the children of
 * that entry instead. If not, it will just output the algorithm to the stream.
 *
 * @param os :: output string stream to append algorithms to.
 * @param iter :: reference to the iterator pointing to the vector of history items
 * @param depth :: count of how far we've recursed into the history
 */
void ScriptBuilder::writeHistoryToStream(std::ostringstream& os, std::vector<HistoryItem>::const_iterator& iter, int depth)
{
  auto algHistory = iter->getAlgorithmHistory();
  if(iter->isUnrolled())
  {
    os << "\n";
    os << std::string(depth, '#');
    os << " Child algorithms of " << algHistory->name() << "\n";

    //don't create a line for the algorithm, just output its children
    buildChildren(os, iter, depth+1);
    
    os << std::string(depth, '#');
    os << " End of child algorithms of " << algHistory->name() << "\n";
    
    if(boost::next(iter) == m_historyItems.end() 
        || !boost::next(iter)->isUnrolled())
    {
      os << "\n";
    }
  }
  else
  {
    //create the string for this algorithm
    os << buildAlgorithmString(algHistory) << "\n";
  }
}
Esempio n. 2
0
/**
 * Unroll an algorithm history to export its child algorithms.
 *
 * This places each of the child algorithm histories into the
 * HistoryView object. The parent is retained as a marker so we can
 * "roll" the history back up if we want. This method does nothing if
 * the history object has no children
 *
 * @param it :: iterator to the list of history item objects at the position to
 *unroll
 */
void HistoryView::unroll(std::vector<HistoryItem>::iterator &it) {
  const auto history = it->getAlgorithmHistory();
  const auto childHistories = history->getChildHistories();

  if (!it->isUnrolled() && !childHistories.empty()) {
    // mark this record as being ignored by the script builder
    it->unrolled(true);

    // insert each of the records, in order, at this position
    std::vector<HistoryItem> tmpHistory(childHistories.cbegin(),
                                        childHistories.cend());
    // since we are using a std::vector, do all insertions at the same time.
    ++it; // move iterator forward to insertion position
    it = m_historyItems.insert(it, tmpHistory.begin(), tmpHistory.end());
  } else
    ++it;
}
Esempio n. 3
0
/**
 * Write out an algorithm to the notebook.
 * If the entry is unrolled this will recurse and output the children of
 * that entry instead. If not, it will just output the algorithm to the stream.
 *
 * @param iter :: reference to the iterator pointing to the vector of history
 *items
 */
void NotebookBuilder::writeHistoryToStream(
    std::vector<HistoryItem>::const_iterator &iter) {
  auto algHistory = iter->getAlgorithmHistory();
  if (iter->isUnrolled()) {

    m_nb_writer->markdownCell(std::string("Child algorithms of ") +
                              algHistory->name());

    buildChildren(iter);

    m_nb_writer->markdownCell(std::string("End of child algorithms of ") +
                              algHistory->name());

  } else {
    // create the string for this algorithm
    m_nb_writer->codeCell(buildAlgorithmString(algHistory));
  }
}