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.
 
double convertToDouble (const std::string &value) const
 Cast an string to double if possible.
 
template<typename T >
double convertToDouble (const T &value) const
 Cast an element to double if possible.
 
std::vector< Type > & data ()
 Reference to the data.
 
const std::vector< Type > & data () const
 Const reference to the data.
 
Type * dataArray ()
 Pointer to the data array.
 
bool equals (const Column &otherColumn, double tolerance, bool const nanEqual=false) const override
 
bool equalsRelErr (const Column &otherColumn, double tolerance, bool const nanEqual=false) const override
 
void fromDouble (size_t i, double value)
 Assign an element from double if possible.
 
void fromDouble (size_t i, double value) override
 Cast an element to double if possible.
 
const std::type_info & get_pointer_type_info () const override
 Type id of the pointer to data in the column.
 
const std::type_info & get_type_info () const override
 Type id of the data in the column.
 
bool isBool () const override
 Type check.
 
bool isNumber () const override
 Are elements of the column interpretable as a number?
 
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
 
void print (size_t index, std::ostream &s) const override
 Output to an ostream.
 
void read (const size_t index, std::istringstream &in) override
 Read in from stream and set the value at the given index.
 
void read (size_t index, const std::string &text)
 Template specialization for strings so they can contain spaces.
 
void read (size_t index, const std::string &text) override
 Read in a string and set the value at the given index.
 
void read (size_t index, std::istringstream &text)
 Template specialization for strings so they can contain spaces.
 
size_t size () const override
 Number of individual elements in the column.
 
long int sizeOfData () const override
 Memory used by the column.
 
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.
 
void sortValues (const std::vector< size_t > &indexVec) override
 Re-arrange values in this column according to indices in indexVec.
 
 TableColumn ()
 
double toDouble (size_t i) const
 Cast an element to double if possible.
 
double toDouble (size_t i) const override
 Cast an element to double if possible.
 
- 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.
 
template<class T >
const T & cell (size_t index) const
 Templated method for returning a value (const version).
 
 Column ()
 
int getLinkedYCol () const
 
int getPlotType () const
 get plot type
 
virtual bool getReadOnly () const
 Returns column read-only flag.
 
template<class T >
bool isType () const
 Type check.
 
template<>
bool isType () const
 
const std::string & name () const
 Name (caption) of the column.
 
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.
 
void setLinkedYCol (const int yCol)
 
void setName (const std::string &str)
 Renames the column.
 
void setPlotType (int t)
 Set plot type where.
 
void setReadOnly (bool isReadOnly)
 Sets column read-only flag.
 
const std::string & type () const
 Type of the column data.
 
virtual ~Column ()=default
 Virtual destructor.
 

Protected Member Functions

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

Private Member Functions

bool compareVectors (const std::vector< API::Boolean > &newVector, double, bool const) const
 Template specialisation for strings for comparison.
 
bool compareVectors (const std::vector< Kernel::V3D > &newVector, double tolerance, bool const nanEqual) const
 Template specialisation for V3D for comparison.
 
bool compareVectors (const std::vector< std::string > &newVector, double, bool const) const
 Template specialisation for strings for comparison.
 
bool compareVectors (const std::vector< Type > &newVector, double tolerance, bool const nanEqual, std::false_type) const
 
bool compareVectors (const std::vector< Type > &newVector, double tolerance, bool const nanEqual=false) const
 
bool compareVectors (const std::vector< Type > &newVector, double tolerance, bool const, std::true_type) const
 
bool compareVectorsRelError (const std::vector< API::Boolean > &newVector, double tolerance, bool const) const
 Template specialisation for bools for comparison.
 
bool compareVectorsRelError (const std::vector< Kernel::V3D > &newVector, double tolerance, bool const nanEqual) const
 Template specialisation for V3D for comparison.
 
bool compareVectorsRelError (const std::vector< std::string > &newVector, double tolerance, bool const) const
 Template specialisation for strings for comparison.
 
bool compareVectorsRelError (const std::vector< Type > &newVector, double tolerance, bool const nanEqual, std::false_type) const
 
bool compareVectorsRelError (const std::vector< Type > &newVector, double tolerance, bool const nanEqual=false) const
 
bool compareVectorsRelError (const std::vector< Type > &newVector, double tolerance, bool const, std::true_type) const
 

Private Attributes

std::vector< Type > m_data
 Column data.
 

Friends

class TableWorkspace
 

Additional Inherited Members

- Protected Attributes inherited from Mantid::API::Column
bool m_isReadOnly
 Column read-only flag.
 
int m_linkedYCol = -1
 For error columns - the index of the related data column.
 
std::string m_name
 name
 
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
 
std::string m_type
 type
 

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 46 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 113 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  ,
bool const   
) const
inlineprivate

Template specialisation for strings for comparison.

Definition at line 289 of file TableColumn.h.

References m_data.

◆ compareVectors() [2/6]

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

Template specialisation for V3D for comparison.

Definition at line 301 of file TableColumn.h.

References Mantid::Kernel::V3D::isnan(), m_data, tolerance, and Mantid::Kernel::withinAbsoluteDifference().

◆ compareVectors() [3/6]

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

Template specialisation for strings for comparison.

Definition at line 277 of file TableColumn.h.

References m_data.

◆ compareVectors() [4/6]

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

Definition at line 236 of file TableColumn.h.

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

◆ compareVectors() [5/6]

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

◆ compareVectors() [6/6]

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

Definition at line 227 of file TableColumn.h.

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

◆ compareVectorsRelError() [1/6]

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

Template specialisation for bools for comparison.

Definition at line 323 of file TableColumn.h.

References tolerance.

◆ compareVectorsRelError() [2/6]

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

Template specialisation for V3D for comparison.

Definition at line 330 of file TableColumn.h.

References Mantid::Kernel::V3D::isnan(), m_data, tolerance, and Mantid::Kernel::withinRelativeDifference().

◆ compareVectorsRelError() [3/6]

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

Template specialisation for strings for comparison.

Definition at line 316 of file TableColumn.h.

References tolerance.

◆ compareVectorsRelError() [4/6]

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

Definition at line 262 of file TableColumn.h.

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

◆ compareVectorsRelError() [5/6]

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

◆ compareVectorsRelError() [6/6]

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

Definition at line 253 of file TableColumn.h.

References Mantid::DataObjects::TableColumn< Type >::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 138 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 123 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 160 of file TableColumn.h.

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

◆ dataArray()

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

◆ equals()

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

◆ equalsRelErr()

template<class Type >
bool Mantid::DataObjects::TableColumn< Type >::equalsRelErr ( const Column otherColumn,
double  tolerance,
bool const  nanEqual = false 
) 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 444 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 151 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 100 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 98 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 204 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 108 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 109 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 166 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 102 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 368 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 344 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 362 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 353 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 211 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 202 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 96 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 111 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 391 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 430 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 442 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 140 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 215 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 213 of file TableColumn.h.

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

Friends And Related Symbol Documentation

◆ TableWorkspace

template<class Type >
friend class TableWorkspace
friend

Definition at line 220 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: