13#include "MantidAPI/DllConfig.h"
20#include <boost/lexical_cast.hpp>
116 const std::string
id()
const override {
return "ITableWorkspace"; }
117 const std::string toString()
const override;
125 virtual bool addColumns(
const std::string &type,
const std::string &name,
size_t n);
175 virtual void sort(std::vector<std::pair<std::string, bool>> &criteria);
192 std::shared_ptr<Column> c = getColumn(name);
193 if (!c->isType<T>()) {
195 std::string(
"getRef: Type mismatch. ") +
typeid(T).name() +
" != " + c->get_type_info().name() +
'\n';
196 throw std::runtime_error(str);
198 return *(
static_cast<T *
>(c->void_pointer(
index)));
209 template <
class T> T &
cell(
size_t row,
size_t col) {
211 if (!c->isType<T>()) {
212 std::ostringstream ostr;
213 ostr <<
"cell: Type mismatch:\n" <<
typeid(T).name() <<
" != \n" << c->get_type_info().name() <<
'\n';
214 throw std::runtime_error(ostr.str());
216 if (row >= this->rowCount()) {
217 throw std::range_error(
"Table does not have row " +
std::to_string(row));
219 return *(
static_cast<T *
>(c->void_pointer(row)));
230 int &
Int(
size_t row,
size_t col) {
return cell<int>(row, col); }
239 double &
Double(
size_t row,
size_t col) {
return cell<double>(row, col); }
248 Boolean &
Bool(
size_t row,
size_t col) {
return cell<Boolean>(row, col); }
257 std::string &
String(
size_t row,
size_t col) {
return cell<std::string>(row, col); }
269 virtual void find(
size_t value,
size_t &row,
size_t col) = 0;
271 virtual void find(
double value,
size_t &row,
size_t col) = 0;
273 virtual void find(
float value,
size_t &row,
size_t col) = 0;
279 virtual void find(
const std::string &
value,
size_t &row,
size_t col) = 0;
326 std::stringstream mess;
327 mess <<
"Type mismatch when creating a ColumnVector<" <<
typeid(T).name() <<
">.";
328 throw std::runtime_error(mess.str());
334 std::stringstream mess;
335 mess <<
"Type mismatch when creating a ColumnVector<" <<
typeid(T).name() <<
">.";
336 throw std::runtime_error(mess.str());
361 std::stringstream mess;
362 mess <<
"Type mismatch when creating a ColumnVector<" <<
typeid(T).name() <<
">.";
363 throw std::runtime_error(mess.str());
369 std::stringstream mess;
370 mess <<
"Type mismatch when creating a ColumnVector<" <<
typeid(T).name() <<
">.";
371 throw std::runtime_error(mess.str());
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
ColumnVector gives access to the column elements without alowing its resizing.
ColumnVector(Column_sptr column)
Construct directly from column.
ColumnVector(const TableColumnHelper &th)
Constructor.
T & operator[](size_t i)
Get the element.
size_t size()
Size of the vector.
Column_sptr m_column
Pointer to the underlying column.
Column is the base class for columns of TableWorkspace.
virtual void remove(size_t index)=0
Removes an item.
virtual void resize(size_t count)=0
Sets the new column size.
virtual void insert(size_t index)=0
Inserts an item.
ConstColumnVector gives const access to the column elements without alowing its resizing.
Column_const_sptr m_column
Pointer to the underlying column.
size_t size()
Size of the vector.
const T & operator[](size_t i)
Get the const reference to element.
ConstColumnVector(Column_const_sptr column)
Construct directly from column.
ConstColumnVector(const TableConstColumnHelper &th)
Constructor.
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
virtual ITableWorkspace * doCloneColumns(const std::vector< std::string > &colNames) const =0
const std::string id() const override
Return the workspace typeID.
void removeFromColumn(Column *c, size_t index)
Remove an element from a column.
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
virtual void removeColumn(const std::string &name)=0
Removes a column.
virtual API::LogManager_const_sptr getLogs() const =0
Get constant access to shared pointer containing workspace properties.
T & getRef(const std::string &name, size_t index)
Get a reference to a data element.
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
ITableWorkspace(const ITableWorkspace &)=default
Protected copy constructor. May be used by childs for cloning.
virtual Column_const_sptr getColumn(size_t index) const =0
Gets the shared pointer to a column by index - return none-modifyable column.
virtual bool customSort() const
Does this type of TableWorkspace need a custom sorting call (e.g.
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
ITableWorkspace * doCloneEmpty() const override=0
Virtual cloneEmpty method.
T & cell(size_t row, size_t col)
Get the reference to the element in row row and column col.
virtual API::LogManager_sptr logs()=0
Get access to shared pointer containing workspace properties.
virtual Column_const_sptr getColumn(const std::string &name) const =0
Gets the shared pointer to a column by name.
virtual void setRowCount(size_t count)=0
Resizes the workspace.
ITableWorkspace_uptr cloneEmpty() const
Returns a default-initialized clone of the workspace.
TableRowHelper getFirstRow()
Creates a TableRow object for the first row (row == 0).
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
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.
virtual Column_sptr getColumn(const std::string &name)=0
Gets the shared pointer to a column by name.
ITableWorkspace()
Constructor.
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.
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.
Boolean & Bool(size_t row, size_t col)
Get the reference to the element in row row and column col if its type is bool.
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
virtual size_t insertRow(size_t index)=0
Inserts a row before row pointed to by index and fills it with default vales.
virtual void removeRow(size_t index)=0
Delets a row if it exists.
virtual Column_sptr addColumn(const std::string &type, const std::string &name)=0
Creates a new column.
ITableWorkspace_uptr clone() const
Returns a clone of the workspace.
void insertInColumn(Column *c, size_t index)
Insert a new element into a column.
TableRowHelper getRow(size_t row)
Creates a TableRow object for row row.
virtual size_t columnCount() const =0
Number of columns in the workspace.
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
virtual Column_sptr getColumn(size_t index)=0
Gets the shared pointer to a column by index.
virtual std::vector< std::string > getColumnNames() const =0
Returns a vector of all column names.
virtual size_t rowCount() const =0
Number of rows in the workspace.
void resizeColumn(Column *c, size_t size)
Resize a column.
ITableWorkspace & operator=(const ITableWorkspace &)=delete
ITableWorkspace * doClone() const override
Virtual clone method. Not implemented to force implementation in children.
Helper class used to create ColumnVector.
ITableWorkspace * m_workspace
Pointer to the TableWorkspace.
std::string m_name
column namae
TableColumnHelper(ITableWorkspace *tw, const std::string &name)
Constructor.
Helper class used to create ConstColumnVector.
TableConstColumnHelper(const ITableWorkspace *tw, const std::string &name)
Constructor.
std::string m_name
column namae
const ITableWorkspace * m_workspace
Pointer to the TableWorkspace.
Helper class used to create TableRow.
TableRowHelper(ITableWorkspace *tw, size_t row)
Constructor.
ITableWorkspace * m_workspace
Pointer to the TableWorkspace.
Base Workspace Abstract Class.
std::shared_ptr< const LogManager > LogManager_const_sptr
shared pointer to the logManager base class (const version)
std::shared_ptr< Column > Column_sptr
std::shared_ptr< LogManager > LogManager_sptr
shared pointer to the logManager base class
std::unique_ptr< ITableWorkspace > ITableWorkspace_uptr
unique pointer to Mantid::API::ITableWorkspace
std::shared_ptr< const Column > Column_const_sptr
Helper class which provides the Collimation Length for SANS instruments.
std::string to_string(const wide_integer< Bits, Signed > &n)
As TableColumn stores its data in a std::vector bool type cannot be used in the same way as the other...