Mantid
|
Class TableColumn implements abstract class Column for any copyable data type. More...
#include <TableColumn.h>
Classes | |
struct | InconvertibleToDoubleType |
Helper struct helping to write a generic casting to double. More... | |
Public Member Functions | |
TableColumn * | clone () 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 Column * | clone () 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... | |
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.
Definition at line 45 of file TableColumn.h.
|
inline |
Definition at line 62 of file TableColumn.h.
References Mantid::API::Column::m_type, and Mantid::API::Column::name().
Referenced by Mantid::DataObjects::TableColumn< Type >::clone().
|
inlineoverridevirtual |
Clone.
Implements Mantid::API::Column.
Definition at line 112 of file TableColumn.h.
References Mantid::DataObjects::TableColumn< Type >::TableColumn().
|
inlineprivate |
Template specialisation for strings for comparison.
Definition at line 285 of file TableColumn.h.
|
inlineprivate |
Template specialisation for long64.
Definition at line 247 of file TableColumn.h.
|
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.
|
inlineprivate |
Template specialisation for strings for comparison.
Definition at line 272 of file TableColumn.h.
|
inlineprivate |
Definition at line 222 of file TableColumn.h.
References fabs, Mantid::DataObjects::TableColumn< Type >::m_data, and tolerance.
Referenced by Mantid::DataObjects::TableColumn< Type >::equals().
|
inlineprivate |
Template specialisation for unsigned long int.
Definition at line 259 of file TableColumn.h.
|
inlineprivate |
Template specialisation for bools for comparison.
Definition at line 354 of file TableColumn.h.
References tolerance.
|
inlineprivate |
Template specialisation for long64 with relative error.
Definition at line 313 of file TableColumn.h.
|
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.
|
inlineprivate |
Template specialisation for strings for comparison.
Definition at line 347 of file TableColumn.h.
References tolerance.
|
inlineprivate |
Definition at line 232 of file TableColumn.h.
References fabs, Mantid::DataObjects::TableColumn< Type >::m_data, and tolerance.
Referenced by Mantid::DataObjects::TableColumn< Type >::equalsRelErr().
|
inlineprivate |
Template specialisation for unsigned long int.
Definition at line 330 of file TableColumn.h.
|
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.
value | :: The value of the element. |
Definition at line 137 of file TableColumn.h.
References value.
|
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.
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().
|
inline |
Reference to the data.
Definition at line 157 of file TableColumn.h.
References Mantid::DataObjects::TableColumn< Type >::m_data.
Referenced by Mantid::DataObjects::TableColumn< Type >::equals(), Mantid::DataObjects::TableColumn< Type >::equalsRelErr(), and Mantid::DataObjects::TableWorkspace::getColVector().
|
inline |
Const reference to the data.
Definition at line 159 of file TableColumn.h.
References Mantid::DataObjects::TableColumn< Type >::m_data.
|
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().
|
inlineoverridevirtual |
Reimplemented from Mantid::API::Column.
Definition at line 181 of file TableColumn.h.
References Mantid::DataObjects::TableColumn< Type >::compareVectors(), Mantid::DataObjects::TableColumn< Type >::data(), Mantid::API::Column::possibleToCompare(), and tolerance.
|
inlineoverridevirtual |
Reimplemented from Mantid::API::Column.
Definition at line 190 of file TableColumn.h.
References Mantid::DataObjects::TableColumn< Type >::compareVectorsRelError(), Mantid::DataObjects::TableColumn< Type >::data(), Mantid::API::Column::possibleToCompare(), and tolerance.
|
inlinevirtual |
Assign an element from double if possible.
Implements Mantid::API::Column.
Definition at line 484 of file TableColumn.h.
|
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.
i | :: The index to an element. |
value | cast 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.
|
inlineoverridevirtual |
Type id of the pointer to data in the column.
Implements Mantid::API::Column.
Definition at line 99 of file TableColumn.h.
|
inlineoverridevirtual |
Type id of the data in the column.
Implements Mantid::API::Column.
Definition at line 97 of file TableColumn.h.
|
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.
|
inlineoverridevirtual |
|
inlineoverridevirtual |
Are elements of the column interpretable as a number?
Implements Mantid::API::Column.
Definition at line 108 of file TableColumn.h.
|
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.
|
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.
|
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.
|
inlinevirtual |
Template specialization for strings so they can contain spaces.
Reimplemented from Mantid::API::Column.
Definition at line 384 of file TableColumn.h.
|
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.
|
inlinevirtual |
Template specialization for strings so they can contain spaces.
Reimplemented from Mantid::API::Column.
Definition at line 393 of file TableColumn.h.
|
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.
|
inlineoverrideprotectedvirtual |
Resize.
Implements Mantid::API::Column.
Definition at line 201 of file TableColumn.h.
References count, and Mantid::DataObjects::TableColumn< Type >::m_data.
|
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.
|
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.
|
overridevirtual |
Sort a vector of indices according to values in corresponding cells of this column.
Reimplemented from Mantid::API::Column.
Definition at line 431 of file TableColumn.h.
|
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.
|
inlinevirtual |
Cast an element to double if possible.
Implements Mantid::API::Column.
Definition at line 482 of file TableColumn.h.
References m_data.
|
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.
|
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.
|
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.
|
friend |
Definition at line 219 of file TableColumn.h.
|
private |
Column data.
Definition at line 218 of file TableColumn.h.
Referenced by Mantid::DataObjects::TableColumn< Type >::compareVectors(), Mantid::DataObjects::TableColumn< Type >::compareVectorsRelError(), Mantid::DataObjects::TableColumn< Type >::data(), Mantid::DataObjects::TableColumn< Type >::dataArray(), Mantid::DataObjects::TableColumn< Type >::fromDouble(), Mantid::DataObjects::TableColumn< Type >::insert(), Mantid::DataObjects::TableColumn< Type >::operator[](), Mantid::DataObjects::TableColumn< Type >::print(), Mantid::DataObjects::TableColumn< Type >::remove(), Mantid::DataObjects::TableColumn< Type >::resize(), Mantid::DataObjects::TableColumn< Type >::size(), Mantid::DataObjects::TableColumn< Type >::sizeOfData(), Mantid::DataObjects::TableColumn< Type >::toDouble(), and Mantid::DataObjects::TableColumn< Type >::void_pointer().