Mantid
Loading...
Searching...
No Matches
AlgorithmHistory.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9//----------------------------------------------------------------------
10// Includes
11//----------------------------------------------------------------------
12#include "MantidAPI/DllConfig.h"
15#include <nexus/NeXusFile.hpp>
16
17#include <ctime>
18#include <set>
19#include <vector>
20
21namespace Mantid {
22namespace API {
23class IAlgorithm;
24class Algorithm;
25class AlgorithmHistory;
26
27// typedefs for algorithm history pointers
28using AlgorithmHistory_sptr = std::shared_ptr<AlgorithmHistory>;
29using AlgorithmHistory_const_sptr = std::shared_ptr<const AlgorithmHistory>;
30using AlgorithmHistories = std::vector<AlgorithmHistory_sptr>;
31
41class MANTID_API_DLL AlgorithmHistory {
42
43public:
45
48 explicit AlgorithmHistory(const Algorithm *const alg,
49 const Types::Core::DateAndTime &start = Types::Core::DateAndTime::getCurrentTime(),
50 const double &duration = -1.0, std::size_t uexeccount = 0);
51 AlgorithmHistory &operator=(const AlgorithmHistory &);
53 AlgorithmHistory(std::string name, int vers, std::string uuid,
54 const Types::Core::DateAndTime &start = Types::Core::DateAndTime::getCurrentTime(),
55 const double &duration = -1.0, std::size_t uexeccount = 0);
56 void addExecutionInfo(const Types::Core::DateAndTime &start, const double &duration);
57 void addProperty(const std::string &name, const std::string &value, bool isdefault,
58 const unsigned int &direction = 99);
59
61 void addChildHistory(const AlgorithmHistory_sptr &childHist);
62 // get functions
64 const std::string &name() const { return m_name; }
66 const int &version() const { return m_version; }
68 double executionDuration() const { return m_executionDuration; }
70 Mantid::Types::Core::DateAndTime executionDate() const { return m_executionDate; }
72 const std::size_t &execCount() const { return m_execCount; }
74 const std::string &uuid() const { return m_uuid; }
76 const Mantid::Kernel::PropertyHistories &getProperties() const { return m_properties; }
78 const std::string &getPropertyValue(const std::string &name) const;
80 const AlgorithmHistories &getChildHistories() const { return m_childHistories; }
82 AlgorithmHistory_sptr getChildAlgorithmHistory(const size_t index) const;
84 AlgorithmHistory_sptr operator[](const size_t index) const;
86 size_t childHistorySize() const;
88 void printSelf(std::ostream &, const int indent = 0, const size_t maxPropertyLength = 0) const;
90 inline bool operator<(const AlgorithmHistory &other) const { return execCount() < other.execCount(); }
92 inline bool operator==(const AlgorithmHistory &other) const {
93 return (execCount() == other.execCount() && name() == other.name());
94 }
96 std::shared_ptr<IAlgorithm> createAlgorithm() const;
98 std::shared_ptr<IAlgorithm> getChildAlgorithm(const size_t index) const;
100 void saveNexus(::NeXus::File *file, int &algCount) const;
101 // Set the execution count
102 void setExecCount(std::size_t execCount) { m_execCount = execCount; }
104 void fillAlgorithmHistory(const Algorithm *const alg, const Types::Core::DateAndTime &start, const double &duration,
105 std::size_t uexeccount);
106 // Allow Algorithm::execute to change the exec count & duration after the
107 // algorithm was executed
108 friend class Algorithm;
109
110private:
111 // private constructor
113 // Set properties of algorithm
114 void setProperties(const Algorithm *const alg);
116 std::string m_name;
118 int m_version{-1};
120 Mantid::Types::Core::DateAndTime m_executionDate;
122 double m_executionDuration{-1.0};
126 std::size_t m_execCount{0};
130 std::string m_uuid;
131};
132
133MANTID_API_DLL std::ostream &operator<<(std::ostream &, const AlgorithmHistory &);
134
135} // namespace API
136} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
This class stores information about the Command History used by algorithms on a workspace.
Mantid::Kernel::PropertyHistories m_properties
The PropertyHistory's defined for the algorithm.
const AlgorithmHistories & getChildHistories() const
get the child histories of this history object
AlgorithmHistories m_childHistories
set of child algorithm histories for this history record
bool operator==(const AlgorithmHistory &other) const
Equality operator.
Mantid::Types::Core::DateAndTime m_executionDate
The execution date of the algorithm.
Mantid::Types::Core::DateAndTime executionDate() const
get execution date
std::string m_uuid
UUID for this algorithm history.
void setExecCount(std::size_t execCount)
AlgorithmHistory(const AlgorithmHistory &)=default
const std::size_t & execCount() const
get the execution count
const std::string & name() const
get name of algorithm in history const
double executionDuration() const
get execution duration
std::string m_name
The name of the Algorithm.
const int & version() const
get version number of algorithm in history const
const std::string & uuid() const
get the uuid
bool operator<(const AlgorithmHistory &other) const
Less than operator.
const Mantid::Kernel::PropertyHistories & getProperties() const
get parameter list of algorithm in history const
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:85
std::vector< AlgorithmHistory_sptr > AlgorithmHistories
MANTID_API_DLL std::ostream & operator<<(std::ostream &, const AlgorithmHistory &)
Prints a text representation.
std::shared_ptr< const AlgorithmHistory > AlgorithmHistory_const_sptr
std::shared_ptr< AlgorithmHistory > AlgorithmHistory_sptr
std::vector< PropertyHistory_sptr > PropertyHistories
Helper class which provides the Collimation Length for SANS instruments.