Loading...
Searching...
No Matches
Table.h
// Copyright (C) 2008-2011 Anders Logg
//
// This file is part of DOLFINx (https://www.fenicsproject.org)
//
// SPDX-License-Identifier: LGPL-3.0-or-later
#pragma once
#include <cstdint>
#include <map>
#include <mpi.h>
#include <string>
#include <variant>
#include <vector>
namespace dolfinx
{
class Table
{
public:
enum class Reduction : std::uint8_t
{
average,
max,
min
};
Table(std::string title = "", bool right_justify = true);
Table(const Table& table) = default;
Table(Table&& table) = default;
~Table() = default;
Table& operator=(const Table& table) = default;
Table& operator=(Table&& table) = default;
void set(const std::string& row, const std::string& col,
std::variant<std::string, int, double> value);
std::variant<std::string, int, double> get(const std::string& row,
const std::string& col) const;
Table reduce(MPI_Comm comm, Reduction reduction) const;
std::string name;
std::string str() const;
private:
// Row and column names
std::vector<std::string> _rows, _cols;
// Table entry values
std::map<std::pair<std::string, std::string>,
std::variant<std::string, int, double>>
_values;
// True if we should right-justify the table entries
bool _right_justify;
};
} // namespace dolfinx
dolfinx::Table::operator=
Table & operator=(Table &&table)=default
Move assignment.
dolfinx::Table::Table
Table(const Table &table)=default
Copy constructor.
dolfinx::Table::set
void set(const std::string &row, const std::string &col, std::variant< std::string, int, double > value)
Definition Table.cpp:39
dolfinx::Table::~Table
~Table()=default
Destructor.
dolfinx::Table::Reduction
Reduction
Definition Table.h:34
dolfinx::Table::name
std::string name
Table name.
Definition Table.h:79
dolfinx::Table::get
std::variant< std::string, int, double > get(const std::string &row, const std::string &col) const
Definition Table.cpp:55
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:33
dolfinx::Table::str
std::string str() const
Return string representation of the table.
Definition Table.cpp:200
dolfinx::Table::reduce
Table reduce(MPI_Comm comm, Reduction reduction) const
Definition Table.cpp:69
dolfinx::Table::operator=
Table & operator=(const Table &table)=default
Assignment operator.
dolfinx
Top-level namespace.
Definition defines.h:12