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

#include <NotebookBuilder.h>

Public Member Functions

const std::string build (const std::string &ws_name, const std::string &ws_title, const std::string &ws_comment)
 build an ipython notebook from the history view More...
 
 NotebookBuilder (const std::shared_ptr< HistoryView > &view, std::string versionSpecificity="old")
 
virtual ~NotebookBuilder ()=default
 

Private Member Functions

const std::string buildAlgorithmString (const AlgorithmHistory_const_sptr &algHistory)
 Build the script output for a single algorithm. More...
 
void buildChildren (std::vector< HistoryItem >::const_iterator &iter)
 Iterate over each of the items children and output them to the script. More...
 
const std::string buildPropertyString (const Mantid::Kernel::PropertyHistory_const_sptr &propHistory)
 Build the script output for a single property. More...
 
void writeHistoryToStream (std::vector< HistoryItem >::const_iterator &iter)
 Write out an algorithm to the notebook. More...
 

Private Attributes

const std::vector< HistoryItemm_historyItems
 
std::unique_ptr< NotebookWriterm_nb_writer
 
std::string m_output
 
std::string m_versionSpecificity
 

Detailed Description

Definition at line 27 of file NotebookBuilder.h.

Constructor & Destructor Documentation

◆ NotebookBuilder()

NotebookBuilder::NotebookBuilder ( const std::shared_ptr< HistoryView > &  view,
std::string  versionSpecificity = "old" 
)

Definition at line 28 of file NotebookBuilder.cpp.

◆ ~NotebookBuilder()

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

Member Function Documentation

◆ build()

const std::string NotebookBuilder::build ( const std::string &  ws_name,
const std::string &  ws_title,
const std::string &  ws_comment 
)

build an ipython notebook from the history view

Build an ipython notebook for algorithms included in the history view.

Parameters
ws_name:: workspace name
ws_title:: workspace title
ws_comment:: workspace comment
Returns
a formatted ipython notebook string of the history

Definition at line 40 of file NotebookBuilder.cpp.

References m_historyItems, m_nb_writer, and writeHistoryToStream().

Referenced by Mantid::Algorithms::GenerateIPythonNotebook::exec().

◆ buildAlgorithmString()

const std::string NotebookBuilder::buildAlgorithmString ( const AlgorithmHistory_const_sptr algHistory)
private

Build the script output for a single algorithm.

Parameters
algHistory:: pointer to an algorithm history object
Returns
std::string to run this algorithm

Definition at line 104 of file NotebookBuilder.cpp.

References buildPropertyString(), Mantid::Kernel::SingletonHolder< T >::Instance(), and m_versionSpecificity.

Referenced by writeHistoryToStream().

◆ buildChildren()

void NotebookBuilder::buildChildren ( std::vector< HistoryItem >::const_iterator &  iter)
private

Iterate over each of the items children and output them to the script.

This moves the iterator forward over each of the child records and writes them to the stream.

Parameters
iter:: reference to the iterator pointing to the vector of history items

Definition at line 89 of file NotebookBuilder.cpp.

References m_historyItems, and writeHistoryToStream().

Referenced by writeHistoryToStream().

◆ buildPropertyString()

const std::string NotebookBuilder::buildPropertyString ( const Mantid::Kernel::PropertyHistory_const_sptr propHistory)
private

Build the script output for a single property.

Parameters
propHistory:: reference to a property history object
Returns
std::string for this property

Definition at line 153 of file NotebookBuilder.cpp.

References Mantid::Kernel::Logger::debug(), Mantid::API::g_log, Mantid::Kernel::Direction::Output, and value.

Referenced by buildAlgorithmString().

◆ writeHistoryToStream()

void NotebookBuilder::writeHistoryToStream ( std::vector< HistoryItem >::const_iterator &  iter)
private

Write out an algorithm to the notebook.

If the entry is unrolled this will recurse and output the children of that entry instead. If not, it will just output the algorithm to the stream.

Parameters
iter:: reference to the iterator pointing to the vector of history items

Definition at line 65 of file NotebookBuilder.cpp.

References buildAlgorithmString(), buildChildren(), and m_nb_writer.

Referenced by build(), and buildChildren().

Member Data Documentation

◆ m_historyItems

const std::vector<HistoryItem> Mantid::API::NotebookBuilder::m_historyItems
private

Definition at line 40 of file NotebookBuilder.h.

Referenced by build(), and buildChildren().

◆ m_nb_writer

std::unique_ptr<NotebookWriter> Mantid::API::NotebookBuilder::m_nb_writer
private

Definition at line 43 of file NotebookBuilder.h.

Referenced by build(), and writeHistoryToStream().

◆ m_output

std::string Mantid::API::NotebookBuilder::m_output
private

Definition at line 41 of file NotebookBuilder.h.

◆ m_versionSpecificity

std::string Mantid::API::NotebookBuilder::m_versionSpecificity
private

Definition at line 42 of file NotebookBuilder.h.

Referenced by buildAlgorithmString().


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