TableColumn.hpp
Go to the documentation of this file.
1/*
2 Copyright 2015 Statoil ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21#ifndef OPM_TABLE_COLUMN_HPP
22#define OPM_TABLE_COLUMN_HPP
23
24#include <string>
25#include <vector>
26
29
30namespace Opm {
31
33 public:
35 explicit TableColumn( const ColumnSchema& schema );
36
38
39 size_t size( ) const;
40 const std::string& name() const;
41 void assertOrder(double value1 , double value2) const;
42 void addValue(double);
43 void addDefault();
44 void updateValue(size_t index, double value);
45 double operator[](size_t index) const;
46 bool defaultApplied(size_t index) const;
47 bool hasDefault( ) const;
48 double front() const;
49 double back() const;
50 double min() const;
51 double max() const;
52 bool inRange( double arg ) const;
53
54 /*
55 Will extrapolate with constant endpoint values if @argValue
56 is out of range.
57 */
58 TableIndex lookup(double argValue) const;
59 double eval( const TableIndex& index) const;
60 void applyDefaults( const TableColumn& argColumn );
61 void assertUnitRange() const;
63
64 std::vector<double> vectorCopy() const;
65 std::vector<double>::const_iterator begin() const;
66 std::vector<double>::const_iterator end() const;
67
68 bool operator==(const TableColumn& data) const;
69
70 template<class Serializer>
71 void serializeOp(Serializer& serializer)
72 {
73 m_schema.serializeOp(serializer);
74 serializer(m_name);
75 serializer(m_values);
76 serializer(m_default);
77 serializer(m_defaultCount);
78 }
79
80 private:
81 void assertUpdate(size_t index, double value) const;
82 void assertPrevious(size_t index , double value) const;
83 void assertNext(size_t index , double value) const;
84
85 ColumnSchema m_schema;
86 std::string m_name;
87 std::vector<double> m_values;
88 std::vector<bool> m_default;
89 size_t m_defaultCount;
90 };
91
92
93}
94
95
96#endif
int index
Definition: cJSON.h:168
const char *const string
Definition: cJSON.h:170
Definition: ColumnSchema.hpp:31
void serializeOp(Serializer &serializer)
Definition: ColumnSchema.hpp:51
Definition: Serializer.hpp:38
Definition: TableColumn.hpp:32
double max() const
const std::string & name() const
void assertOrder(double value1, double value2) const
bool inRange(double arg) const
TableColumn & operator=(const TableColumn &other)
bool hasDefault() const
void assertUnitRange() const
std::vector< double >::const_iterator begin() const
static TableColumn serializeObject()
void serializeOp(Serializer &serializer)
Definition: TableColumn.hpp:71
double back() const
void applyDefaults(const TableColumn &argColumn)
std::vector< double > vectorCopy() const
void addValue(double)
double min() const
bool defaultApplied(size_t index) const
double front() const
TableIndex lookup(double argValue) const
std::vector< double >::const_iterator end() const
size_t size() const
double eval(const TableIndex &index) const
bool operator==(const TableColumn &data) const
TableColumn(const ColumnSchema &schema)
double operator[](size_t index) const
void updateValue(size_t index, double value)
Definition: TableIndex.hpp:36
Definition: A.hpp:4
T value(details::expression_node< T > *n)
Definition: exprtk.hpp:12955
static std::string data()
Definition: exprtk.hpp:40022