Skip to content

Commit

Permalink
Refs #8913 Add a couple of additional methods for convenience.
Browse files Browse the repository at this point in the history
These are consistent with the functionality that is available in WorkspaceHistory.
  • Loading branch information
Samuel Jackson committed Apr 28, 2014
1 parent 16ef51b commit d8481c4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmHistory.h
Expand Up @@ -87,6 +87,10 @@ class MANTID_API_DLL AlgorithmHistory
const std::vector<Kernel::PropertyHistory>& getProperties() const {return m_properties;}
/// get the child histories of this history object
AlgorithmHistories getChildHistories() const { return m_childHistories; }
/// Retrieve a child algorithm history by index
const AlgorithmHistory & getChildAlgorithmHistory(const size_t index) const;
/// Retrieve the number of child algorithms
size_t childHistorySize() const;
/// print contents of object
void printSelf(std::ostream&,const int indent = 0) const;
/// Less than operator
Expand Down
25 changes: 25 additions & 0 deletions Code/Mantid/Framework/API/src/AlgorithmHistory.cpp
Expand Up @@ -91,6 +91,31 @@ void AlgorithmHistory::addChildHistory(const AlgorithmHistory& childHist)
m_childHistories.insert(childHist);
}

/*
Return the child history length
*/
size_t AlgorithmHistory::childHistorySize() const
{
return m_childHistories.size();
}

/**
* Retrieve a child algorithm history by index
* @param index :: An index within the child algorithm history set
* @returns A reference to a const AlgorithmHistory object
* @throws std::out_of_range error if the index is invalid
*/
const AlgorithmHistory & AlgorithmHistory::getChildAlgorithmHistory(const size_t index) const
{
if( index >= this->getChildHistories().size() )
{
throw std::out_of_range("AlgorithmHistory::getAlgorithmHistory() - Index out of range");
}
AlgorithmHistories::const_iterator start = m_childHistories.begin();
std::advance(start, index);
return *start;
}

/** Set the duration time of the algorithm in the history
* @param duration :: The time the algorithm took to execute
*/
Expand Down

0 comments on commit d8481c4

Please sign in to comment.