ImFusion SDK 4.3
Progress Class Referenceabstract

#include <ImFusion/Base/Progress.h>

Generic interface to report operation/computation progress. More...

+ Inheritance diagram for Progress:

Detailed Description

Generic interface to report operation/computation progress.

The Progress interface can host progress reports of multiple independent tasks, where each can represent either a regular progress bar with an individual number of steps, or a busy indicator that runs endlessly until stopped. Algorithms that want to provide progress/status information request their individual Task instance, store it locally as variable, and report their progress/status update through it. As soon as the instance goes out of scope the progress report is automatically removed form the parent reporter.

Basic usage example:

void processData(const std::vector<Foo>& data, Progress& progressHandler) {
Progress::Task task = progressHandler.addTask(data.size(), "Processing data");
for (auto& elem : data) {
if (task.wasCanceled())
break;
processElement(elem);
task.incrementStep();
}
}
Represents the progress/status report of an individual task hosted by a Progress.
Definition Progress.h:66
bool wasCanceled() const
Returns the flag whether the user requested cancellation of the current operation.
void incrementStep(int amount=1)
Increments the current progress value by the given amount (defaults to 1).
Generic interface to report operation/computation progress.
Definition Progress.h:41
Task addTask(int numSteps, const std::string &description)
Create a new progress report for an operation with the given number of steps.

By default the Progress interface is not thread-safe and must only be accessed from the same thread it was created on. You can request a limited support for concurrent access for individual tasks through Task::requestThreadSafety().

Classes

class  Task
 Represents the progress/status report of an individual task hosted by a Progress. More...
 

Public Member Functions

Task addTask (int numSteps, const std::string &description)
 Create a new progress report for an operation with the given number of steps.
 
Task addBusyIndicator (const std::string &description)
 Create a busy indicator for an operation but does not have a predefined number of steps.
 

Protected Member Functions

virtual void onTaskAdded (Task *task)=0
 Function is called whenever a new Task has been created.
 
virtual void onTaskUpdated (const Task *task)=0
 Function is called whenever the state of a Task has changed and the reporter should update its UI.
 
virtual bool onTaskRequestsThreadSafety (const Task *task)=0
 Function is called by Task::requestThreadSafety() in order to check whether the parent reporter supports concurrent access.
 
virtual void onTaskRemoved (const Task *task)=0
 Function is called whenever a Task is about to be destroyed and its pointer will become invalid.
 

Member Function Documentation

◆ addTask()

Task addTask ( int numSteps,
const std::string & description )

Create a new progress report for an operation with the given number of steps.

Convenience function with the same effect as calling the Task(this, numSteps, description) constructor.

◆ addBusyIndicator()

Task addBusyIndicator ( const std::string & description)

Create a busy indicator for an operation but does not have a predefined number of steps.

Convenience function with the same effect as calling the Task(this, 0, description) constructor.

◆ onTaskAdded()

virtual void onTaskAdded ( Task * task)
protectedpure virtual

Function is called whenever a new Task has been created.

Implemented in NestedProgress, ProgressDialog, and SubProgress.

◆ onTaskUpdated()

virtual void onTaskUpdated ( const Task * task)
protectedpure virtual

Function is called whenever the state of a Task has changed and the reporter should update its UI.

Implemented in ConeBeamReconLoader, NestedProgress, ProgressDialog, SubProgress, CalibrationProgress, and WatershedComputer.

◆ onTaskRequestsThreadSafety()

virtual bool onTaskRequestsThreadSafety ( const Task * task)
protectedpure virtual

Function is called by Task::requestThreadSafety() in order to check whether the parent reporter supports concurrent access.

Implementations are free to ignore this request and return false. Otherwise they must ensure that subsequent concurrent calls to any of the onTask...() callbacks are handled correctly without race conditions. Implementations are free to return to a unsynchronized implementation as soon as all multi-threaded tasks have been removed from the reporter.

Implemented in NestedProgress, ProgressDialog, and SubProgress.

◆ onTaskRemoved()

virtual void onTaskRemoved ( const Task * task)
protectedpure virtual

Function is called whenever a Task is about to be destroyed and its pointer will become invalid.

Implemented in NestedProgress, ProgressDialog, and SubProgress.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close