DOLFIN
DOLFIN C++ interface
Toggle main menu visibility
Loading...
Searching...
No Matches
dolfin
log
Table.h
1
// Copyright (C) 2008-2011 Anders Logg
2
//
3
// This file is part of DOLFIN.
4
//
5
// DOLFIN is free software: you can redistribute it and/or modify
6
// it under the terms of the GNU Lesser 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
// DOLFIN 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 Lesser General Public License for more details.
14
//
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17
//
18
// First added: 2008-07-19
19
// Last changed: 2011-10-07
20
21
#ifndef __TABLE_H
22
#define __TABLE_H
23
24
#include <map>
25
#include <set>
26
#include <vector>
27
#include <dolfin/common/Variable.h>
28
29
namespace
dolfin
30
{
31
class
MPI
;
32
class
XMLTable
;
33
class
TableEntry
;
34
48
49
class
Table
:
public
Variable
50
{
51
public
:
52
54
Table
(std::string title=
""
,
bool
right_justify=
true
);
55
57
~Table
();
58
60
TableEntry
operator()
(std::string row, std::string col);
61
63
void
set
(std::string row, std::string col,
int
value);
64
66
void
set
(std::string row, std::string col, std::size_t value);
67
69
void
set
(std::string row, std::string col,
double
value);
70
72
void
set
(std::string row, std::string col, std::string value);
73
75
std::string
get
(std::string row, std::string col)
const
;
76
78
double
get_value
(std::string row, std::string col)
const
;
79
81
const
Table
&
operator=
(
const
Table
& table);
82
84
std::string
str
(
bool
verbose)
const
;
85
87
std::string
str_latex
()
const
;
88
89
private
:
90
91
// Rows
92
std::vector<std::string> rows;
93
std::set<std::string> row_set;
94
95
// Columns
96
std::vector<std::string> cols;
97
std::set<std::string> col_set;
98
99
// Table values as strings
100
std::map<std::pair<std::string, std::string>, std::string> values;
101
102
// Table values as doubles
103
std::map<std::pair<std::string, std::string>,
double
> dvalues;
104
105
// True if we should right-justify the table entries
106
bool
_right_justify;
107
108
// Allow MPI::all_reduce accessing dvalues
109
friend
class
MPI;
110
111
// Allow XMLTable accessing data
112
friend
class
XMLTable;
113
114
};
115
117
118
class
TableEntry
119
{
120
public
:
121
123
TableEntry
(std::string row, std::string col,
Table
& table);
124
126
~TableEntry
();
127
129
const
TableEntry
&
operator=
(std::size_t value);
130
132
const
TableEntry
&
operator=
(
int
value);
133
135
const
TableEntry
&
operator=
(
double
value);
136
138
const
TableEntry
&
operator=
(std::string value);
139
141
operator
std::string()
const
;
142
143
private
:
144
145
// Row
146
std::string _row;
147
148
// Column
149
std::string _col;
150
151
// Table
152
Table
& _table;
153
154
};
155
156
}
157
158
#endif
dolfin::MPI
Definition
MPI.h:71
dolfin::TableEntry
This class represents an entry in a Table.
Definition
Table.h:119
dolfin::TableEntry::TableEntry
TableEntry(std::string row, std::string col, Table &table)
Create table entry.
Definition
Table.cpp:319
dolfin::TableEntry::~TableEntry
~TableEntry()
Destructor.
Definition
Table.cpp:325
dolfin::TableEntry::operator=
const TableEntry & operator=(std::size_t value)
Assign value to table entry.
Definition
Table.cpp:330
dolfin::Table
Definition
Table.h:50
dolfin::Table::set
void set(std::string row, std::string col, int value)
Set value of table entry.
Definition
Table.cpp:53
dolfin::Table::get_value
double get_value(std::string row, std::string col) const
Get value of table entry.
Definition
Table.cpp:117
dolfin::Table::str
std::string str(bool verbose) const
Return informal string representation (pretty-print).
Definition
Table.cpp:191
dolfin::Table::operator=
const Table & operator=(const Table &table)
Assignment operator.
Definition
Table.cpp:174
dolfin::Table::~Table
~Table()
Destructor.
Definition
Table.cpp:42
dolfin::Table::get
std::string get(std::string row, std::string col) const
Get value of table entry.
Definition
Table.cpp:100
dolfin::Table::str_latex
std::string str_latex() const
Return informal string representation for LaTeX.
Definition
Table.cpp:278
dolfin::Table::Table
Table(std::string title="", bool right_justify=true)
Create empty table.
Definition
Table.cpp:35
dolfin::Table::operator()
TableEntry operator()(std::string row, std::string col)
Return table entry.
Definition
Table.cpp:47
dolfin::Variable::Variable
Variable()
Create unnamed variable.
Definition
Variable.cpp:31
dolfin::XMLTable
Output of XML representation of DOLFIN Table.
Definition
XMLTable.h:37
dolfin
Definition
adapt.h:30
Generated by
1.17.0