HAL  v4.5.0-124-g47ab54673
The Hardware Analyzer - a comprehensive reverse engineering and manipulation framework for gate-level netlists.
hal::user_feedback::ProgressPrinter Class Reference

#include <hal_core/plugin_system/user_feedback.h>

Collaboration diagram for hal::user_feedback::ProgressPrinter:
Collaboration graph

Public Member Functions

 ProgressPrinter (const std::string &message, u32 max_detail_size=0)
 
 ~ProgressPrinter ()
 
 ProgressPrinter (const ProgressPrinter &)=delete
 
ProgressPrinteroperator= (const ProgressPrinter &)=delete
 
void report (float progress, const std::string &detail="")
 
void set_message (const std::string &message)
 
void clear ()
 
void reset ()
 

Detailed Description

Brackets a long-running operation that can say how far along it is, and reports that both as a progress bar on the terminal and to the progress display of the user interface.

This is a ProgressScope that an operation can report into, so use it instead of a scope wherever progress can be quantified at all, and a bare ProgressScope only where it cannot. Covering both the terminal and the user interface with one object means a plugin reports its progress once and reaches whoever is watching. The bar is only drawn if stderr is a terminal wide enough for it, so redirected output stays clean.

Definition at line 119 of file user_feedback.h.

Constructor & Destructor Documentation

◆ ProgressPrinter() [1/2]

hal::user_feedback::ProgressPrinter::ProgressPrinter ( const std::string &  message,
u32  max_detail_size = 0 
)
explicit

Construct a progress printer and show the progress display at zero percent.

Parameters
[in]message- The message naming the operation, shown alongside the progress.
[in]max_detail_size- The number of characters to reserve for the detail passed to report, 0 for none.

Definition at line 70 of file user_feedback.cpp.

References reset().

◆ ~ProgressPrinter()

hal::user_feedback::ProgressPrinter::~ProgressPrinter ( )

Erases the progress bar and dismisses the progress display, so that whatever comes next starts clean.

Definition at line 86 of file user_feedback.cpp.

References clear().

◆ ProgressPrinter() [2/2]

hal::user_feedback::ProgressPrinter::ProgressPrinter ( const ProgressPrinter )
delete

Member Function Documentation

◆ clear()

void hal::user_feedback::ProgressPrinter::clear ( )

Erase the progress bar, for instance before printing something else.

Definition at line 157 of file user_feedback.cpp.

Referenced by hal::dataflow::pre_processing::identify_register_stages(), and ~ProgressPrinter().

◆ operator=()

ProgressPrinter& hal::user_feedback::ProgressPrinter::operator= ( const ProgressPrinter )
delete

◆ report()

void hal::user_feedback::ProgressPrinter::report ( float  progress,
const std::string &  detail = "" 
)

Report how far the operation has come along.

Cheap to call in a tight loop: the bar is only redrawn when it actually changes.

Parameters
[in]progress- The progress, from 0.0 to 1.0.
[in]detail- What the operation is doing right now, shown next to the bar. Truncated to the maximum detail size.

Definition at line 97 of file user_feedback.cpp.

References hal::output, and hal::user_feedback::report_progress().

Referenced by hal::dataflow::pre_processing::identify_register_stages().

◆ reset()

void hal::user_feedback::ProgressPrinter::reset ( )

Forget what has been drawn, so that the next report draws the bar again from scratch.

Definition at line 166 of file user_feedback.cpp.

Referenced by ProgressPrinter().

◆ set_message()

void hal::user_feedback::ProgressPrinter::set_message ( const std::string &  message)

Change the message naming the operation, for instance when it moves on to another phase.

Parameters
[in]message- The message naming the operation.

Definition at line 91 of file user_feedback.cpp.

References hal::user_feedback::report_progress().


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