Skip to content

Commit

Permalink
Refs #8913 Add additional getter/setters to AlgorithmHistory.
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Jackson committed Apr 24, 2014
1 parent db979ff commit add7c42
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 8 deletions.
18 changes: 18 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/AlgorithmHistory.h
Expand Up @@ -9,13 +9,18 @@
#include "MantidKernel/DateAndTime.h"
#include <ctime>
#include <vector>
#include <set>

namespace Mantid
{
namespace API
{
class IAlgorithm;
class Algorithm;
class AlgorithmHistory;

typedef std::set<AlgorithmHistory> AlgorithmHistories;

/** @class AlgorithmHistory AlgorithmHistory.h API/MAntidAPI/AlgorithmHistory.h
This class stores information about the Command History used by algorithms on a workspace.
Expand Down Expand Up @@ -43,9 +48,13 @@ namespace API
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/


class MANTID_API_DLL AlgorithmHistory
{
public:
/// History container

/// The date-and-time will be stored as the Mantid::Kernel::DateAndTime type
explicit AlgorithmHistory(const Algorithm* const alg,
const Kernel::DateAndTime& start = Kernel::DateAndTime::defaultTime(),
Expand All @@ -58,6 +67,11 @@ class MANTID_API_DLL AlgorithmHistory
void addExecutionInfo(const Kernel::DateAndTime& start, const double& duration);
void addProperty(const std::string& name,const std::string& value,bool isdefault,
const unsigned int& direction = 99);

/// add a child algorithm history record to this history object
void addChildHistory(const AlgorithmHistory& childHist);
/// set the duration time this algorithm history object
void setAlgorithmDuration(const double& duration);
// get functions
/// get name of algorithm in history const
const std::string& name() const {return m_name;}
Expand All @@ -71,6 +85,8 @@ class MANTID_API_DLL AlgorithmHistory
const std::size_t& execCount() const {return m_execCount;}
/// get parameter list of algorithm in history const
const std::vector<Kernel::PropertyHistory>& getProperties() const {return m_properties;}
/// get the child histories of this history object
AlgorithmHistories getChildHistories() const { return m_childHistories; }
/// print contents of object
void printSelf(std::ostream&,const int indent = 0) const;
/// Less than operator
Expand Down Expand Up @@ -100,6 +116,8 @@ class MANTID_API_DLL AlgorithmHistory
std::vector<Kernel::PropertyHistory> m_properties;
///count keeps track of execution order of an algorithm
std::size_t m_execCount;
/// set of child algorithm histories for this history record
AlgorithmHistories m_childHistories;
};

MANTID_API_DLL std::ostream& operator<<(std::ostream&, const AlgorithmHistory&);
Expand Down
5 changes: 1 addition & 4 deletions Code/Mantid/Framework/API/inc/MantidAPI/WorkspaceHistory.h
Expand Up @@ -52,9 +52,6 @@ namespace API
class MANTID_API_DLL WorkspaceHistory
{
public:
/// History container
typedef std::set<AlgorithmHistory> AlgorithmHistories;

/// Default constructor
WorkspaceHistory();
/// Destructor
Expand Down Expand Up @@ -96,7 +93,7 @@ class MANTID_API_DLL WorkspaceHistory
/// The environment of the workspace
const Kernel::EnvironmentHistory m_environment;
/// The algorithms which have been called on the workspace
AlgorithmHistories m_algorithms;
Mantid::API::AlgorithmHistories m_algorithms;

};

Expand Down
24 changes: 21 additions & 3 deletions Code/Mantid/Framework/API/src/AlgorithmHistory.cpp
Expand Up @@ -19,7 +19,7 @@ using Kernel::DateAndTime;
* @param uexeccount :: an unsigned int for algorithm execution order
*/
AlgorithmHistory::AlgorithmHistory(const Algorithm* const alg, const Kernel::DateAndTime& start, const double& duration,std::size_t uexeccount) :
m_name(alg->name()), m_version(alg->version()), m_executionDate(start), m_executionDuration(duration),m_execCount(uexeccount)
m_name(alg->name()), m_version(alg->version()), m_executionDate(start), m_executionDuration(duration),m_execCount(uexeccount), m_childHistories()
{
// Now go through the algorithm's properties and create the PropertyHistory objects.
const std::vector<Property*>& properties = alg->getProperties();
Expand All @@ -44,7 +44,8 @@ AlgorithmHistory::~AlgorithmHistory()
*/
AlgorithmHistory::AlgorithmHistory(const std::string& name, int vers, const Kernel::DateAndTime& start, const double& duration, std::size_t uexeccount) :
m_name(name),m_version(vers),m_executionDate(start),
m_executionDuration(duration),m_execCount(uexeccount)
m_executionDuration(duration),m_execCount(uexeccount),
m_childHistories()
{
}

Expand All @@ -54,7 +55,8 @@ AlgorithmHistory::AlgorithmHistory(const std::string& name, int vers, const Kern
*/
AlgorithmHistory::AlgorithmHistory(const AlgorithmHistory& A) :
m_name(A.m_name),m_version(A.m_version),m_executionDate(A.m_executionDate),
m_executionDuration(A.m_executionDuration),m_properties(A.m_properties),m_execCount(A.m_execCount)
m_executionDuration(A.m_executionDuration),m_properties(A.m_properties),
m_execCount(A.m_execCount), m_childHistories(A.m_childHistories)
{
}

Expand All @@ -80,6 +82,22 @@ void AlgorithmHistory::addExecutionInfo(const DateAndTime& start, const double&
m_properties.push_back(Kernel::PropertyHistory(name,value,"",isdefault, direction));
}

/** Add a child algorithm history to hsitory
* @param childHist :: The child history
*/
void AlgorithmHistory::addChildHistory(const AlgorithmHistory& childHist)
{
m_childHistories.insert(childHist);
}

/** Set the duration time of the algorithm in the history
* @param duration :: The time the algorithm took to execute
*/
void AlgorithmHistory::setAlgorithmDuration(const double& duration)
{
m_executionDuration = duration;
}

/** Prints a text representation of itself
* @param os :: The ouput stream to write to
* @param indent :: an indentation value to make pretty printing of object and sub-objects
Expand Down
2 changes: 1 addition & 1 deletion Code/Mantid/Framework/API/src/WorkspaceHistory.cpp
Expand Up @@ -39,7 +39,7 @@ WorkspaceHistory::WorkspaceHistory(const WorkspaceHistory& A) :
{}

/// Returns a const reference to the algorithmHistory
const WorkspaceHistory::AlgorithmHistories & WorkspaceHistory::getAlgorithmHistories() const
const Mantid::API::AlgorithmHistories & WorkspaceHistory::getAlgorithmHistories() const
{
return m_algorithms;
}
Expand Down

0 comments on commit add7c42

Please sign in to comment.