#include <progress.h>
This class simplifies the progress tracking of operations. Once created a operation can simply put the current progress into the object by calling SetProgressAndCheckBreak(). On the other end the ObservableProgressNotification can be hooked up to get notifications (e.g. for the ui). The implementation can handle 2 modes. 1.) simple mode: without calling AddProgressJob() there is one default job available with a weight of 1.0. you can use this mode to call all functions with idx == 0 to set or get the progress. 2.) multi mode: after calling AddProgressJob() the first time you need to provide the idx for the job you want to set or get. the implementation calculates the total progress depending on the weights of the individual sub jobs.
Public Member Functions | |
MAXON_METHOD Result< void > | InitProgress (const TimeValue &delayFirstProgress, const TimeValue &minProgressUpdate) |
MAXON_METHOD Result< Int > | AddProgressJob (Float jobWeight, const String &jobName) |
MAXON_METHOD Result< void > | SetProgressAndCheckBreak (Int jobIndex, Float percent) |
MAXON_METHOD Result< Float > | GetProgress (Int jobIndex) |
MAXON_METHOD Float | GetTotalWeight () const |
MAXON_OBSERVABLE (void, ObservableProgressNotification,(const ProgressRef &progress, Float percent, const TimeValue &duration, const TimeValue &expectedTotalTime), ObservableCombinerRunAllComponent) | |
MAXON_METHOD Result< Tuple< TimeValue, TimeValue > > | GetTime () const |
MAXON_METHOD String | GetDetailsText () const |
MAXON_METHOD void | SetDetailsText (const String &details) |
MAXON_METHOD Bool | SupportsCancelJob () const |
MAXON_METHOD Result< void > | SetCancelJobDelegate (JobCancelDelegate &&cancelJobDelegate) |
MAXON_METHOD Result< void > | CancelJob () |
MAXON_METHOD Bool | IsCancelled () |
Private Member Functions | |
MAXON_INTERFACE (ProgressInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.progress", MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel")) | |
|
private |
MAXON_METHOD Result<void> InitProgress | ( | const TimeValue & | delayFirstProgress, |
const TimeValue & | minProgressUpdate | ||
) |
[in] | delayFirstProgress | Time to delay the first progress notification. |
[in] | minProgressUpdate | Minimum time difference to call the progress callback. |
MAXON_METHOD Result<Int> AddProgressJob | ( | Float | jobWeight, |
const String & | jobName | ||
) |
The first call of AddProgressJob() switches from simple mode to multi job mode.
[in] | jobWeight | Add the weight for this job. All the weights are summed up and is taken into account for the overall percentage. |
MAXON_METHOD Result<void> SetProgressAndCheckBreak | ( | Int | jobIndex, |
Float | percent | ||
) |
Sets the progress of the current operation.
[in] | jobIndex | Job index returned by AddProgressJob() or 0 when running in simple mode. |
[in] | percent | Percentage between 0.0 and 1.0 of the done work. use UNKNOWNPROGRESS to set spinning mode |
MAXON_METHOD Result<Float> GetProgress | ( | Int | jobIndex | ) |
Returns the progress of the current operation.
[in] | jobIndex | Job index returned by AddProgressJob or 0 when running in simple mode or -1 to get the total progress. |
MAXON_METHOD Float GetTotalWeight | ( | ) | const |
GetTotalWeight returns the total weight of all jobs.
MAXON_OBSERVABLE | ( | void | , |
ObservableProgressNotification | , | ||
(const ProgressRef &progress, Float percent, const TimeValue &duration, const TimeValue &expectedTotalTime) | , | ||
ObservableCombinerRunAllComponent | |||
) |
Observable will be called as soon as the progress changes.
[in] | progress | Reference to this object. |
[in] | percent | Percentage between 0.0 and 1.0 of the done work. |
[in] | duration | Duration of the current operation. |
[in] | expectedTotalTime | Expected total time of the current operation. TIMEVALUE_INFINITE will be set for infinite time. |
[in] | userData | User data passed from the caller. |
MAXON_METHOD Result<Tuple<TimeValue, TimeValue> > GetTime | ( | ) | const |
GetTime returns a tuple with the "running time" and "expected total time" of the progress. Expected time might be TIMEVALUE_INFINITE if the time is unknown.
MAXON_METHOD String GetDetailsText | ( | ) | const |
Returns the details of the progress.
MAXON_METHOD void SetDetailsText | ( | const String & | details | ) |
Sets the details of the progress.
[in] | details | New details to be set. |
MAXON_METHOD Bool SupportsCancelJob | ( | ) | const |
SupportsCancelJob returns true if the progress object supports job cancellation.
MAXON_METHOD Result<void> SetCancelJobDelegate | ( | JobCancelDelegate && | cancelJobDelegate | ) |
SetCancelJobDelegate allows to set a job cancellation delegate.
[in] | cancelJobDelegate | Delegate which is called to cancel the job |
MAXON_METHOD Result<void> CancelJob | ( | ) |
CancelJob cancels the job by calling the job cancel delegate (see SetCancelJobDelegate).
MAXON_METHOD Bool IsCancelled | ( | ) |
IsCancelled returns true if the job is cancelled.