Mantid
|
This class stores information about the Workspace History used by algorithms on a workspace and the environment history. More...
#include <WorkspaceHistory.h>
Public Member Functions | |
void | addHistory (AlgorithmHistory_sptr algHistory) |
Append an algorithm history to this one. More... | |
void | addHistory (const WorkspaceHistory &otherHistory) |
Append an workspace history to this one. More... | |
void | clearHistory () |
remove all algorithm history objects from the workspace history More... | |
std::shared_ptr< HistoryView > | createView () const |
Create a flat view of the workspaces algorithm history. More... | |
bool | empty () const |
Is the history empty. More... | |
std::shared_ptr< IAlgorithm > | getAlgorithm (const size_t index) const |
Create an algorithm from a history record at a given index. More... | |
const AlgorithmHistories & | getAlgorithmHistories () const |
Retrieve the algorithm history list. More... | |
AlgorithmHistory_const_sptr | getAlgorithmHistory (const size_t index) const |
Retrieve an algorithm history by index. More... | |
const Kernel::EnvironmentHistory & | getEnvironmentHistory () const |
Retrieve the environment history. More... | |
std::shared_ptr< IAlgorithm > | lastAlgorithm () const |
Convenience function for retrieving the last algorithm. More... | |
void | loadNexus (::NeXus::File *file) |
Load the workspace history from a nexus file. More... | |
WorkspaceHistory & | operator= (const WorkspaceHistory &)=delete |
Deleted copy assignment operator since m_environment has no copy assignment. More... | |
bool | operator== (const WorkspaceHistory &otherHistory) const |
Add an operator== that compares algorithm historys. More... | |
AlgorithmHistory_const_sptr | operator[] (const size_t index) const |
Add operator[] access. More... | |
void | printSelf (std::ostream &, const int indent=0) const |
Pretty print the entire history. More... | |
void | saveNexus (::NeXus::File *file) const |
Save the workspace history to a nexus file. More... | |
size_t | size () const |
How many entries are there. More... | |
WorkspaceHistory () | |
Default constructor. More... | |
WorkspaceHistory (const WorkspaceHistory &)=default | |
Copy constructor. More... | |
virtual | ~WorkspaceHistory ()=default |
Destructor. More... | |
Private Member Functions | |
std::set< int > | findHistoryEntries (::NeXus::File *file) |
Find the history entries at this level in the file. More... | |
void | loadNestedHistory (::NeXus::File *file, const AlgorithmHistory_sptr &parent=std::shared_ptr< AlgorithmHistory >()) |
Recursive function to load the algorithm history tree from file. More... | |
AlgorithmHistory_sptr | parseAlgorithmHistory (const std::string &rawData) |
Parse an algorithm history string loaded from file. More... | |
Private Attributes | |
Mantid::API::AlgorithmHistories | m_algorithms |
The algorithms which have been called on the workspace. More... | |
const Kernel::EnvironmentHistory | m_environment |
The environment of the workspace. More... | |
This class stores information about the Workspace History used by algorithms on a workspace and the environment history.
Definition at line 35 of file WorkspaceHistory.h.
Mantid::API::WorkspaceHistory::WorkspaceHistory | ( | ) |
|
virtualdefault |
Destructor.
|
default |
Copy constructor.
void Mantid::API::WorkspaceHistory::addHistory | ( | AlgorithmHistory_sptr | algHistory | ) |
Append an algorithm history to this one.
Append an AlgorithmHistory to this WorkspaceHistory.
Definition at line 94 of file WorkspaceHistory.cpp.
References m_algorithms.
void Mantid::API::WorkspaceHistory::addHistory | ( | const WorkspaceHistory & | otherHistory | ) |
Append an workspace history to this one.
Append the algorithm history from another WorkspaceHistory into this one.
Definition at line 65 of file WorkspaceHistory.cpp.
References addHistory(), getAlgorithmHistories(), and m_algorithms.
Referenced by addHistory(), and loadNestedHistory().
void Mantid::API::WorkspaceHistory::clearHistory | ( | ) |
remove all algorithm history objects from the workspace history
Empty the list of algorithm history objects.
Definition at line 114 of file WorkspaceHistory.cpp.
References m_algorithms.
std::shared_ptr< HistoryView > Mantid::API::WorkspaceHistory::createView | ( | ) | const |
Create a flat view of the workspaces algorithm history.
Definition at line 444 of file WorkspaceHistory.cpp.
Referenced by Mantid::Algorithms::GenerateIPythonNotebook::exec(), Mantid::Algorithms::GeneratePythonScript::exec(), and Mantid::MDAlgorithms::getHistoricalDataSources().
bool Mantid::API::WorkspaceHistory::empty | ( | ) | const |
Is the history empty.
Query if the history is empty or not.
Definition at line 109 of file WorkspaceHistory.cpp.
References m_algorithms.
Referenced by AlgorithmHistoryWindow::AlgorithmHistoryWindow(), and export_WorkspaceHistory().
|
private |
Find the history entries at this level in the file.
Find all the algorithm entries at a particular point the the nexus file.
file | :: The handle to the nexus file |
Definition at line 314 of file WorkspaceHistory.cpp.
References Mantid::Kernel::Strings::convert().
Referenced by loadNestedHistory().
std::shared_ptr< IAlgorithm > Mantid::API::WorkspaceHistory::getAlgorithm | ( | const size_t | index | ) | const |
Create an algorithm from a history record at a given index.
index | :: An index within the workspace history |
Definition at line 144 of file WorkspaceHistory.cpp.
References Mantid::API::Algorithm::fromHistory(), and getAlgorithmHistory().
Referenced by export_WorkspaceHistory(), and lastAlgorithm().
const Mantid::API::AlgorithmHistories & Mantid::API::WorkspaceHistory::getAlgorithmHistories | ( | ) | const |
Retrieve the algorithm history list.
Returns a const reference to the algorithmHistory.
Definition at line 60 of file WorkspaceHistory.cpp.
References m_algorithms.
Referenced by addHistory(), AlgorithmHistoryWindow::createAlgHistoryPropWindow(), Mantid::API::HistoryView::HistoryView(), and AlgHistoryTreeWidget::populateAlgHistoryTreeWidget().
AlgorithmHistory_const_sptr Mantid::API::WorkspaceHistory::getAlgorithmHistory | ( | const size_t | index | ) | const |
Retrieve an algorithm history by index.
index | :: An index within the workspace history |
std::out_of_range | error if the index is invalid |
Definition at line 122 of file WorkspaceHistory.cpp.
References index, m_algorithms, and size().
Referenced by AlgorithmHistoryWindow::createExecSummaryGrpBox(), export_WorkspaceHistory(), getAlgorithm(), and operator[]().
const Kernel::EnvironmentHistory & Mantid::API::WorkspaceHistory::getEnvironmentHistory | ( | ) | const |
Retrieve the environment history.
Returns a const reference to the EnvironmentHistory.
Definition at line 62 of file WorkspaceHistory.cpp.
References m_environment.
std::shared_ptr< IAlgorithm > Mantid::API::WorkspaceHistory::lastAlgorithm | ( | ) | const |
Convenience function for retrieving the last algorithm.
Definition at line 152 of file WorkspaceHistory.cpp.
References getAlgorithm(), m_algorithms, and size().
Referenced by export_WorkspaceHistory().
|
private |
Recursive function to load the algorithm history tree from file.
Load every algorithm history object at this point in the hierarchy.
This method will recurse over every algorithm entry in the nexus file and load both the record and its children.
file | :: The handle to the nexus file |
parent | :: Pointer to the parent AlgorithmHistory object. If null then loaded histories are added to the workspace history. |
Definition at line 282 of file WorkspaceHistory.cpp.
References addHistory(), findHistoryEntries(), Mantid::API::g_log, history, loadNestedHistory(), parseAlgorithmHistory(), Mantid::Kernel::Strings::toString(), and Mantid::Kernel::Logger::warning().
Referenced by loadNestedHistory(), and loadNexus().
void Mantid::API::WorkspaceHistory::loadNexus | ( | ::NeXus::File * | file | ) |
Load the workspace history from a nexus file.
Opens a group called "process" and loads the workspace history from it.
file | :: previously opened NXS file. |
Definition at line 258 of file WorkspaceHistory.cpp.
References Mantid::API::g_log, loadNestedHistory(), and Mantid::Kernel::Logger::warning().
Referenced by Mantid::MDAlgorithms::LoadMD::doLoad().
|
delete |
Deleted copy assignment operator since m_environment has no copy assignment.
References std::operator==().
bool Mantid::API::WorkspaceHistory::operator== | ( | const WorkspaceHistory & | otherHistory | ) | const |
Add an operator== that compares algorithm historys.
Definition at line 457 of file WorkspaceHistory.cpp.
References m_algorithms.
AlgorithmHistory_const_sptr Mantid::API::WorkspaceHistory::operator[] | ( | const size_t | index | ) | const |
Add operator[] access.
Index operator[] access to a workspace history.
index | :: An index within the workspace history |
std::out_of_range | error if the index is invalid |
Definition at line 135 of file WorkspaceHistory.cpp.
References getAlgorithmHistory(), and index.
|
private |
Parse an algorithm history string loaded from file.
Parse an algorithm history entry loaded from file.
rawData | :: The string containing the history entry loaded from file |
std::runtime_error | if the loaded data could not be parsed |
specifies the order that algorithm data is listed in workspaces' histories
To allow legacy files we must check if it is parameters and set the variables accordingly. If legacy generate a new UUID for it.
Definition at line 340 of file WorkspaceHistory.cpp.
References Mantid::API::AlgorithmHistory::addProperty(), Mantid::Kernel::Direction::asEnum(), Mantid::API::Algorithm::g_execCount, Mantid::API::g_log, Mantid::API::getWordsInString(), history, index, and Mantid::Kernel::Logger::warning().
Referenced by loadNestedHistory().
void Mantid::API::WorkspaceHistory::printSelf | ( | std::ostream & | os, |
const int | indent = 0 |
||
) | const |
Pretty print the entire history.
Prints a text representation of itself.
os | :: The ouput stream to write to |
indent | :: an indentation value to make pretty printing of object and sub-objects |
Definition at line 164 of file WorkspaceHistory.cpp.
References m_algorithms, m_environment, and Mantid::Kernel::EnvironmentHistory::printSelf().
Referenced by Mantid::API::operator<<().
void Mantid::API::WorkspaceHistory::saveNexus | ( | ::NeXus::File * | file | ) | const |
Save the workspace history to a nexus file.
Saves all of the workspace history to a "process" field in an open NXS file.
Code taken from NexusFileIO.cpp on May 14, 2012.
file | :: previously opened NXS file. |
Definition at line 180 of file WorkspaceHistory.cpp.
References m_algorithms.
size_t Mantid::API::WorkspaceHistory::size | ( | ) | const |
How many entries are there.
Definition at line 103 of file WorkspaceHistory.cpp.
References m_algorithms.
Referenced by AlgorithmHistoryWindow::createExecSummaryGrpBox(), Mantid::Algorithms::GenerateIPythonNotebook::exec(), Mantid::Algorithms::GeneratePythonScript::exec(), export_WorkspaceHistory(), getAlgorithmHistory(), and lastAlgorithm().
|
private |
The algorithms which have been called on the workspace.
Definition at line 92 of file WorkspaceHistory.h.
Referenced by addHistory(), clearHistory(), empty(), getAlgorithmHistories(), getAlgorithmHistory(), lastAlgorithm(), operator==(), printSelf(), saveNexus(), and size().
|
private |
The environment of the workspace.
Definition at line 90 of file WorkspaceHistory.h.
Referenced by getEnvironmentHistory(), and printSelf().