Cadabra
Computer algebra system for field theory problems
|
Object keeping track of time spent in nested execution blocks, and keeping track of out-of-band messages produced by these blocks.
The messaging facility is currently experimental.
#include <ProgressMonitor.hh>
Classes | |
class | Block |
A single element of the nested group call stack. More... | |
class | Total |
Object to accumulate total time and call counts for a particular named execution group. More... | |
Public Member Functions | |
ProgressMonitor (std::function< void(const std::string &, int, int)> report=nullptr, int report_level=2) | |
virtual | ~ProgressMonitor () |
void | group (std::string name="", int total=0, int level=-1) |
Start a new named group, or close the innermost one in case the name argument is empty. More... | |
void | progress () |
Set the progress of the current top-level block to be n out of total steps. More... | |
void | progress (int n) |
void | progress (int n, int total) |
void | message (const std::string &) |
Log out-of-band messages to the current block. More... | |
void | print () const |
Generate debug output on cerr . More... | |
std::vector< Total > | totals () const |
Public Attributes | |
std::function< void(const std::string &, int, int)> | report |
Callback for reporting a progress update. More... | |
int | report_level |
Private Attributes | |
std::stack< Block > | call_stack |
std::map< std::string, Total > | call_totals |
ProgressMonitor::ProgressMonitor | ( | std::function< void(const std::string &, int, int)> | report = nullptr , |
int | report_level = 2 |
||
) |
|
virtual |
void ProgressMonitor::group | ( | std::string | name = "" , |
int | total = 0 , |
||
int | level = -1 |
||
) |
Start a new named group, or close the innermost one in case the name
argument is empty.
All time spent inbetween calls to group open/close calls is accumulated in a Totals
object, one for each group name. These Totals
blocks can be retrieved from the totals
function. FIXME: call this block
.
void ProgressMonitor::message | ( | const std::string & | msg | ) |
Log out-of-band messages to the current block.
void ProgressMonitor::print | ( | ) | const |
Generate debug output on cerr
.
void ProgressMonitor::progress | ( | ) |
Set the progress of the current top-level block to be n
out of total
steps.
It is possible to change totals
at every call (e.g. in situations where the algorithm cannot possibly figure out how many total steps there are to take.
void ProgressMonitor::progress | ( | int | n | ) |
void ProgressMonitor::progress | ( | int | n, |
int | total | ||
) |
std::vector< ProgressMonitor::Total > ProgressMonitor::totals | ( | ) | const |
|
private |
|
private |
std::function<void(const std::string&, int, int)> ProgressMonitor::report |
Callback for reporting a progress update.
int ProgressMonitor::report_level |