Mantid
Loading...
Searching...
No Matches
Column.cpp
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#include <algorithm>
8#include <iostream>
9#include <stdexcept>
10
11#include "MantidAPI/Column.h"
12#include "MantidKernel/Logger.h"
13
14namespace Mantid::API {
15
16namespace {
18Kernel::Logger g_log("Column");
19} // namespace
20
21template <> bool Column::isType<bool>() const { return isBool(); }
22
28void Column::setPlotType(int t) {
29 if (t == -1000 || t == 0 || t == 1 || t == 2 || t == 3 || t == 4 || t == 5 || t == 6)
30 m_plotType = t;
31 else {
32 g_log.error() << "Cannot set plot of column to " << t << " . Ignore this attempt.\n";
33 }
34}
35
36void Column::setLinkedYCol(const int yCol) { m_linkedYCol = yCol; }
37
41void Column::sortIndex(bool /*unused*/, size_t /*unused*/, size_t /*unused*/, std::vector<size_t> & /*unused*/,
42 std::vector<std::pair<size_t, size_t>> & /*unused*/) const {
43 throw std::runtime_error("Cannot sort column of type " + m_type);
44}
45
49void Column::sortValues(const std::vector<size_t> & /*unused*/) {
50 throw std::runtime_error("Cannot sort column of type " + m_type);
51}
52
53std::ostream &operator<<(std::ostream &s, const API::Boolean &b) {
54 s << (b.value ? "true" : "false");
55 return s;
56}
57
61std::istream &operator>>(std::istream &istr, API::Boolean &b) {
62 std::string buff;
63 istr >> buff;
64 std::transform(buff.begin(), buff.end(), buff.begin(), toupper);
65 if (buff == "TRUE" || buff == "1" || buff == "OK" || buff == "YES" || buff == "ON") {
66 b = true;
67 } else {
68 b = false;
69 }
70 return istr;
71}
72
73} // namespace Mantid::API
int m_plotType
plot type where None = 0 (means it has specifically been set to 'no plot type') NotSet = -1000 (this ...
Definition: Column.h:192
int m_linkedYCol
For error columns - the index of the related data column.
Definition: Column.h:195
virtual bool isBool() const =0
Specialized type check.
std::string m_type
type
Definition: Column.h:186
void error(const std::string &msg)
Logs at error level.
Definition: Logger.cpp:77
MANTID_API_DLL std::ostream & operator<<(std::ostream &, const AlgorithmHistory &)
Prints a text representation.
Kernel::Logger g_log("ExperimentInfo")
static logger object
MANTID_API_DLL std::istream & operator>>(std::istream &istr, API::Boolean &)
Redaing a Boolean from an input stream.
Definition: Column.cpp:61
As TableColumn stores its data in a std::vector bool type cannot be used in the same way as the other...
Definition: Column.h:209
bool value
boolean value
Definition: Column.h:220