Mantid
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
Mantid::DataObjects::TableColumn< Type > Class Template Reference

Class TableColumn implements abstract class Column for any copyable data type. More...

#include <TableColumn.h>

Inheritance diagram for Mantid::DataObjects::TableColumn< Type >:
Mantid::API::Column

Classes

struct  InconvertibleToDoubleType
 Helper struct helping to write a generic casting to double. More...
 

Public Member Functions

TableColumnclone () const override
 Clone. More...
 
double convertToDouble (const std::string &value) const
 Cast an string to double if possible. More...
 
template<typename T >
double convertToDouble (const T &value) const
 Cast an element to double if possible. More...
 
std::vector< Type > & data ()
 Reference to the data. More...
 
const std::vector< Type > & data () const
 Const reference to the data. More...
 
Type * dataArray ()
 Pointer to the data array. More...
 
bool equals (const Column &otherColumn, double tolerance) const override
 
bool equalsRelErr (const Column &otherColumn, double tolerance) const override
 
void fromDouble (size_t i, double value)
 Assign an element from double if possible. More...
 
void fromDouble (size_t i, double value) override
 Cast an element to double if possible. More...
 
const std::type_info & get_pointer_type_info () const override
 Type id of the pointer to data in the column. More...
 
const std::type_info & get_type_info () const override
 Type id of the data in the column. More...
 
bool isBool () const override
 Type check. More...
 
bool isNumber () const override
 Are elements of the column interpretable as a number? More...
 
double operator[] (size_t i) const override
 return a value casted to double; the users responsibility is to be sure, that the casting is possible More...
 
void print (size_t index, std::ostream &s) const override
 Output to an ostream. More...
 
void read (const size_t index, std::istringstream &in) override
 Read in from stream and set the value at the given index. More...
 
void read (size_t index, const std::string &text)
 Template specialization for strings so they can contain spaces. More...
 
void read (size_t index, const std::string &text) override
 Read in a string and set the value at the given index. More...
 
void read (size_t index, std::istringstream &text)
 Template specialization for strings so they can contain spaces. More...
 
size_t size () const override
 Number of individual elements in the column. More...
 
long int sizeOfData () const override
 Memory used by the column. More...
 
void sortIndex (bool ascending, size_t start, size_t end, std::vector< size_t > &indexVec, std::vector< std::pair< size_t, size_t > > &equalRanges) const override
 Sort a vector of indices according to values in corresponding cells of this column. More...
 
void sortValues (const std::vector< size_t > &indexVec) override
 Re-arrange values in this column according to indices in indexVec. More...
 
 TableColumn ()
 
double toDouble (size_t i) const
 Cast an element to double if possible. More...
 
double toDouble (size_t i) const override
 Cast an element to double if possible. More...
 
- Public Member Functions inherited from Mantid::API::Column
template<class T >
T & cell (size_t index)
 Templated method for returning a value. No type checks are done. More...
 
template<class T >
const T & cell (size_t index) const
 Templated method for returning a value (const version). More...
 
virtual Columnclone () const =0
 Virtual constructor. Fully clone any column. More...
 
 Column ()
 
virtual bool equals (const Column &, double) const
 
virtual bool equalsRelErr (const Column &, double) const
 
virtual void fromDouble (size_t index, double value)=0
 Assign an element from double if possible. More...
 
virtual const std::type_info & get_pointer_type_info () const =0
 Returns typeid for the pointer type to the data element in the column. More...
 
virtual const std::type_info & get_type_info () const =0
 Returns typeid for the data in the column. More...
 
int getLinkedYCol () const
 
int getPlotType () const
 get plot type More...
 
virtual bool getReadOnly () const
 Returns column read-only flag. More...
 
virtual bool isBool () const =0
 Specialized type check. More...
 
virtual bool isNumber () const =0
 Are elements of the column interpretable as a number? More...
 
template<class T >
bool isType () const
 Type check. More...
 
template<>
bool isType () const
 
const std::string & name () const
 Name (caption) of the column. More...
 
template<class T = double>
std::vector< T > numeric_fill (size_t maxSize=std::numeric_limits< size_t >::max()) const
 Fills a std vector with values from the column if the types are compatible. More...
 
virtual double operator[] (size_t i) const
 return value casted to double (should be pure virtual) More...
 
virtual void print (size_t index, std::ostream &s) const =0
 Prints out the value to a stream. More...
 
virtual void read (const size_t index, std::istringstream &in)
 Read in from stream and set the value at the given index. More...
 
virtual void read (size_t index, const std::string &text)
 Read in a string and set the value at the given index. More...
 
void setLinkedYCol (const int yCol)
 
void setName (const std::string &str)
 Renames the column. More...
 
void setPlotType (int t)
 Set plot type where. More...
 
void setReadOnly (bool isReadOnly)
 Sets column read-only flag. More...
 
virtual size_t size () const =0
 Number of individual elements in the column. More...
 
virtual long int sizeOfData () const =0
 Must return overall memory size taken by the column. More...
 
virtual void sortIndex (bool ascending, size_t start, size_t end, std::vector< size_t > &indexVec, std::vector< std::pair< size_t, size_t > > &equalRanges) const
 Sort all or part of a vector of indices according to values in corresponding cells of this column. More...
 
virtual void sortValues (const std::vector< size_t > &indexVec)
 Re-arrange values in this column according to indices in indexVec. More...
 
virtual double toDouble (size_t index) const =0
 Cast an element to double if possible. More...
 
const std::string & type () const
 Type of the column data. More...
 
virtual ~Column ()=default
 Virtual destructor. More...
 

Protected Member Functions

void insert (size_t index) override
 Inserts default value at position index. More...
 
void remove (size_t index) override
 Removes an item at index. More...
 
void resize (size_t count) override
 Resize. More...
 
const void * void_pointer (size_t index) const override
 Returns a pointer to the data element. More...
 
void * void_pointer (size_t index) override
 Returns a pointer to the data element. More...
 
- Protected Member Functions inherited from Mantid::API::Column
virtual void insert (size_t index)=0
 Inserts an item. More...
 
bool possibleToCompare (const Column &otherColumn) const
 
virtual void remove (size_t index)=0
 Removes an item. More...
 
virtual void resize (size_t count)=0
 Sets the new column size. More...
 
virtual const void * void_pointer (size_t index) const =0
 Pointer to a data element. More...
 
virtual void * void_pointer (size_t index)=0
 Pointer to a data element. More...
 

Private Member Functions

bool compareVectors (const std::vector< API::Boolean > &newVector, double tolerance) const
 Template specialisation for strings for comparison. More...
 
bool compareVectors (const std::vector< int64_t > &newVector, double tolerance) const
 Template specialisation for long64. More...
 
bool compareVectors (const std::vector< Kernel::V3D > &newVector, double tolerance) const
 Template specialisation for V3D for comparison. More...
 
bool compareVectors (const std::vector< std::string > &newVector, double tolerance) const
 Template specialisation for strings for comparison. More...
 
bool compareVectors (const std::vector< Type > &newVector, double tolerance) const
 
bool compareVectors (const std::vector< unsigned long > &newVector, double tolerance) const
 Template specialisation for unsigned long int. More...
 
bool compareVectorsRelError (const std::vector< API::Boolean > &newVector, double tolerance) const
 Template specialisation for bools for comparison. More...
 
bool compareVectorsRelError (const std::vector< int64_t > &newVector, double tolerance) const
 Template specialisation for long64 with relative error. More...
 
bool compareVectorsRelError (const std::vector< Kernel::V3D > &newVector, double tolerance) const
 Template specialisation for V3D for comparison. More...
 
bool compareVectorsRelError (const std::vector< std::string > &newVector, double tolerance) const
 Template specialisation for strings for comparison. More...
 
bool compareVectorsRelError (const std::vector< Type > &newVector, double tolerance) const
 
bool compareVectorsRelError (const std::vector< unsigned long > &newVector, double tolerance) const
 Template specialisation for unsigned long int. More...
 

Private Attributes

std::vector< Type > m_data
 Column data. More...
 

Friends

class TableWorkspace
 

Additional Inherited Members

- Protected Attributes inherited from Mantid::API::Column
bool m_isReadOnly
 Column read-only flag. More...
 
int m_linkedYCol = -1
 For error columns - the index of the related data column. More...
 
std::string m_name
 name More...
 
int m_plotType
 plot type where None = 0 (means it has specifically been set to 'no plot type') NotSet = -1000 (this is the default and means plot style has not been set) X = 1, Y = 2, Z = 3, xErr = 4, yErr = 5, Label = 6 More...
 
std::string m_type
 type More...
 

Detailed Description

template<class Type>
class Mantid::DataObjects::TableColumn< Type >

Class TableColumn implements abstract class Column for any copyable data type.

A TableColumn is created using TableWorkspace::addColumn(type,name). type is the simbolic name of the data type which must be first declared with DECLARE_TABLECOLUMN macro. Predeclared types are:

"int" for int "int32_t" for int32_t "size_t" for size_t "float" for float "double" for double "bool" for Boolean "str" for std::string "V3D" for Mantid::Kernel::V3D

Boolean is used instead of bool because of bool's non-standard treatmemt in std::vector.

Author
Roman Tolchenov
Date
31/10/2008

Definition at line 45 of file TableColumn.h.

Constructor & Destructor Documentation

◆ TableColumn()

template<class Type >
Mantid::DataObjects::TableColumn< Type >::TableColumn ( )
inline

Member Function Documentation

◆ clone()

template<class Type >
TableColumn * Mantid::DataObjects::TableColumn< Type >::clone ( ) const
inlineoverridevirtual

Clone.

Implements Mantid::API::Column.

Definition at line 112 of file TableColumn.h.

References Mantid::DataObjects::TableColumn< Type >::TableColumn().

◆ compareVectors() [1/6]

bool Mantid::DataObjects::TableColumn< API::Boolean >::compareVectors ( const std::vector< API::Boolean > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for strings for comparison.

Definition at line 285 of file TableColumn.h.

References m_data, and tolerance.

◆ compareVectors() [2/6]

bool Mantid::DataObjects::TableColumn< int64_t >::compareVectors ( const std::vector< int64_t > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for long64.

Definition at line 247 of file TableColumn.h.

References m_data, and tolerance.

◆ compareVectors() [3/6]

bool Mantid::DataObjects::TableColumn< Kernel::V3D >::compareVectors ( const std::vector< Kernel::V3D > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for V3D for comparison.

Definition at line 298 of file TableColumn.h.

References fabs, m_data, tolerance, Mantid::Geometry::X, Mantid::Geometry::Y, and Mantid::Geometry::Z.

◆ compareVectors() [4/6]

bool Mantid::DataObjects::TableColumn< std::string >::compareVectors ( const std::vector< std::string > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for strings for comparison.

Definition at line 272 of file TableColumn.h.

References m_data, and tolerance.

◆ compareVectors() [5/6]

template<class Type >
bool Mantid::DataObjects::TableColumn< Type >::compareVectors ( const std::vector< Type > &  newVector,
double  tolerance 
) const
inlineprivate

◆ compareVectors() [6/6]

bool Mantid::DataObjects::TableColumn< unsignedlong >::compareVectors ( const std::vector< unsigned long > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for unsigned long int.

Definition at line 259 of file TableColumn.h.

References m_data, and tolerance.

◆ compareVectorsRelError() [1/6]

bool Mantid::DataObjects::TableColumn< API::Boolean >::compareVectorsRelError ( const std::vector< API::Boolean > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for bools for comparison.

Definition at line 354 of file TableColumn.h.

References tolerance.

◆ compareVectorsRelError() [2/6]

bool Mantid::DataObjects::TableColumn< int64_t >::compareVectorsRelError ( const std::vector< int64_t > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for long64 with relative error.

Definition at line 313 of file TableColumn.h.

References m_data, and tolerance.

◆ compareVectorsRelError() [3/6]

bool Mantid::DataObjects::TableColumn< Kernel::V3D >::compareVectorsRelError ( const std::vector< Kernel::V3D > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for V3D for comparison.

Definition at line 361 of file TableColumn.h.

References fabs, m_data, tolerance, Mantid::Geometry::X, Mantid::Geometry::Y, and Mantid::Geometry::Z.

◆ compareVectorsRelError() [4/6]

bool Mantid::DataObjects::TableColumn< std::string >::compareVectorsRelError ( const std::vector< std::string > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for strings for comparison.

Definition at line 347 of file TableColumn.h.

References tolerance.

◆ compareVectorsRelError() [5/6]

template<class Type >
bool Mantid::DataObjects::TableColumn< Type >::compareVectorsRelError ( const std::vector< Type > &  newVector,
double  tolerance 
) const
inlineprivate

◆ compareVectorsRelError() [6/6]

bool Mantid::DataObjects::TableColumn< unsignedlong >::compareVectorsRelError ( const std::vector< unsigned long > &  newVector,
double  tolerance 
) const
inlineprivate

Template specialisation for unsigned long int.

Definition at line 330 of file TableColumn.h.

References m_data, and tolerance.

◆ convertToDouble() [1/2]

template<class Type >
double Mantid::DataObjects::TableColumn< Type >::convertToDouble ( const std::string &  value) const
inline

Cast an string to double if possible.

If it's impossible std::invalid_argument is throw. In case of an overflow boost::numeric::positive_overflow or boost::numeric::negative_overflow is throw.

Parameters
value:: The value of the element.

Definition at line 137 of file TableColumn.h.

References value.

◆ convertToDouble() [2/2]

template<class Type >
template<typename T >
double Mantid::DataObjects::TableColumn< Type >::convertToDouble ( const T &  value) const
inline

Cast an element to double if possible.

If it's impossible boost::numeric::bad_numeric_cast is throw. In case of an overflow boost::numeric::positive_overflow or boost::numeric::negative_overflow is throw.

Parameters
value:: The value of the element.

Definition at line 122 of file TableColumn.h.

References Mantid::API::Column::type(), and value.

Referenced by Mantid::DataObjects::TableColumn< Type >::operator[](), and Mantid::DataObjects::TableColumn< Type >::toDouble().

◆ data() [1/2]

template<class Type >
std::vector< Type > & Mantid::DataObjects::TableColumn< Type >::data ( )
inline

◆ data() [2/2]

template<class Type >
const std::vector< Type > & Mantid::DataObjects::TableColumn< Type >::data ( ) const
inline

Const reference to the data.

Definition at line 159 of file TableColumn.h.

References Mantid::DataObjects::TableColumn< Type >::m_data.

◆ dataArray()

template<class Type >
Type * Mantid::DataObjects::TableColumn< Type >::dataArray ( )
inline

Pointer to the data array.

Definition at line 161 of file TableColumn.h.

References Mantid::DataObjects::TableColumn< Type >::m_data.

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

◆ equals()

template<class Type >
bool Mantid::DataObjects::TableColumn< Type >::equals ( const Column otherColumn,
double  tolerance 
) const
inlineoverridevirtual

◆ equalsRelErr()

template<class Type >
bool Mantid::DataObjects::TableColumn< Type >::equalsRelErr ( const Column otherColumn,
double  tolerance 
) const
inlineoverridevirtual

◆ fromDouble() [1/2]

void Mantid::DataObjects::TableColumn< API::Boolean >::fromDouble ( size_t  index,
double  value 
)
inlinevirtual

Assign an element from double if possible.

Implements Mantid::API::Column.

Definition at line 484 of file TableColumn.h.

References m_data, and value.

◆ fromDouble() [2/2]

template<class Type >
void Mantid::DataObjects::TableColumn< Type >::fromDouble ( size_t  i,
double  value 
)
inlineoverridevirtual

Cast an element to double if possible.

If it's impossible boost::numeric::bad_numeric_cast is throw. In case of an overflow boost::numeric::positive_overflow or boost::numeric::negative_overflow is throw.

Parameters
i:: The index to an element.
valuecast this value

Implements Mantid::API::Column.

Definition at line 150 of file TableColumn.h.

References Mantid::DataObjects::TableColumn< Type >::m_data, Mantid::API::Column::type(), and value.

◆ get_pointer_type_info()

template<class Type >
const std::type_info & Mantid::DataObjects::TableColumn< Type >::get_pointer_type_info ( ) const
inlineoverridevirtual

Type id of the pointer to data in the column.

Implements Mantid::API::Column.

Definition at line 99 of file TableColumn.h.

◆ get_type_info()

template<class Type >
const std::type_info & Mantid::DataObjects::TableColumn< Type >::get_type_info ( ) const
inlineoverridevirtual

Type id of the data in the column.

Implements Mantid::API::Column.

Definition at line 97 of file TableColumn.h.

◆ insert()

template<class Type >
void Mantid::DataObjects::TableColumn< Type >::insert ( size_t  index)
inlineoverrideprotectedvirtual

Inserts default value at position index.

Implements Mantid::API::Column.

Definition at line 203 of file TableColumn.h.

References index, and Mantid::DataObjects::TableColumn< Type >::m_data.

◆ isBool()

template<class Type >
bool Mantid::DataObjects::TableColumn< Type >::isBool ( ) const
inlineoverridevirtual

Type check.

Implements Mantid::API::Column.

Definition at line 107 of file TableColumn.h.

◆ isNumber()

template<class Type >
bool Mantid::DataObjects::TableColumn< Type >::isNumber ( ) const
inlineoverridevirtual

Are elements of the column interpretable as a number?

Implements Mantid::API::Column.

Definition at line 108 of file TableColumn.h.

◆ operator[]()

template<class Type >
double Mantid::DataObjects::TableColumn< Type >::operator[] ( size_t  i) const
inlineoverridevirtual

return a value casted to double; the users responsibility is to be sure, that the casting is possible

Reimplemented from Mantid::API::Column.

Definition at line 165 of file TableColumn.h.

References Mantid::DataObjects::TableColumn< Type >::convertToDouble(), and Mantid::DataObjects::TableColumn< Type >::m_data.

◆ print()

template<class Type >
void Mantid::DataObjects::TableColumn< Type >::print ( size_t  index,
std::ostream &  s 
) const
inlineoverridevirtual

Output to an ostream.

Implements Mantid::API::Column.

Definition at line 101 of file TableColumn.h.

References index, and Mantid::DataObjects::TableColumn< Type >::m_data.

◆ read() [1/4]

template<typename Type >
void Mantid::DataObjects::TableColumn< Type >::read ( const size_t  index,
std::istringstream &  in 
)
overridevirtual

Read in from stream and set the value at the given index.

Reimplemented from Mantid::API::Column.

Definition at line 408 of file TableColumn.h.

References index, and m_data.

◆ read() [2/4]

void Mantid::DataObjects::TableColumn< std::string >::read ( size_t  index,
const std::string &  text 
)
inlinevirtual

Template specialization for strings so they can contain spaces.

Reimplemented from Mantid::API::Column.

Definition at line 384 of file TableColumn.h.

References index, and m_data.

◆ read() [3/4]

template<typename Type >
void Mantid::DataObjects::TableColumn< Type >::read ( size_t  index,
const std::string &  text 
)
overridevirtual

Read in a string and set the value at the given index.

Reimplemented from Mantid::API::Column.

Definition at line 402 of file TableColumn.h.

References index, and m_data.

◆ read() [4/4]

void Mantid::DataObjects::TableColumn< std::string >::read ( size_t  index,
std::istringstream &  text 
)
inlinevirtual

Template specialization for strings so they can contain spaces.

Reimplemented from Mantid::API::Column.

Definition at line 393 of file TableColumn.h.

References index, and m_data.

◆ remove()

template<class Type >
void Mantid::DataObjects::TableColumn< Type >::remove ( size_t  index)
inlineoverrideprotectedvirtual

Removes an item at index.

Implements Mantid::API::Column.

Definition at line 210 of file TableColumn.h.

References index, and Mantid::DataObjects::TableColumn< Type >::m_data.

◆ resize()

template<class Type >
void Mantid::DataObjects::TableColumn< Type >::resize ( size_t  count)
inlineoverrideprotectedvirtual

Resize.

Implements Mantid::API::Column.

Definition at line 201 of file TableColumn.h.

References count, and Mantid::DataObjects::TableColumn< Type >::m_data.

◆ size()

template<class Type >
size_t Mantid::DataObjects::TableColumn< Type >::size ( ) const
inlineoverridevirtual

Number of individual elements in the column.

Implements Mantid::API::Column.

Definition at line 95 of file TableColumn.h.

References Mantid::DataObjects::TableColumn< Type >::m_data.

◆ sizeOfData()

template<class Type >
long int Mantid::DataObjects::TableColumn< Type >::sizeOfData ( ) const
inlineoverridevirtual

Memory used by the column.

Implements Mantid::API::Column.

Definition at line 110 of file TableColumn.h.

References Mantid::DataObjects::TableColumn< Type >::m_data.

◆ sortIndex()

template<typename Type >
void Mantid::DataObjects::TableColumn< Type >::sortIndex ( bool  ascending,
size_t  start,
size_t  end,
std::vector< size_t > &  indexVec,
std::vector< std::pair< size_t, size_t > > &  equalRanges 
) const
overridevirtual

Sort a vector of indices according to values in corresponding cells of this column.

See also
Column::sortIndex

Reimplemented from Mantid::API::Column.

Definition at line 431 of file TableColumn.h.

References iEnd, m_data, and n.

◆ sortValues()

template<typename Type >
void Mantid::DataObjects::TableColumn< Type >::sortValues ( const std::vector< size_t > &  indexVec)
overridevirtual

Re-arrange values in this column according to indices in indexVec.

Re-arrange values in this column in order of indices in indexVec.

Reimplemented from Mantid::API::Column.

Definition at line 470 of file TableColumn.h.

References m_data.

◆ toDouble() [1/2]

double Mantid::DataObjects::TableColumn< API::Boolean >::toDouble ( size_t  index) const
inlinevirtual

Cast an element to double if possible.

Implements Mantid::API::Column.

Definition at line 482 of file TableColumn.h.

References m_data.

◆ toDouble() [2/2]

template<class Type >
double Mantid::DataObjects::TableColumn< Type >::toDouble ( size_t  index) const
inlineoverridevirtual

Cast an element to double if possible.

Implements Mantid::API::Column.

Definition at line 139 of file TableColumn.h.

References Mantid::DataObjects::TableColumn< Type >::convertToDouble(), and Mantid::DataObjects::TableColumn< Type >::m_data.

◆ void_pointer() [1/2]

template<class Type >
const void * Mantid::DataObjects::TableColumn< Type >::void_pointer ( size_t  index) const
inlineoverrideprotectedvirtual

Returns a pointer to the data element.

Implements Mantid::API::Column.

Definition at line 214 of file TableColumn.h.

References index, and Mantid::DataObjects::TableColumn< Type >::m_data.

◆ void_pointer() [2/2]

template<class Type >
void * Mantid::DataObjects::TableColumn< Type >::void_pointer ( size_t  index)
inlineoverrideprotectedvirtual

Returns a pointer to the data element.

Implements Mantid::API::Column.

Definition at line 212 of file TableColumn.h.

References index, and Mantid::DataObjects::TableColumn< Type >::m_data.

Friends And Related Function Documentation

◆ TableWorkspace

template<class Type >
friend class TableWorkspace
friend

Definition at line 219 of file TableColumn.h.

Member Data Documentation

◆ m_data

template<class Type >
std::vector<Type> Mantid::DataObjects::TableColumn< Type >::m_data
private

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