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

ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same size. More...

#include <ITableWorkspace.h>

Inheritance diagram for Mantid::API::ITableWorkspace:
Mantid::API::Workspace Mantid::Kernel::DataItem Mantid::API::IPeaksWorkspace Mantid::DataObjects::TableWorkspace TableWorkspaceTester Mantid::DataObjects::LeanElasticPeaksWorkspace Mantid::DataObjects::PeaksWorkspace Mantid::DataObjects::MementoTableWorkspace Mantid::DataObjects::SplittersWorkspace

Public Member Functions

virtual Column_sptr addColumn (const std::string &type, const std::string &name)=0
 Creates a new column. More...
 
virtual bool addColumns (const std::string &type, const std::string &name, size_t n)
 Creates n new columns of the same type. More...
 
TableRowHelper appendRow ()
 Appends a row. More...
 
BooleanBool (size_t row, size_t col)
 Get the reference to the element in row row and column col if its type is bool. More...
 
template<class T >
T & cell (size_t row, size_t col)
 Get the reference to the element in row row and column col. More...
 
ITableWorkspace_uptr clone () const
 Returns a clone of the workspace. More...
 
ITableWorkspace_uptr cloneColumns (const std::vector< std::string > &colNames) const
 Returns a clone of the workspace. More...
 
ITableWorkspace_uptr cloneEmpty () const
 Returns a default-initialized clone of the workspace. More...
 
virtual size_t columnCount () const =0
 Number of columns in the workspace. More...
 
virtual bool customSort () const
 Does this type of TableWorkspace need a custom sorting call (e.g. More...
 
double & Double (size_t row, size_t col)
 Get the reference to the element in row row and column col if its type is double. More...
 
virtual void find (API::Boolean value, size_t &row, size_t col)=0
 find method to get the index of API::Boolean value cell in a table workspace More...
 
virtual void find (const Mantid::Kernel::V3D &value, size_t &row, size_t col)=0
 find method to get the index of Mantid::Kernel::V3D cell value in a table workspace More...
 
virtual void find (const std::string &value, size_t &row, size_t col)=0
 find method to get the index of cellstd::string value in a table workspace More...
 
virtual void find (double value, size_t &row, size_t col)=0
 find method to get the index of double cell value in a table workspace More...
 
virtual void find (float value, size_t &row, size_t col)=0
 find method to get the index of float cell value in a table workspace More...
 
virtual void find (size_t value, size_t &row, size_t col)=0
 find method to get the index of integer cell value in a table workspace More...
 
virtual Column_const_sptr getColumn (const std::string &name) const =0
 Gets the shared pointer to a column by name. More...
 
virtual Column_sptr getColumn (const std::string &name)=0
 Gets the shared pointer to a column by name. More...
 
virtual Column_const_sptr getColumn (size_t index) const =0
 Gets the shared pointer to a column by index - return none-modifyable column. More...
 
virtual Column_sptr getColumn (size_t index)=0
 Gets the shared pointer to a column by index. More...
 
virtual std::vector< std::string > getColumnNames () const =0
 Returns a vector of all column names. More...
 
TableRowHelper getFirstRow ()
 Creates a TableRow object for the first row (row == 0). More...
 
virtual API::LogManager_const_sptr getLogs () const =0
 Get constant access to shared pointer containing workspace properties. More...
 
template<class T >
T & getRef (const std::string &name, size_t index)
 Get a reference to a data element. More...
 
TableRowHelper getRow (size_t row)
 Creates a TableRow object for row row. More...
 
TableColumnHelper getVector (const std::string &name)
 Access the column with name name trough a ColumnVector object. More...
 
TableConstColumnHelper getVector (const std::string &name) const
 Access the column with name name trough a ColumnVector object. More...
 
const std::string id () const override
 Return the workspace typeID. More...
 
virtual size_t insertRow (size_t index)=0
 Inserts a row before row pointed to by index and fills it with default vales. More...
 
int & Int (size_t row, size_t col)
 Get the reference to the element in row row and column col if its type is int. More...
 
 ITableWorkspace ()
 Constructor. More...
 
virtual API::LogManager_sptr logs ()=0
 Get access to shared pointer containing workspace properties. More...
 
void modified ()
 If the workspace is the AnalysisDataService sends AfterReplaceNotification. More...
 
ITableWorkspaceoperator= (const ITableWorkspace &)=delete
 
virtual void removeColumn (const std::string &name)=0
 Removes a column. More...
 
virtual void removeRow (size_t index)=0
 Delets a row if it exists. More...
 
virtual size_t rowCount () const =0
 Number of rows in the workspace. More...
 
virtual void setRowCount (size_t count)=0
 Resizes the workspace. More...
 
virtual void sort (std::vector< std::pair< std::string, bool > > &criteria)
 Overridable method to custom-sort the workspace. More...
 
std::string & String (size_t row, size_t col)
 Get the reference to the element in row row and column col if its type is std::string. More...
 
const std::string toString () const override
 Serializes the object to a string. More...
 
- Public Member Functions inherited from Mantid::API::Workspace
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...
 
void readLock ()
 Acquires a read lock. More...
 
void unlock ()
 

Protected Member Functions

void insertInColumn (Column *c, size_t index)
 Insert a new element into a column. More...
 
 ITableWorkspace (const ITableWorkspace &)=default
 Protected copy constructor. May be used by childs for cloning. More...
 
void removeFromColumn (Column *c, size_t index)
 Remove an element from a column. More...
 
void resizeColumn (Column *c, size_t size)
 Resize a column. More...
 
- Protected Member Functions inherited from Mantid::API::Workspace
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

ITableWorkspacedoClone () const override
 Virtual clone method. Not implemented to force implementation in children. More...
 
virtual ITableWorkspacedoCloneColumns (const std::vector< std::string > &colNames) const =0
 
ITableWorkspacedoCloneEmpty () const override=0
 Virtual cloneEmpty method. More...
 

Detailed Description

ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same size.

Elements of a column have the same data type. Columns can be added to the TableWorkspace with ctreateColumn(type,name). name is a name given to the column. type is a symbolic name for the data type of the column. Predefined types are:

User defined types can be used after declaring them with DECLARE_TABLECOLUMN macro: DECLARE_TABLECOLUMN(typeName, UserDefinedType)

Ways to access the data:

Author
Roman Tolchenov
Date
31/10/2008

Definition at line 101 of file ITableWorkspace.h.

Constructor & Destructor Documentation

◆ ITableWorkspace() [1/2]

Mantid::API::ITableWorkspace::ITableWorkspace ( )
inline

Constructor.

Definition at line 104 of file ITableWorkspace.h.

◆ ITableWorkspace() [2/2]

Mantid::API::ITableWorkspace::ITableWorkspace ( const ITableWorkspace )
protecteddefault

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

Member Function Documentation

◆ addColumn()

virtual Column_sptr Mantid::API::ITableWorkspace::addColumn ( const std::string &  type,
const std::string &  name 
)
pure virtual

Creates a new column.

Parameters
type:: The datatype of the column
name:: The name to assign to the column
Returns
True if the column was successfully added

Implemented in Mantid::DataObjects::LeanElasticPeaksWorkspace, Mantid::DataObjects::PeaksWorkspace, TableWorkspaceTester, and Mantid::DataObjects::TableWorkspace.

Referenced by addColumns(), and ITableWorkspacePickleSuite::readMetaData().

◆ addColumns()

bool Mantid::API::ITableWorkspace::addColumns ( const std::string &  type,
const std::string &  name,
size_t  n 
)
virtual

Creates n new columns of the same type.

Parameters
type:: The datatype of the column
name:: The name to assign to the column
n:: The number of columns to create
Returns
True if the column was successfully added

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

Definition at line 35 of file ITableWorkspace.cpp.

References addColumn(), and n.

◆ appendRow()

TableRowHelper Mantid::API::ITableWorkspace::appendRow ( )

◆ Bool()

Boolean & Mantid::API::ITableWorkspace::Bool ( size_t  row,
size_t  col 
)
inline

Get the reference to the element in row row and column col if its type is bool.

If it doesn't match the actual type of the column a runtime_error exception is thrown.

Parameters
row:: Row number
col:: Column number
Returns
the reference of a requested cell if it's a boolean

Definition at line 248 of file ITableWorkspace.h.

◆ cell()

template<class T >
T & Mantid::API::ITableWorkspace::cell ( size_t  row,
size_t  col 
)
inline

Get the reference to the element in row row and column col.

Parameters
row:: Row number
col:: Column number
Template Parameters
TType of the data in the column. If it doesn't match the actual type a runtime_error exception is thrown.
Returns
the reference to the requested cell

Definition at line 209 of file ITableWorkspace.h.

References std::to_string().

◆ clone()

ITableWorkspace_uptr Mantid::API::ITableWorkspace::clone ( ) const
inline

Returns a clone of the workspace.

Definition at line 107 of file ITableWorkspace.h.

◆ cloneColumns()

ITableWorkspace_uptr Mantid::API::ITableWorkspace::cloneColumns ( const std::vector< std::string > &  colNames) const

Returns a clone of the workspace.

Parameters
colNames:: Names of the column to clone. If empty clone all columns.

Definition at line 16 of file ITableWorkspace.cpp.

References doCloneColumns().

◆ cloneEmpty()

ITableWorkspace_uptr Mantid::API::ITableWorkspace::cloneEmpty ( ) const
inline

Returns a default-initialized clone of the workspace.

Definition at line 110 of file ITableWorkspace.h.

◆ columnCount()

virtual size_t Mantid::API::ITableWorkspace::columnCount ( ) const
pure virtual

◆ customSort()

virtual bool Mantid::API::ITableWorkspace::customSort ( ) const
inlinevirtual

Does this type of TableWorkspace need a custom sorting call (e.g.

PeaksWorkspace)

Returns
true if the workspace needs custom sorting calls

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

Definition at line 172 of file ITableWorkspace.h.

◆ doClone()

ITableWorkspace * Mantid::API::ITableWorkspace::doClone ( ) const
inlineoverrideprivatevirtual

◆ doCloneColumns()

virtual ITableWorkspace * Mantid::API::ITableWorkspace::doCloneColumns ( const std::vector< std::string > &  colNames) const
privatepure virtual

◆ doCloneEmpty()

ITableWorkspace * Mantid::API::ITableWorkspace::doCloneEmpty ( ) const
overrideprivatepure virtual

◆ Double()

double & Mantid::API::ITableWorkspace::Double ( size_t  row,
size_t  col 
)
inline

Get the reference to the element in row row and column col if its type is double.

If it doesn't match the actual type of the column a runtime_error exception is thrown.

Parameters
row:: Row number
col:: Column number
Returns
the reference of a requested cell if it's a double

Definition at line 239 of file ITableWorkspace.h.

◆ find() [1/6]

virtual void Mantid::API::ITableWorkspace::find ( API::Boolean  value,
size_t &  row,
size_t  col 
)
pure virtual

◆ find() [2/6]

virtual void Mantid::API::ITableWorkspace::find ( const Mantid::Kernel::V3D value,
size_t &  row,
size_t  col 
)
pure virtual

◆ find() [3/6]

virtual void Mantid::API::ITableWorkspace::find ( const std::string &  value,
size_t &  row,
size_t  col 
)
pure virtual

find method to get the index of cellstd::string value in a table workspace

Implemented in Mantid::DataObjects::LeanElasticPeaksWorkspace, Mantid::DataObjects::PeaksWorkspace, TableWorkspaceTester, and Mantid::DataObjects::TableWorkspace.

◆ find() [4/6]

virtual void Mantid::API::ITableWorkspace::find ( double  value,
size_t &  row,
size_t  col 
)
pure virtual

find method to get the index of double cell value in a table workspace

Implemented in Mantid::DataObjects::TableWorkspace, Mantid::DataObjects::LeanElasticPeaksWorkspace, Mantid::DataObjects::PeaksWorkspace, and TableWorkspaceTester.

◆ find() [5/6]

virtual void Mantid::API::ITableWorkspace::find ( float  value,
size_t &  row,
size_t  col 
)
pure virtual

find method to get the index of float cell value in a table workspace

Implemented in Mantid::DataObjects::TableWorkspace, Mantid::DataObjects::LeanElasticPeaksWorkspace, Mantid::DataObjects::PeaksWorkspace, and TableWorkspaceTester.

◆ find() [6/6]

virtual void Mantid::API::ITableWorkspace::find ( size_t  value,
size_t &  row,
size_t  col 
)
pure virtual

find method to get the index of integer cell value in a table workspace

Implemented in Mantid::DataObjects::TableWorkspace, Mantid::DataObjects::LeanElasticPeaksWorkspace, Mantid::DataObjects::PeaksWorkspace, and TableWorkspaceTester.

◆ getColumn() [1/4]

virtual Column_const_sptr Mantid::API::ITableWorkspace::getColumn ( const std::string &  name) const
pure virtual

◆ getColumn() [2/4]

virtual Column_sptr Mantid::API::ITableWorkspace::getColumn ( const std::string &  name)
pure virtual

◆ getColumn() [3/4]

virtual Column_const_sptr Mantid::API::ITableWorkspace::getColumn ( size_t  index) const
pure virtual

Gets the shared pointer to a column by index - return none-modifyable column.

Implemented in Mantid::DataObjects::LeanElasticPeaksWorkspace, Mantid::DataObjects::PeaksWorkspace, Mantid::DataObjects::TableWorkspace, and TableWorkspaceTester.

◆ getColumn() [4/4]

virtual Column_sptr Mantid::API::ITableWorkspace::getColumn ( size_t  index)
pure virtual

◆ getColumnNames()

virtual std::vector< std::string > Mantid::API::ITableWorkspace::getColumnNames ( ) const
pure virtual

◆ getFirstRow()

TableRowHelper Mantid::API::ITableWorkspace::getFirstRow ( )
inline

Creates a TableRow object for the first row (row == 0).

Definition at line 266 of file ITableWorkspace.h.

◆ getLogs()

virtual API::LogManager_const_sptr Mantid::API::ITableWorkspace::getLogs ( ) const
pure virtual

Get constant access to shared pointer containing workspace properties.

Implemented in Mantid::DataObjects::LeanElasticPeaksWorkspace, Mantid::DataObjects::PeaksWorkspace, Mantid::DataObjects::TableWorkspace, and TableWorkspaceTester.

◆ getRef()

template<class T >
T & Mantid::API::ITableWorkspace::getRef ( const std::string &  name,
size_t  index 
)
inline

Get a reference to a data element.

Parameters
name:: Column name.
index:: Element's opsition in the column.
Template Parameters
TType of the data in the column. If it doesn't match the actual type a runtime_error exception is thrown.
Returns
the reference to the data element

Definition at line 191 of file ITableWorkspace.h.

References index.

◆ getRow()

TableRowHelper Mantid::API::ITableWorkspace::getRow ( size_t  row)
inline

Creates a TableRow object for row row.

Parameters
row:: Row number
Returns
the requested row

Definition at line 263 of file ITableWorkspace.h.

Referenced by appendRow(), and Mantid::DataObjects::SplittersWorkspace::getSplitter().

◆ getVector() [1/2]

TableColumnHelper Mantid::API::ITableWorkspace::getVector ( const std::string &  name)

Access the column with name name trough a ColumnVector object.

Parameters
name:: The name of the column
Returns
The named column

Definition at line 56 of file ITableWorkspace.cpp.

◆ getVector() [2/2]

TableConstColumnHelper Mantid::API::ITableWorkspace::getVector ( const std::string &  name) const

Access the column with name name trough a ColumnVector object.

Access the column with name name trough a ColumnVector object (const)

Parameters
name:: The name of the column
Returns
The named column

Definition at line 63 of file ITableWorkspace.cpp.

◆ id()

const std::string Mantid::API::ITableWorkspace::id ( ) const
inlineoverridevirtual

◆ insertInColumn()

void Mantid::API::ITableWorkspace::insertInColumn ( Column c,
size_t  index 
)
inlineprotected

Insert a new element into a column.

Parameters
c:: Pointer to the column
index:: Index in the column before which a new element wil be inserted.

Definition at line 301 of file ITableWorkspace.h.

References index, and Mantid::API::Column::insert().

Referenced by Mantid::DataObjects::TableWorkspace::insertRow().

◆ insertRow()

virtual size_t Mantid::API::ITableWorkspace::insertRow ( size_t  index)
pure virtual

Inserts a row before row pointed to by index and fills it with default vales.

Implemented in Mantid::DataObjects::TableWorkspace, Mantid::DataObjects::LeanElasticPeaksWorkspace, Mantid::DataObjects::PeaksWorkspace, and TableWorkspaceTester.

Referenced by appendRow().

◆ Int()

int & Mantid::API::ITableWorkspace::Int ( size_t  row,
size_t  col 
)
inline

Get the reference to the element in row row and column col if its type is int.

If it doesn't match the actual type of the column a runtime_error exception is thrown.

Parameters
row:: Row number
col:: Column number
Returns
the reference of a requested cell if it's an integer

Definition at line 230 of file ITableWorkspace.h.

◆ logs()

virtual API::LogManager_sptr Mantid::API::ITableWorkspace::logs ( )
pure virtual

◆ modified()

void Mantid::API::ITableWorkspace::modified ( )

◆ operator=()

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

◆ removeColumn()

virtual void Mantid::API::ITableWorkspace::removeColumn ( const std::string &  name)
pure virtual

◆ removeFromColumn()

void Mantid::API::ITableWorkspace::removeFromColumn ( Column c,
size_t  index 
)
inlineprotected

Remove an element from a column.

Parameters
c:: Pointer to the column
index:: Index of the element to be removed.

Definition at line 307 of file ITableWorkspace.h.

References index, and Mantid::API::Column::remove().

Referenced by Mantid::DataObjects::TableWorkspace::removeRow().

◆ removeRow()

virtual void Mantid::API::ITableWorkspace::removeRow ( size_t  index)
pure virtual

◆ resizeColumn()

void Mantid::API::ITableWorkspace::resizeColumn ( Column c,
size_t  size 
)
inlineprotected

Resize a column.

Parameters
c:: Pointer to the column
size:: New column size

Definition at line 294 of file ITableWorkspace.h.

References Mantid::API::Column::resize().

Referenced by Mantid::DataObjects::TableWorkspace::addColumn(), and Mantid::DataObjects::TableWorkspace::setRowCount().

◆ rowCount()

virtual size_t Mantid::API::ITableWorkspace::rowCount ( ) const
pure virtual

◆ setRowCount()

virtual void Mantid::API::ITableWorkspace::setRowCount ( size_t  count)
pure virtual

◆ sort()

void Mantid::API::ITableWorkspace::sort ( std::vector< std::pair< std::string, bool > > &  criteria)
virtual

Overridable method to custom-sort the workspace.

Parameters
criteria: a vector with a list of pairs: column name, bool; where bool = true for ascending, false for descending sort. The peaks are sorted by the first criterion first, then the 2nd if equal, etc.
Exceptions
std::runtime_errorunless overridden

Reimplemented in Mantid::DataObjects::TableWorkspace.

Definition at line 91 of file ITableWorkspace.cpp.

References UNUSED_ARG.

◆ String()

std::string & Mantid::API::ITableWorkspace::String ( size_t  row,
size_t  col 
)
inline

Get the reference to the element in row row and column col if its type is std::string.

If it doesn't match the actual type of the column a runtime_error exception is thrown.

Parameters
row:: Row number
col:: Column number
Returns
the reference of a requested cell if it's a string

Definition at line 257 of file ITableWorkspace.h.

◆ toString()

const std::string Mantid::API::ITableWorkspace::toString ( ) const
overridevirtual

Serializes the object to a string.

Implements Mantid::Kernel::DataItem.

Definition at line 20 of file ITableWorkspace.cpp.

References columnCount(), Mantid::API::Workspace::getMemorySizeAsStr(), id(), rowCount(), and std::to_string().

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


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