Lightweight 0.20261031.0
Loading...
Searching...
No Matches
Lightweight::ProgressTask Class Referenceabstract

Progress of one task, which the library reports and a host (a CLI, a GUI) renders. More...

#include <ProgressTask.hpp>

Inheritance diagram for Lightweight::ProgressTask:
Lightweight::NullProgressTask

Public Types

enum class  LogLevel : std::uint8_t { Info , Warning , Error }
 Severity of a message reported against a task. More...
 

Public Member Functions

 ProgressTask (ProgressTask const &)=delete
 
 ProgressTask (ProgressTask &&)=delete
 
ProgressTask & operator= (ProgressTask const &)=delete
 
ProgressTask & operator= (ProgressTask &&)=delete
 
virtual ~ProgressTask ()=default
 Marks the task finished.
 
virtual std::unique_ptr< ProgressTask > BeginSubTask (std::string_view title, std::uint64_t total)=0
 
virtual void SetTotal (std::uint64_t total)=0
 
virtual void Advance (std::uint64_t count=1, std::string_view detail={})=0
 
virtual void Log (LogLevel level, std::string_view message)=0
 
virtual bool IsCancellationRequested () const =0
 
virtual void Fail (std::string_view reason)=0
 

Detailed Description

Progress of one task, which the library reports and a host (a CLI, a GUI) renders.

Tasks nest: a task opens sub-tasks for its parts, and destroying a task marks it finished. A total of 0 makes a task indeterminate: the host shows that it runs and for how long, not how far it got. The host implements this interface and the library only calls it, possibly from a worker thread, one task tree at a time. New virtual functions are only ever appended at the end.

Definition at line 18 of file ProgressTask.hpp.

Member Enumeration Documentation

◆ LogLevel

enum class Lightweight::ProgressTask::LogLevel : std::uint8_t
strong

Severity of a message reported against a task.

Definition at line 22 of file ProgressTask.hpp.

Member Function Documentation

◆ BeginSubTask()

virtual std::unique_ptr< ProgressTask > Lightweight::ProgressTask::BeginSubTask ( std::string_view  title,
std::uint64_t  total 
)
pure virtual

Opens a child task.

Parameters
titleWhat the child does, e.g. "Unit 2 of 5".
totalUnits of work of the child; 0 = indeterminate.
Returns
The child; destroying it finishes it.

Implemented in Lightweight::NullProgressTask.

◆ SetTotal()

virtual void Lightweight::ProgressTask::SetTotal ( std::uint64_t  total)
pure virtual

Replaces the task's total.

Parameters
totalUnits of work; 0 = indeterminate.

Implemented in Lightweight::NullProgressTask.

◆ Advance()

virtual void Lightweight::ProgressTask::Advance ( std::uint64_t  count = 1,
std::string_view  detail = {} 
)
pure virtual

Records more work done and names what runs now. Advance(0, detail) only changes the detail.

Parameters
countUnits of work done since the last call.
detailWhat the task does now; empty keeps the previous detail.

Implemented in Lightweight::NullProgressTask.

◆ Log()

virtual void Lightweight::ProgressTask::Log ( LogLevel  level,
std::string_view  message 
)
pure virtual

Reports a message about the task.

Parameters
levelThe message's severity.
messageThe message, UTF-8.

Implemented in Lightweight::NullProgressTask.

◆ IsCancellationRequested()

virtual bool Lightweight::ProgressTask::IsCancellationRequested ( ) const
pure virtual
Returns
True once the user asked to cancel; callers stop at their next safe point.

Implemented in Lightweight::NullProgressTask.

◆ Fail()

virtual void Lightweight::ProgressTask::Fail ( std::string_view  reason)
pure virtual

Marks the task failed; destroying it then ends it as failed, not as done.

Parameters
reasonWhat went wrong, UTF-8.

Implemented in Lightweight::NullProgressTask.


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