10#include "MantidDataObjects/DllConfig.h"
14#include <boost/algorithm/string/join.hpp>
15#include <boost/algorithm/string/trim.hpp>
16#include <boost/lexical_cast.hpp>
21namespace DataObjects {
39 const std::type_info &
get_type_info()
const override {
return typeid(std::vector<Type>); }
45 void print(
size_t index, std::ostream &s)
const override {
48 auto it = values.begin();
50 if (it != values.end()) {
55 for (; it != values.end(); ++it) {
62 void read(
size_t index,
const std::string &text)
override {
63 std::vector<Type> newValues;
66 for (
const auto &element : elements) {
68 newValues.emplace_back(boost::lexical_cast<Type>(element));
69 }
catch (boost::bad_lexical_cast &) {
70 throw std::invalid_argument(
"Unable to convert one of the elements: " + element);
78 void read(
const size_t index, std::istringstream &in)
override {
85 bool isBool()
const override {
return false; }
87 bool isNumber()
const override {
return false; }
91 return std::accumulate(
m_data.cbegin(),
m_data.cend(), 0, [](
long int dataSize,
const auto &elem) {
92 return dataSize + static_cast<long int>(elem.size() * sizeof(Type));
99 newColumn->m_data =
m_data;
100 newColumn->setName(m_name);
101 newColumn->setPlotType(m_plotType);
108 throw std::runtime_error(
"VectorColumn is not convertible to double.");
115 throw std::runtime_error(
"VectorColumn is not assignable from double.");
119 const std::vector<std::vector<Type>> &
data()
const {
return m_data; }
122 if (!possibleToCompare(otherColumn)) {
126 const auto &otherData = otherColumnTyped.
data();
127 for (
size_t i = 0; i <
m_data.size(); i++) {
128 if (
m_data[i].size() != otherData[i].
size()) {
131 for (
size_t j = 0; j <
m_data[i].size(); j++) {
132 double const left =
static_cast<double>(
m_data[i][j]);
133 double const right =
static_cast<double>(otherData[i][j]);
134 if (nanEqual && std::isnan(
left) && std::isnan(
right)) {
145 if (!possibleToCompare(otherColumn)) {
149 const auto &otherData = otherColumnTyped.
data();
150 for (
size_t i = 0; i <
m_data.size(); i++) {
151 if (
m_data[i].size() != otherData[i].
size()) {
154 for (
size_t j = 0; j <
m_data[i].size(); j++) {
155 double const left =
static_cast<double>(
m_data[i][j]);
156 double const right =
static_cast<double>(otherData[i][j]);
157 if (nanEqual && std::isnan(
left) && std::isnan(
right)) {
198#define DECLARE_VECTORCOLUMN(Type, TypeName) \
199 template <> std::string VectorColumn<Type>::typeName() { return #TypeName; } \
200 Kernel::RegistrationHelper register_column_##TypeName( \
201 (API::ColumnFactory::Instance().subscribe<VectorColumn<Type>>(#TypeName), 0));
double value
The value of the point.
std::map< DeltaEMode::Type, std::string > index
#define UNUSED_ARG(x)
Function arguments are sometimes unused in certain implmentations but are required for documentation ...
const std::vector< Type > & m_data
Column is the base class for columns of TableWorkspace.
VectorColumn : table column type capable of storing vectors of primitive types.
bool equalsRelErr(const Column &otherColumn, double tolerance, bool const nanEqual=false) const override
void resize(size_t count) override
Sets the new column size.
const std::type_info & get_pointer_type_info() const override
Returns typeid for the pointer type to the data element in the column.
bool isBool() const override
Specialized type check.
long int sizeOfData() const override
Overall memory size taken by the column (bytes)
void read(const size_t index, std::istringstream &in) override
Set item from a stream.
bool equals(const Column &otherColumn, double tolerance, bool const nanEqual=false) const override
void read(size_t index, const std::string &text) override
Set item from a string value.
void fromDouble(size_t i, double value) override
Assign from double.
const void * void_pointer(size_t index) const override
Pointer to a data element.
void print(size_t index, std::ostream &s) const override
Print specified item to the stream.
void insert(size_t index) override
Inserts an item.
VectorColumn * clone() const override
Create another copy of the column.
std::string typeName()
Returns the name of the column with the given type.
void remove(size_t index) override
Removes an item.
const std::type_info & get_type_info() const override
Returns typeid for the data in the column.
double toDouble(size_t i) const override
Cast to double.
size_t size() const override
Number of individual elements in the column.
bool isNumber() const override
Are elements of the column interpretable as a number?
void * void_pointer(size_t index) override
Pointer to a data element.
const std::vector< std::vector< Type > > & data() const
Reference to the data.
std::vector< std::vector< Type > > m_data
All the vectors stored.
@ TOK_TRIM
remove leading and trailing whitespace from tokens
Helper class which provides the Collimation Length for SANS instruments.