/usr/include/dolfin/log/Table.h is in libdolfin-dev 1.4.0+dfsg-4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | // Copyright (C) 2008-2011 Anders Logg
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// First added: 2008-07-19
// Last changed: 2011-10-07
#ifndef __TABLE_H
#define __TABLE_H
#include <map>
#include <set>
#include <vector>
#include <dolfin/common/Variable.h>
namespace dolfin
{
class TableEntry;
/// This class provides storage and pretty-printing for tables.
/// Example usage:
///
/// Table table("Timings");
///
/// table("uBLAS", "Assemble") = 0.010;
/// table("uBLAS", "Solve") = 0.020;
/// table("PETSc", "Assemble") = 0.011;
/// table("PETSc", "Solve") = 0.019;
/// table("Epetra", "Assemble") = 0.012;
/// table("Epetra", "Solve") = 0.018;
///
/// info(table);
class Table : public Variable
{
public:
/// Create empty table
Table(std::string title="", bool right_justify=true);
/// Destructor
~Table();
/// Return table entry
TableEntry operator() (std::string row, std::string col);
/// Set value of table entry
void set(std::string row, std::string col, int value);
/// Set value of table entry
void set(std::string row, std::string col, std::size_t value);
/// Set value of table entry
void set(std::string row, std::string col, double value);
/// Set value of table entry
void set(std::string row, std::string col, std::string value);
/// Get value of table entry
std::string get(std::string row, std::string col) const;
/// Get value of table entry
double get_value(std::string row, std::string col) const;
/// Return table title
std::string title() const;
/// Assignment operator
const Table& operator= (const Table& table);
/// Return informal string representation (pretty-print)
std::string str(bool verbose) const;
/// Return informal string representation for LaTeX
std::string str_latex() const;
private:
// Table title
std::string _title;
// Rows
std::vector<std::string> rows;
std::set<std::string> row_set;
// Columns
std::vector<std::string> cols;
std::set<std::string> col_set;
// Table values as strings
std::map<std::pair<std::string, std::string>, std::string> values;
// Table values as doubles
std::map<std::pair<std::string, std::string>, double> dvalues;
// True if we should right-justify the table entries
bool _right_justify;
};
/// This class represents an entry in a Table
class TableEntry
{
public:
/// Create table entry
TableEntry(std::string row, std::string col, Table& table);
/// Destructor
~TableEntry();
/// Assign value to table entry
const TableEntry& operator= (std::size_t value);
/// Assign value to table entry
const TableEntry& operator= (int value);
/// Assign value to table entry
const TableEntry& operator= (double value);
/// Assign value to table entry
const TableEntry& operator= (std::string value);
/// Cast to entry value
operator std::string() const;
private:
// Row
std::string _row;
// Column
std::string _col;
// Table
Table& _table;
};
}
#endif
|