21#ifndef LIBSEMIGROUPS_DETAIL_REPORT_HPP_
22#define LIBSEMIGROUPS_DETAIL_REPORT_HPP_
32#include "libsemigroups/exception.hpp"
35#include "formatters.hpp"
43 t_id this_threads_id();
44 t_id thread_id(std::thread::id);
45 void reset_thread_ids();
47 bool is_report_suppressed_for(std::string_view);
59 TickerImpl* _ticker_impl;
64 template <
typename Func,
typename Time = std::chrono::seconds>
65 explicit Ticker(Func&& func, Time time = std::chrono::seconds(1));
67 template <
typename Func,
typename Time = std::chrono::seconds>
68 void operator()(Func&& func, Time time = std::chrono::seconds(1));
70 Ticker() : _ticker_impl(nullptr) {}
71 Ticker(Ticker
const&) =
delete;
72 Ticker(Ticker&&) =
delete;
73 Ticker& operator=(Ticker
const&) =
delete;
74 Ticker& operator=(Ticker&&) =
delete;
89 using Row = std::array<std::string, C + 1>;
91 std::array<size_t, C + 1> _col_widths;
92 std::vector<Row> _rows;
95 ReportCell() : _col_widths(), _rows() {
99 ReportCell(ReportCell
const&) =
delete;
100 ReportCell(ReportCell&&) =
delete;
101 ReportCell& operator=(ReportCell
const&) =
delete;
102 ReportCell& operator=(ReportCell&&) =
delete;
109 ReportCell& min_width(
size_t val) {
110 _col_widths.fill(val);
115 ReportCell& min_width(
size_t col,
size_t val) {
116 LIBSEMIGROUPS_ASSERT(col < C);
117 _col_widths[col + 1] = val;
122 template <
typename... Args>
123 void operator()(std::string_view fmt_str, Args&&... args);
127 template <
typename Func,
typename... Args>
128 void operator()(Func&& f,
char const* fmt_str, Args&&... args) {
129 operator()(fmt_str, f(args)...);
133 size_t line_width()
const;
143 template <typename... Args>
145 std::string prefix = fmt::format(
"#{}: ", detail::this_threads_id());
150 template <
typename... Args>
161 template <
typename... Args>
164 std::string_view prefix(sv);
165 auto pos = prefix.find(
":");
166 if (pos != std::string::npos) {
167 prefix.remove_suffix(prefix.size() - prefix.find(
":"));
168 if (detail::is_report_suppressed_for((prefix))) {
179 libsemigroups::detail::Timer
const& tmr) {
202 class SuppressReportFor {
203 std::string_view _prefix;
206 explicit SuppressReportFor(std::string_view);
207 ~SuppressReportFor();
Namespace for everything in the libsemigroups library.
Definition action.hpp:44
bool reporting_enabled() noexcept
No doc.
void report_default(std::string_view sv, Args &&... args)
No doc.
Definition report.hpp:162
static void report_elapsed_time(std::string_view prefix, libsemigroups::detail::Timer const &tmr)
No doc.
Definition report.hpp:178
std::string fmt_default(std::string_view sv, Args &&... args)
No doc.
Definition report.hpp:144
void report_no_prefix(std::string_view sv, Args &&... args)
No doc.
Definition report.hpp:151
ReportGuard(bool val=true)
Constructs a ReportGuard with reporting enabled by default.