DOLFINx
0.12.0.0
DOLFINx C++
Toggle main menu visibility
Loading...
Searching...
No Matches
dolfinx
common
Table.h
1
// Copyright (C) 2008-2011 Anders Logg
2
//
3
// This file is part of DOLFINx (https://www.fenicsproject.org)
4
//
5
// SPDX-License-Identifier: LGPL-3.0-or-later
6
7
#pragma once
8
9
#include <cstdint>
10
#include <map>
11
#include <mpi.h>
12
#include <string>
13
#include <string_view>
14
#include <variant>
15
#include <vector>
16
17
namespace
dolfinx
18
{
19
29
class
Table
30
{
31
public
:
34
enum class
Reduction
: std::uint8_t
35
{
36
average,
37
max,
38
min
39
};
40
42
Table
(std::string title =
""
,
bool
right_justify =
true
);
43
45
Table
(
const
Table
& table) =
default
;
46
48
Table
(
Table
&& table) =
default
;
49
51
~Table
() =
default
;
52
54
Table
&
operator=
(
const
Table
& table) =
default
;
55
57
Table
&
operator=
(
Table
&& table) =
default
;
58
63
void
set
(std::string_view row, std::string_view col,
64
std::variant<std::string, int, double> value);
65
70
std::variant<std::string, int, double>
get
(std::string_view row,
71
std::string_view col)
const
;
72
77
Table
reduce
(MPI_Comm comm,
Reduction
reduction)
const
;
78
80
std::string
name
;
81
83
std::string
str
()
const
;
84
85
private
:
86
// Row and column names
87
std::vector<std::string> _rows, _cols;
88
89
// Table entry values
90
std::map<std::pair<std::string, std::string>,
91
std::variant<std::string, int, double>>
92
_values;
93
94
// True if we should right-justify the table entries
95
bool
_right_justify;
96
};
97
98
}
// namespace dolfinx
dolfinx::Table::set
void set(std::string_view row, std::string_view col, std::variant< std::string, int, double > value)
Definition
Table.cpp:41
dolfinx::Table::operator=
Table & operator=(Table &&table)=default
Move assignment.
dolfinx::Table::Table
Table(const Table &table)=default
Copy constructor.
dolfinx::Table::get
std::variant< std::string, int, double > get(std::string_view row, std::string_view col) const
Definition
Table.cpp:57
dolfinx::Table::~Table
~Table()=default
Destructor.
dolfinx::Table::Reduction
Reduction
Definition
Table.h:35
dolfinx::Table::name
std::string name
Table name.
Definition
Table.h:80
dolfinx::Table::Table
Table(Table &&table)=default
Move constructor.
dolfinx::Table::Table
Table(std::string title="", bool right_justify=true)
Create empty table.
Definition
Table.cpp:35
dolfinx::Table::str
std::string str() const
Return string representation of the table.
Definition
Table.cpp:202
dolfinx::Table::reduce
Table reduce(MPI_Comm comm, Reduction reduction) const
Definition
Table.cpp:71
dolfinx::Table::operator=
Table & operator=(const Table &table)=default
Assignment operator.
dolfinx
Top-level namespace.
Definition
defines.h:12
Generated by
1.17.0