Cadabra
Computer algebra system for field theory problems
Classes | Public Member Functions | Public Attributes | Private Attributes | List of all members
ProgressMonitor Class Reference

Description

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< Totaltotals () 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< Blockcall_stack
 
std::map< std::string, Totalcall_totals
 

Constructor & Destructor Documentation

◆ ProgressMonitor()

ProgressMonitor::ProgressMonitor ( std::function< void(const std::string &, int, int)>  report = nullptr,
int  report_level = 2 
)

◆ ~ProgressMonitor()

ProgressMonitor::~ProgressMonitor ( )
virtual

Member Function Documentation

◆ group()

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.

◆ message()

void ProgressMonitor::message ( const std::string &  msg)

Log out-of-band messages to the current block.

◆ print()

void ProgressMonitor::print ( ) const

Generate debug output on cerr.

◆ progress() [1/3]

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.

◆ progress() [2/3]

void ProgressMonitor::progress ( int  n)

◆ progress() [3/3]

void ProgressMonitor::progress ( int  n,
int  total 
)

◆ totals()

std::vector< ProgressMonitor::Total > ProgressMonitor::totals ( ) const

Member Data Documentation

◆ call_stack

std::stack<Block> ProgressMonitor::call_stack
private

◆ call_totals

std::map<std::string, Total> ProgressMonitor::call_totals
private

◆ report

std::function<void(const std::string&, int, int)> ProgressMonitor::report

Callback for reporting a progress update.

◆ report_level

int ProgressMonitor::report_level

The documentation for this class was generated from the following files: