NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
tablecolumn.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 NumeRe: Framework fuer Numerische Rechnungen
3 Copyright (C) 2021 Erik Haenel et al.
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17******************************************************************************/
18
19#ifndef TABLECOLUMN_HPP
20#define TABLECOLUMN_HPP
21
22#include <string>
23#include <vector>
24#include <memory>
25#include "../ParserLib/muParserDef.h"
26#include "../structures.hpp"
27
34{
36 {
46 };
47
48 std::string m_sHeadLine;
50
52 virtual ~TableColumn() {}
53
54 std::vector<std::string> getValueAsString(const VectorIndex& idx) const;
55 std::vector<std::string> getValueAsInternalString(const VectorIndex& idx) const;
56 std::vector<mu::value_type> getValue(const VectorIndex& idx) const;
57
58 virtual std::string getValueAsString(size_t elem) const = 0;
59 virtual std::string getValueAsInternalString(size_t elem) const = 0;
60 virtual std::string getValueAsParserString(size_t elem) const = 0;
61 virtual std::string getValueAsStringLiteral(size_t elem) const = 0;
62 virtual mu::value_type getValue(size_t elem) const = 0;
63
64 void setValue(const VectorIndex& idx, const std::vector<std::string>& vValue);
65 void setValue(const VectorIndex& idx, const std::vector<mu::value_type>& vValue);
66 void setValue(const VectorIndex& idx, mu::value_type* _dData, unsigned int _nNum);
67
68 virtual void setValue(size_t elem, const std::string& sValue) = 0;
69 virtual void setValue(size_t elem, const mu::value_type& vValue) = 0;
70
71 TableColumn* copy() const;
72 virtual TableColumn* copy(const VectorIndex& idx) const = 0;
73 virtual void assign(const TableColumn* column) = 0;
74 virtual void insert(const VectorIndex& idx, const TableColumn* column) = 0;
75 virtual void deleteElements(const VectorIndex& idx) = 0;
76 void shrink();
77
78 virtual void insertElements(size_t pos, size_t elem) = 0;
79 virtual void appendElements(size_t elem) = 0;
80 virtual void removeElements(size_t pos, size_t elem) = 0;
81 virtual void resize(size_t elem) = 0;
82
83 virtual int compare(int i, int j, bool flag) const = 0;
84 virtual bool isValid(int elem) const = 0;
85
86 virtual bool asBool(int elem) const = 0;
87
88 virtual size_t size() const = 0;
89 virtual size_t getBytes() const = 0;
90 size_t getNumFilledElements() const;
91
93
94 static std::string getDefaultColumnHead(size_t colNo);
95 static std::string typeToString(ColumnType type);
96 static ColumnType stringToType(const std::string& sType);
97 static std::vector<std::string> getTypesAsString();
98};
99
100
106typedef std::unique_ptr<TableColumn> TblColPtr;
107
113typedef std::vector<TblColPtr> TableColumnArray;
114
115
116
117#endif // TABLECOLUMN_HPP
118
119
120
This class abstracts all the index logics, i.e. the logical differences between single indices and in...
Definition: structures.hpp:42
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:251
Abstract table column, which allows using it to compose the data table in each Memory instance.
Definition: tablecolumn.hpp:34
virtual bool isValid(int elem) const =0
void shrink()
Shrink the column by removing all invalid elements from the end.
std::vector< std::string > getValueAsInternalString(const VectorIndex &idx) const
Returns the table column's contents as a vector containing internal strings.
Definition: tablecolumn.cpp:56
size_t getNumFilledElements() const
Return the number of actual filled elements in this column, which can be different from the actual si...
TableColumn * copy() const
Simplification wrapper around the indiced copy method to copy the whole column.
static ColumnType stringToType(const std::string &sType)
Converts the passed string representation to a ColumnType value.
virtual size_t size() const =0
virtual TableColumn * convert(ColumnType type=TableColumn::TYPE_NONE)=0
std::vector< mu::value_type > getValue(const VectorIndex &idx) const
Return the table column's contents as a vector of numerical types.
Definition: tablecolumn.cpp:78
virtual TableColumn * copy(const VectorIndex &idx) const =0
virtual void resize(size_t elem)=0
virtual std::string getValueAsParserString(size_t elem) const =0
virtual void insert(const VectorIndex &idx, const TableColumn *column)=0
virtual void appendElements(size_t elem)=0
ColumnType m_type
Definition: tablecolumn.hpp:49
virtual std::string getValueAsStringLiteral(size_t elem) const =0
virtual void setValue(size_t elem, const std::string &sValue)=0
static std::string getDefaultColumnHead(size_t colNo)
Creates a default column headline for a column, which can be used without an instance of this class.
virtual void insertElements(size_t pos, size_t elem)=0
virtual void removeElements(size_t pos, size_t elem)=0
virtual std::string getValueAsInternalString(size_t elem) const =0
static std::string typeToString(ColumnType type)
Converts the passed ColumnType value to a string representation.
virtual ~TableColumn()
Definition: tablecolumn.hpp:52
virtual void deleteElements(const VectorIndex &idx)=0
virtual std::string getValueAsString(size_t elem) const =0
virtual void assign(const TableColumn *column)=0
virtual bool asBool(int elem) const =0
std::vector< std::string > getValueAsString(const VectorIndex &idx) const
Return the table column's contents as a vector of strings.
Definition: tablecolumn.cpp:34
virtual void setValue(size_t elem, const mu::value_type &vValue)=0
virtual size_t getBytes() const =0
virtual int compare(int i, int j, bool flag) const =0
std::string m_sHeadLine
Definition: tablecolumn.hpp:48
virtual mu::value_type getValue(size_t elem) const =0
static std::vector< std::string > getTypesAsString()
Returns a list of all available column types as strings.
void setValue(const VectorIndex &idx, const std::vector< std::string > &vValue)
Sets a string vector at the specified indices.
std::unique_ptr< TableColumn > TblColPtr
Typedef for simplifying the usage of a smart pointer in combination with a TableColumn instance.
std::vector< TblColPtr > TableColumnArray
This typedef represents the actual table, which is implemented using a std::vector.