Exemplo n.º 1
0
HistoryView::HistoryView(const WorkspaceHistory &wsHist)
    : m_wsHist(wsHist), m_historyItems() {
  // add all of the top level algorithms to the view by default
  const auto &algorithms = wsHist.getAlgorithmHistories();
  m_historyItems =
      std::vector<HistoryItem>(algorithms.begin(), algorithms.end());
}
Exemplo n.º 2
0
/*
 * Return a vector of the names of files and workspaces which have been
 * previously added to the workspace
 * @param ws_history :: History of the workspace
 * @returns a vector of the names of data_sources which have previously been
 * appended to the workspace
*/
std::vector<std::string>
getHistoricalDataSources(const WorkspaceHistory &ws_history,
                         const std::string &create_alg_name,
                         const std::string &accumulate_alg_name) {
  // Using a set so we only insert unique names
  std::set<std::string> historical_data_sources;

  // Get previously added data sources from DataSources property of the original
  // call of CreateMD and any subsequent calls of AccumulateMD
  auto view = ws_history.createView();
  view->unrollAll();
  const std::vector<HistoryItem> history_items = view->getAlgorithmsList();
  for (auto iter = history_items.begin(); iter != history_items.end(); ++iter) {
    auto alg_history = iter->getAlgorithmHistory();
    if (alg_history->name() == create_alg_name ||
        alg_history->name() == accumulate_alg_name) {
      auto props = alg_history->getProperties();
      for (auto prop_iter = props.begin(); prop_iter != props.end();
           ++prop_iter) {
        PropertyHistory_const_sptr prop_history = *prop_iter;
        if (prop_history->name() == "DataSources") {
          insertDataSources(prop_history->value(), historical_data_sources);
        }
      }
    }
  }

  std::vector<std::string> result(historical_data_sources.begin(),
                                  historical_data_sources.end());
  return result;
}
Exemplo n.º 3
0
/**
 * Return a Python list of history objects from the workspace history as this is
 * far easier to work with than a set
 * @param self :: A reference to the WorkspaceHistory that called this method
 * @returns A python list created from the set of algorithm histories
 */
boost::python::object getHistoriesAsList(WorkspaceHistory& self)
{
  boost::python::list names;
  const auto histories = self.getAlgorithmHistories();
  Mantid::API::AlgorithmHistories::const_iterator itr = histories.begin();
  for(; itr != histories.end(); ++itr)
  {
    names.append(*itr);
  }
  return names;
}
Exemplo n.º 4
0
/// Append the algorithm history from another WorkspaceHistory into this one
void WorkspaceHistory::addHistory(const WorkspaceHistory &otherHistory) {
  // Don't copy one's own history onto oneself
  if (this == &otherHistory) {
    return;
  }

  // Merge the histories
  const AlgorithmHistories &otherAlgorithms =
      otherHistory.getAlgorithmHistories();
  m_algorithms.insert(otherAlgorithms.begin(), otherAlgorithms.end());
}