Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::API::WorkspaceHistory Class Reference

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< HistoryViewcreateView () const
 Create a flat view of the workspaces algorithm history. More...
 
bool empty () const
 Is the history empty. More...
 
std::shared_ptr< IAlgorithmgetAlgorithm (const size_t index) const
 Create an algorithm from a history record at a given index. More...
 
const AlgorithmHistoriesgetAlgorithmHistories () 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::EnvironmentHistorygetEnvironmentHistory () const
 Retrieve the environment history. More...
 
std::shared_ptr< IAlgorithmlastAlgorithm () const
 Convenience function for retrieving the last algorithm. More...
 
void loadNexus (::NeXus::File *file)
 Load the workspace history from a nexus file. More...
 
WorkspaceHistoryoperator= (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...
 

Detailed Description

This class stores information about the Workspace History used by algorithms on a workspace and the environment history.

Author
Dickon Champion, ISIS, RAL
Date
21/01/2008

Definition at line 35 of file WorkspaceHistory.h.

Constructor & Destructor Documentation

◆ WorkspaceHistory() [1/2]

Mantid::API::WorkspaceHistory::WorkspaceHistory ( )

Default constructor.

Default Constructor.

Definition at line 57 of file WorkspaceHistory.cpp.

◆ ~WorkspaceHistory()

virtual Mantid::API::WorkspaceHistory::~WorkspaceHistory ( )
virtualdefault

Destructor.

◆ WorkspaceHistory() [2/2]

Mantid::API::WorkspaceHistory::WorkspaceHistory ( const WorkspaceHistory )
default

Copy constructor.

Member Function Documentation

◆ addHistory() [1/2]

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.

◆ addHistory() [2/2]

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().

◆ clearHistory()

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.

◆ createView()

std::shared_ptr< HistoryView > Mantid::API::WorkspaceHistory::createView ( ) const

◆ empty()

bool Mantid::API::WorkspaceHistory::empty ( ) const

Is the history empty.

Query if the history is empty or not.

Returns
True if the list is empty, false otherwise

Definition at line 109 of file WorkspaceHistory.cpp.

References m_algorithms.

Referenced by AlgorithmHistoryWindow::AlgorithmHistoryWindow(), and export_WorkspaceHistory().

◆ findHistoryEntries()

std::set< int > Mantid::API::WorkspaceHistory::findHistoryEntries ( ::NeXus::File *  file)
private

Find the history entries at this level in the file.

Find all the algorithm entries at a particular point the the nexus file.

Parameters
file:: The handle to the nexus file
Returns
set of integers. One for each algorithm at the level in the file.

Definition at line 314 of file WorkspaceHistory.cpp.

References Mantid::Kernel::Strings::convert().

Referenced by loadNestedHistory().

◆ getAlgorithm()

std::shared_ptr< IAlgorithm > Mantid::API::WorkspaceHistory::getAlgorithm ( const size_t  index) const

Create an algorithm from a history record at a given index.

Parameters
index:: An index within the workspace history
Returns
A shared pointer to an algorithm object

Definition at line 144 of file WorkspaceHistory.cpp.

References Mantid::API::Algorithm::fromHistory(), and getAlgorithmHistory().

Referenced by export_WorkspaceHistory(), and lastAlgorithm().

◆ getAlgorithmHistories()

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().

◆ getAlgorithmHistory()

AlgorithmHistory_const_sptr Mantid::API::WorkspaceHistory::getAlgorithmHistory ( const size_t  index) const

Retrieve an algorithm history by index.

Parameters
index:: An index within the workspace history
Returns
A pointer to an AlgorithmHistory object
Exceptions
std::out_of_rangeerror 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[]().

◆ getEnvironmentHistory()

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.

◆ lastAlgorithm()

std::shared_ptr< IAlgorithm > Mantid::API::WorkspaceHistory::lastAlgorithm ( ) const

Convenience function for retrieving the last algorithm.

Returns
A shared pointer to the algorithm

Definition at line 152 of file WorkspaceHistory.cpp.

References getAlgorithm(), m_algorithms, and size().

Referenced by export_WorkspaceHistory().

◆ loadNestedHistory()

void Mantid::API::WorkspaceHistory::loadNestedHistory ( ::NeXus::File *  file,
const AlgorithmHistory_sptr parent = std::shared_ptr<AlgorithmHistory>() 
)
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.

Parameters
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().

◆ 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.

Parameters
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().

◆ operator=()

WorkspaceHistory & Mantid::API::WorkspaceHistory::operator= ( const WorkspaceHistory )
delete

Deleted copy assignment operator since m_environment has no copy assignment.

References std::operator==().

◆ 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.

◆ operator[]()

AlgorithmHistory_const_sptr Mantid::API::WorkspaceHistory::operator[] ( const size_t  index) const

Add operator[] access.

Index operator[] access to a workspace history.

Parameters
index:: An index within the workspace history
Returns
A pointer to an AlgorithmHistory object
Exceptions
std::out_of_rangeerror if the index is invalid

Definition at line 135 of file WorkspaceHistory.cpp.

References getAlgorithmHistory(), and index.

◆ parseAlgorithmHistory()

AlgorithmHistory_sptr Mantid::API::WorkspaceHistory::parseAlgorithmHistory ( const std::string &  rawData)
private

Parse an algorithm history string loaded from file.

Parse an algorithm history entry loaded from file.

Parameters
rawData:: The string containing the history entry loaded from file
Returns
a pointer to the loaded algorithm history object
Exceptions
std::runtime_errorif 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().

◆ printSelf()

void Mantid::API::WorkspaceHistory::printSelf ( std::ostream &  os,
const int  indent = 0 
) const

Pretty print the entire history.

Prints a text representation of itself.

Parameters
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<<().

◆ saveNexus()

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.

Parameters
file:: previously opened NXS file.

Definition at line 180 of file WorkspaceHistory.cpp.

References m_algorithms.

◆ size()

size_t Mantid::API::WorkspaceHistory::size ( ) const

Member Data Documentation

◆ m_algorithms

Mantid::API::AlgorithmHistories Mantid::API::WorkspaceHistory::m_algorithms
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().

◆ m_environment

const Kernel::EnvironmentHistory Mantid::API::WorkspaceHistory::m_environment
private

The environment of the workspace.

Definition at line 90 of file WorkspaceHistory.h.

Referenced by getEnvironmentHistory(), and printSelf().


The documentation for this class was generated from the following files: