12#include "MantidAPI/DllConfig.h"
37 Column() : m_type(
"int"), m_plotType(-1000), m_isReadOnly(false) {};
43 const std::string &
name()
const {
return m_name; }
46 const std::string &
type()
const {
return m_type; }
48 virtual double operator[]([[maybe_unused]]
size_t i)
const {
return std::numeric_limits<double>::quiet_NaN(); }
50 void setName(
const std::string &str) { m_name = str; }
53 virtual size_t size()
const = 0;
65 void setReadOnly(
bool isReadOnly) { m_isReadOnly = isReadOnly; }
68 virtual void print(
size_t index, std::ostream &s)
const = 0;
71 virtual void read(
size_t index,
const std::string &text) {
77 virtual void read(
const size_t index, std::istringstream &in) {
117 virtual void sortIndex(
bool ascending,
size_t start,
size_t end, std::vector<size_t> &indexVec,
118 std::vector<std::pair<size_t, size_t>> &equalRanges)
const;
121 virtual void sortValues(
const std::vector<size_t> &indexVec);
124 template <
class T> T &
cell(
size_t index) {
return *
static_cast<T *
>(void_pointer(
index)); }
128 template <
class T>
const T &
cell(
size_t index)
const {
return *
static_cast<const T *
>(void_pointer(
index)); }
131 template <
class T>
bool isType()
const {
return !std::strcmp(get_type_info().
name(),
typeid(T).
name()); }
139 void setPlotType(
int t);
143 void setLinkedYCol(
const int yCol);
149 template <
class T =
double> std::vector<T>
numeric_fill(
size_t maxSize = std::numeric_limits<size_t>::max())
const {
150 std::vector<T>
vec(std::min(size(), maxSize));
151 for (
size_t i = 0; i <
vec.size(); ++i) {
152 vec[i] =
static_cast<T
>(toDouble(i));
157 virtual bool equals(
const Column &,
double,
bool const =
false)
const {
158 throw std::runtime_error(
"equals not implemented");
162 throw std::runtime_error(
"equals not implemented");
180 if (otherColumn.
size() != this->size()) {
196 int m_linkedYCol = -1;
220 operator bool()
const {
return this->
value; }
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
std::vector< T > const * vec
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
The ColumnFactory class is in charge of the creation of concrete instances of columns.
ColumnVector gives access to the column elements without alowing its resizing.
Column is the base class for columns of TableWorkspace.
virtual const void * void_pointer(size_t index) const =0
Pointer to a data element.
int m_plotType
plot type where None = 0 (means it has specifically been set to 'no plot type') NotSet = -1000 (this ...
const std::string & type() const
Type of the column data.
virtual double operator[](size_t i) const
return value casted to double (should be pure virtual)
virtual bool equalsRelErr(const Column &, double, bool const =false) const
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.
const T & cell(size_t index) const
Templated method for returning a value (const version).
int getPlotType() const
get plot type
virtual void remove(size_t index)=0
Removes an item.
bool m_isReadOnly
Column read-only flag.
int getLinkedYCol() const
T & cell(size_t index)
Templated method for returning a value. No type checks are done.
virtual void * void_pointer(size_t index)=0
Pointer to a data element.
virtual bool getReadOnly() const
Returns column read-only flag.
virtual void read(const size_t index, std::istringstream &in)
Read in from stream and set the value at the given index.
virtual bool isBool() const =0
Specialized type check.
virtual void resize(size_t count)=0
Sets the new column size.
virtual Column * clone() const =0
Virtual constructor. Fully clone any column.
void setName(const std::string &str)
Renames the column.
virtual void insert(size_t index)=0
Inserts an item.
virtual void read(size_t index, const std::string &text)
Read in a string and set the value at the given index.
virtual double toDouble(size_t index) const =0
Cast an element to double if possible.
virtual bool equals(const Column &, double, bool const =false) const
virtual const std::type_info & get_type_info() const =0
Returns typeid for the data in the column.
virtual void print(size_t index, std::ostream &s) const =0
Prints out the value to a stream.
virtual bool isNumber() const =0
Are elements of the column interpretable as a number?
void setReadOnly(bool isReadOnly)
Sets column read-only flag.
virtual size_t size() const =0
Number of individual elements in the column.
virtual long int sizeOfData() const =0
Must return overall memory size taken by the column.
bool possibleToCompare(const Column &otherColumn) const
virtual const std::type_info & get_pointer_type_info() const =0
Returns typeid for the pointer type to the data element in the column.
virtual void fromDouble(size_t index, double value)=0
Assign an element from double if possible.
const std::string & name() const
Name (caption) of the column.
virtual ~Column()=default
Virtual destructor.
bool isType() const
Type check.
ITableWorkspace is an implementation of Workspace in which the data are organised in columns of same ...
std::shared_ptr< Column > Column_sptr
MANTID_API_DLL std::ostream & operator<<(std::ostream &, const AlgorithmHistory &)
Prints a text representation.
std::shared_ptr< const Column > Column_const_sptr
MANTID_API_DLL std::istream & operator>>(std::istream &istr, API::Boolean &)
Redaing a Boolean from an input stream.
Helper class which provides the Collimation Length for SANS instruments.
As TableColumn stores its data in a std::vector bool type cannot be used in the same way as the other...
Boolean()
Default constructor.
bool operator==(const Boolean &b) const
equal to operator
Boolean(bool b)
Conversion from bool.