Mantid
Loading...
Searching...
No Matches
AlgorithmHistory.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 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 +
11
12#include <boost/python/class.hpp>
13#include <boost/python/copy_const_reference.hpp>
14#include <boost/python/list.hpp>
15#include <boost/python/operators.hpp>
16#include <boost/python/register_ptr_to_python.hpp>
17#include <boost/python/return_internal_reference.hpp>
18#include <boost/python/self.hpp>
19
21using namespace boost::python;
22
29boost::python::list getChildrenAsList(const std::shared_ptr<AlgorithmHistory> &self) {
30 boost::python::list names;
31 const auto histories = self->getChildHistories();
32 for (const auto &history : histories) {
33 names.append(history);
34 }
35 return names;
36}
37
44boost::python::list getPropertiesAsList(const AlgorithmHistory &self) {
45 boost::python::list names;
46 const auto &histories = self.getProperties();
47 for (const auto &history : histories) {
48 names.append(history);
49 }
50 return names;
51}
52
54 register_ptr_to_python<Mantid::API::AlgorithmHistory_sptr>();
55
56 class_<AlgorithmHistory>("AlgorithmHistory", no_init)
57 .def("name", &AlgorithmHistory::name, arg("self"), return_value_policy<copy_const_reference>(),
58 "Returns the name of the algorithm.")
59
60 .def("version", &AlgorithmHistory::version, arg("self"), return_value_policy<copy_const_reference>(),
61 "Returns the version of the algorithm.")
62
63 .def("executionDuration", &AlgorithmHistory::executionDuration, arg("self"),
64 "Returns the execution duration of the algorithm.")
65
66 .def("executionDate", &AlgorithmHistory::executionDate, arg("self"),
67 "Returns the execution date of the algorithm.")
68
69 .def("execCount", &AlgorithmHistory::execCount, arg("self"), return_value_policy<copy_const_reference>(),
70 "Returns the execution number of the algorithm.")
71
72 .def("childHistorySize", &AlgorithmHistory::childHistorySize, arg("self"),
73 "Returns the number of the child algorithms.")
74
75 .def("getChildAlgorithmHistory", &AlgorithmHistory::getChildAlgorithmHistory, (arg("self"), arg("index")),
76 "Returns the child algorithm at the given index in the history")
77
78 .def("getChildHistories", &getChildrenAsList, arg("self"),
79 "Returns a list of child "
80 "algorithm histories for "
81 "this algorithm history.")
82
83 .def("getProperties", &getPropertiesAsList, arg("self"), "Returns properties for this algorithm history.")
84
85 .def("getPropertyValue", &AlgorithmHistory::getPropertyValue, (arg("self"), arg("index")),
86 return_value_policy<copy_const_reference>(), "Returns the string representation of a specified property.")
87
88 .def("getChildAlgorithm", &AlgorithmHistory::getChildAlgorithm, (arg("self"), arg("index")),
89 "Returns the algorithm at the given index in the history")
90 // ----------------- Operators --------------------------------------
91 .def(self_ns::str(self));
92}
boost::python::list getChildrenAsList(const std::shared_ptr< AlgorithmHistory > &self)
Return a Python list of child history objects from the history as this is far easier to work with tha...
boost::python::list getPropertiesAsList(const AlgorithmHistory &self)
Return a Python list of property history objects from the history.
void export_AlgorithmHistory()
std::vector< history_type > history
history information
This class stores information about the Command History used by algorithms on a workspace.
std::shared_ptr< IAlgorithm > getChildAlgorithm(const size_t index) const
Create an child algorithm from a history record at a given index.
Mantid::Types::Core::DateAndTime executionDate() const
get execution date
const std::string & getPropertyValue(const std::string &name) const
get the string representation of a specified property
const std::size_t & execCount() const
get the execution count
size_t childHistorySize() const
Retrieve the number of child algorithms.
const std::string & name() const
get name of algorithm in history const
double executionDuration() const
get execution duration
const int & version() const
get version number of algorithm in history const
AlgorithmHistory_sptr getChildAlgorithmHistory(const size_t index) const
Retrieve a child algorithm history by index.
const Mantid::Kernel::PropertyHistories & getProperties() const
get parameter list of algorithm in history const