Mantid
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Mantid::API::Workspace Class Referenceabstract

Base Workspace Abstract Class. More...

#include <Workspace.h>

Inheritance diagram for Mantid::API::Workspace:
Mantid::Kernel::DataItem FakeWorkspace Mantid::API::IMDWorkspace Mantid::API::ITableWorkspace Mantid::API::WorkspaceGroup Mantid::API::IMDEventWorkspace Mantid::API::IMDHistoWorkspace Mantid::API::MatrixWorkspace Mantid::API::IPeaksWorkspace Mantid::DataObjects::TableWorkspace TableWorkspaceTester Mantid::DataObjects::MDEventWorkspace MDHistoWorkspaceTester Mantid::DataObjects::MDHistoWorkspace AxeslessWorkspaceTester Mantid::API::HistoWorkspace Mantid::API::IEventWorkspace Mantid::DataObjects::LeanElasticPeaksWorkspace Mantid::DataObjects::PeaksWorkspace Mantid::DataObjects::MementoTableWorkspace Mantid::DataObjects::SplittersWorkspace

Public Member Functions

Workspace_uptr clone () const
 Returns a clone (copy) of the workspace with covariant return type in all derived classes. More...
 
Workspace_uptr cloneEmpty () const
 Returns a default-initialized clone of the workspace. More...
 
const std::string & getComment () const
 Get the workspace comment. More...
 
const WorkspaceHistorygetHistory () const
 Returns a reference to the WorkspaceHistory const. More...
 
virtual size_t getMemorySize () const =0
 Get the footprint in memory in bytes. More...
 
std::string getMemorySizeAsStr () const
 Returns the memory footprint in sensible units. More...
 
const std::string & getName () const override
 Get the workspace name. More...
 
virtual const std::string getTitle () const
 Get the workspace title. More...
 
WorkspaceHistoryhistory ()
 Returns a reference to the WorkspaceHistory. More...
 
bool isDirty (const int n=1) const
 Check whether other algorithms have been applied to the workspace by checking the history length. More...
 
virtual bool isGroup () const
 
Workspaceoperator= (const Workspace &other)=delete
 
void setComment (const std::string &)
 Set the comment field of the workspace. More...
 
virtual void setTitle (const std::string &)
 Set the title of the workspace. More...
 
Parallel::StorageMode storageMode () const
 Returns the storage mode (used for MPI runs) More...
 
bool threadSafe () const override
 Marks the workspace as safe for multiple threads to edit data simutaneously. More...
 
 Workspace (const Parallel::StorageMode storageMode=Parallel::StorageMode::Cloned)
 
 ~Workspace ()
 
- Public Member Functions inherited from Mantid::Kernel::DataItem
 DataItem ()
 Default constructor. More...
 
 DataItem (const DataItem &other)
 Copy constructor Always makes a unique lock. More...
 
virtual ~DataItem ()
 Destructor. More...
 
virtual const std::string id () const =0
 A string ID for the class. More...
 
virtual const std::string toString () const =0
 Serializes the object to a string. More...
 
void readLock ()
 Acquires a read lock. More...
 
void unlock ()
 

Protected Member Functions

void setStorageMode (Parallel::StorageMode mode)
 Sets the storage mode (used for MPI runs) More...
 
 Workspace (const Workspace &)
 Protected copy constructor. May be used by childs for cloning. More...
 
- Protected Member Functions inherited from Mantid::Kernel::DataItem
Poco::RWLock * getLock () const
 Private method to access the RWLock object. More...
 

Private Member Functions

virtual WorkspacedoClone () const =0
 Virtual clone method. Not implemented to force implementation in children. More...
 
virtual WorkspacedoCloneEmpty () const =0
 Virtual cloneEmpty method. More...
 
void setName (const std::string &)
 Set the name field of the workspace. More...
 

Private Attributes

std::string m_comment
 A user-provided comment that is attached to the workspace. More...
 
std::unique_ptr< WorkspaceHistorym_history
 The history of the workspace, algorithm and environment. More...
 
std::string m_name
 The name associated with the object within the ADS (This is required for workspace algebra. More...
 
Parallel::StorageMode m_storageMode
 Storage mode of the Workspace (used for MPI runs) More...
 
std::string m_title
 The title of the workspace. More...
 

Friends

class AnalysisDataServiceImpl
 

Detailed Description

Base Workspace Abstract Class.

Author
Laurent C Chapon, ISIS, RAL
Date
26/09/2007

Definition at line 30 of file Workspace.h.

Constructor & Destructor Documentation

◆ Workspace() [1/2]

Mantid::API::Workspace::Workspace ( const Parallel::StorageMode  storageMode = Parallel::StorageMode::Cloned)

Definition at line 14 of file Workspace.cpp.

◆ ~Workspace()

Mantid::API::Workspace::~Workspace ( )
default

◆ Workspace() [2/2]

Mantid::API::Workspace::Workspace ( const Workspace other)
protected

Protected copy constructor. May be used by childs for cloning.

Definition at line 20 of file Workspace.cpp.

Member Function Documentation

◆ clone()

Workspace_uptr Mantid::API::Workspace::clone ( ) const
inline

Returns a clone (copy) of the workspace with covariant return type in all derived classes.

Note that this public function is not virtual. This has two reasons:

  • We want to enforce covariant return types. If this public clone() method was virtual some derived class might fail to reimplement it. Since there are several levels of inheritance in the Workspace inheritance tree we cannot just use a pure virtual method in the base class. Thus, we use this non-virtual interface method which calls the private and virtual doClone() method. Since it is private, failing to reimplement it will cause a compiler error as a reminder. Note that this mechanism does not always work if a derived class does not implement clone(): if doClone() in a parent is implemented then calling clone on a base class will return a clone of the parent defining doClone, not the actual instance. This is more a problem of the inheritance structure, i.e., whether or not all non-leaf classes are pure virtual and declare doClone()=0.
  • Covariant return types are in conflict with smart pointers, but if clone() is not virtual this is a non-issue.

Definition at line 54 of file Workspace.h.

◆ cloneEmpty()

Workspace_uptr Mantid::API::Workspace::cloneEmpty ( ) const
inline

Returns a default-initialized clone of the workspace.

Definition at line 57 of file Workspace.h.

◆ doClone()

virtual Workspace * Mantid::API::Workspace::doClone ( ) const
privatepure virtual

◆ doCloneEmpty()

virtual Workspace * Mantid::API::Workspace::doCloneEmpty ( ) const
privatepure virtual

◆ getComment()

const std::string & Mantid::API::Workspace::getComment ( ) const

Get the workspace comment.

Returns
The comment

Definition at line 52 of file Workspace.cpp.

References m_comment.

Referenced by export_Workspace(), and Mantid::API::WorkspaceFactoryImpl::initializeFromParent().

◆ getHistory()

const WorkspaceHistory & Mantid::API::Workspace::getHistory ( ) const
inline

◆ getMemorySize()

virtual size_t Mantid::API::Workspace::getMemorySize ( ) const
pure virtual

◆ getMemorySizeAsStr()

std::string Mantid::API::Workspace::getMemorySizeAsStr ( ) const

Returns the memory footprint in sensible units.

Returns
A string with the

Definition at line 77 of file Workspace.cpp.

References getMemorySize(), and Mantid::Kernel::memToString< uint64_t >().

Referenced by Mantid::API::ITableWorkspace::toString().

◆ getName()

const std::string & Mantid::API::Workspace::getName ( ) const
overridevirtual

◆ getTitle()

const std::string Mantid::API::Workspace::getTitle ( ) const
virtual

Get the workspace title.

Returns
The title

Reimplemented in Mantid::API::MatrixWorkspace.

Definition at line 46 of file Workspace.cpp.

References m_title.

Referenced by export_Workspace(), Mantid::API::MatrixWorkspace::getTitle(), and Mantid::API::IMDWorkspace::toString().

◆ history()

WorkspaceHistory & Mantid::API::Workspace::history ( )
inline

Returns a reference to the WorkspaceHistory.

Definition at line 82 of file Workspace.h.

Referenced by Mantid::MDAlgorithms::LoadMD::doLoad().

◆ isDirty()

bool Mantid::API::Workspace::isDirty ( const int  n = 1) const

Check whether other algorithms have been applied to the workspace by checking the history length.

By default a workspace is called dirty if its history is longer than one. This default can be changed to allow for workspace creation processes that necessitate more than a single algorithm.

Parameters
nnumber of algorithms defining a clean workspace

Definition at line 71 of file Workspace.cpp.

References m_history, and n.

Referenced by export_Workspace().

◆ isGroup()

virtual bool Mantid::API::Workspace::isGroup ( ) const
inlinevirtual

Reimplemented in Mantid::API::WorkspaceGroup.

Definition at line 75 of file Workspace.h.

Referenced by export_Workspace().

◆ operator=()

Workspace & Mantid::API::Workspace::operator= ( const Workspace other)
delete

◆ setComment()

void Mantid::API::Workspace::setComment ( const std::string &  c)

Set the comment field of the workspace.

Parameters
c:: The comment

Definition at line 34 of file Workspace.cpp.

References m_comment.

Referenced by export_Workspace(), and Mantid::API::WorkspaceFactoryImpl::initializeFromParent().

◆ setName()

void Mantid::API::Workspace::setName ( const std::string &  name)
private

Set the name field of the workspace.

Parameters
name:: The name

Definition at line 40 of file Workspace.cpp.

References m_name.

◆ setStorageMode()

void Mantid::API::Workspace::setStorageMode ( Parallel::StorageMode  mode)
protected

Sets the storage mode (used for MPI runs)

Definition at line 85 of file Workspace.cpp.

References m_storageMode, and storageMode().

Referenced by Mantid::API::MatrixWorkspace::initialize(), and Mantid::API::MatrixWorkspace::setIndexInfoWithoutISpectrumUpdate().

◆ setTitle()

void Mantid::API::Workspace::setTitle ( const std::string &  t)
virtual

Set the title of the workspace.

Parameters
t:: The title

Reimplemented in Mantid::API::MatrixWorkspace.

Definition at line 28 of file Workspace.cpp.

References m_title.

Referenced by Mantid::MDAlgorithms::LoadMD::doLoad(), export_Workspace(), and Mantid::API::MatrixWorkspace::setTitle().

◆ storageMode()

Parallel::StorageMode Mantid::API::Workspace::storageMode ( ) const

◆ threadSafe()

bool Mantid::API::Workspace::threadSafe ( ) const
inlineoverridevirtual

Marks the workspace as safe for multiple threads to edit data simutaneously.

Workspace creation is always considered to be a single threaded operation.

Returns
true if the workspace is suitable for multithreaded operations, otherwise false.

Implements Mantid::Kernel::DataItem.

Reimplemented in Mantid::DataObjects::EventWorkspace, Mantid::DataObjects::LeanElasticPeaksWorkspace, Mantid::DataObjects::PeaksWorkspace, and MDHistoWorkspaceTester.

Definition at line 67 of file Workspace.h.

Referenced by Mantid::API::MatrixWorkspace::createIterators(), Mantid::DataObjects::MDHistoWorkspace::createIterators(), and Mantid::API::MatrixWorkspace::getIntegratedSpectra().

Friends And Related Function Documentation

◆ AnalysisDataServiceImpl

friend class AnalysisDataServiceImpl
friend

Definition at line 113 of file Workspace.h.

Member Data Documentation

◆ m_comment

std::string Mantid::API::Workspace::m_comment
private

A user-provided comment that is attached to the workspace.

Definition at line 98 of file Workspace.h.

Referenced by getComment(), and setComment().

◆ m_history

std::unique_ptr<WorkspaceHistory> Mantid::API::Workspace::m_history
private

The history of the workspace, algorithm and environment.

Definition at line 103 of file Workspace.h.

Referenced by isDirty().

◆ m_name

std::string Mantid::API::Workspace::m_name
private

The name associated with the object within the ADS (This is required for workspace algebra.

Definition at line 101 of file Workspace.h.

Referenced by getName(), and setName().

◆ m_storageMode

Parallel::StorageMode Mantid::API::Workspace::m_storageMode
private

Storage mode of the Workspace (used for MPI runs)

Definition at line 105 of file Workspace.h.

Referenced by setStorageMode(), and storageMode().

◆ m_title

std::string Mantid::API::Workspace::m_title
private

The title of the workspace.

Definition at line 96 of file Workspace.h.

Referenced by getTitle(), and setTitle().


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