ProgressInterface Class Reference

#include <progress.h>

Inheritance diagram for ProgressInterface:

Detailed Description

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< IntAddProgressJob (const Float jobWeight, const String &jobName)
 
MAXON_METHOD Result< void > SetProgressAndCheckBreak (Int jobIndex, Float percent)
 
MAXON_METHOD Result< FloatGetProgress (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.image.interface.mediasessionprogress")
 

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( ProgressInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.image.interface.mediasessionprogress"   
)
private

◆ InitProgress()

MAXON_METHOD Result<void> InitProgress ( const TimeValue delayFirstProgress,
const TimeValue minProgressUpdate 
)
Parameters
[in]delayFirstProgressTime to delay the first progress notification.
[in]minProgressUpdateMinimum time difference to call the progress callback.

◆ AddProgressJob()

MAXON_METHOD Result<Int> AddProgressJob ( const Float  jobWeight,
const String jobName 
)

The first call of AddProgressJob() switches from simple mode to multi job mode.

Parameters
[in]jobWeightAdd the weight for this job. All the weights are summed up and is taken into account for the overall percentage.
Returns
Index of the newly created job.

◆ SetProgressAndCheckBreak()

MAXON_METHOD Result<void> SetProgressAndCheckBreak ( Int  jobIndex,
Float  percent 
)

Sets the progress of the current operation.

Parameters
[in]jobIndexJob index returned by AddProgressJob() or 0 when running in simple mode.
[in]percentPercentage between 0.0 and 1.0 of the done work. use UNKNOWNPROGRESS to set spinning mode

◆ GetProgress()

MAXON_METHOD Result<Float> GetProgress ( Int  jobIndex)

Returns the progress of the current operation.

Parameters
[in]jobIndexJob index returned by AddProgressJob or 0 when running in simple mode or -1 to get the total progress.
Returns
Progress between 0 and 1 or UNKNOWNPROGRESS for unknown duration (ui should show a spinner in that case.

◆ GetTotalWeight()

MAXON_METHOD Float GetTotalWeight ( ) const

GetTotalWeight returns the total weight of all jobs.

◆ MAXON_OBSERVABLE()

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.

Parameters
[in]progressReference to this object.
[in]percentPercentage between 0.0 and 1.0 of the done work.
[in]durationDuration of the current operation.
[in]expectedTotalTimeExpected total time of the current operation. TIMEVALUE_INFINITE will be set for infinite time.
[in]userDataUser data passed from the caller.

◆ GetTime()

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.

◆ GetDetailsText()

MAXON_METHOD String GetDetailsText ( ) const

Returns the details of the progress.

◆ SetDetailsText()

MAXON_METHOD void SetDetailsText ( const String details)

Sets the details of the progress.

Parameters
[in]detailsNew details to be set.

◆ SupportsCancelJob()

MAXON_METHOD Bool SupportsCancelJob ( ) const

SupportsCancelJob returns true if the progress object supports job cancellation.

◆ SetCancelJobDelegate()

MAXON_METHOD Result<void> SetCancelJobDelegate ( JobCancelDelegate &&  cancelJobDelegate)

SetCancelJobDelegate allows to set a job cancellation delegate.

Parameters
[in]cancelJobDelegateDelegate which is called to cancel the job
Returns
OK on success.

◆ CancelJob()

MAXON_METHOD Result<void> CancelJob ( )

CancelJob cancels the job by calling the job cancel delegate (see SetCancelJobDelegate).

Returns
OK on success.

◆ IsCancelled()

MAXON_METHOD Bool IsCancelled ( )

IsCancelled returns true if the job is cancelled.