CAD Exchanger SDK
cadex::Base_ProgressStatus Class Reference

Provides progress status and notification mechanism. More...

Classes

class  CancellationChecker
 Base abstract class for cancelation checker registered in Base_ProgressStatus. More...
 
class  Observer
 Base abstract class for observers registered in Base_ProgressStatus. More...
 

Public Types

typedef float ValueType
 Defines a type of the progress status value and ranges.
 
typedef ValueType value_type
 Defines a type of the progress status value and ranges.
 

Public Member Functions

 Base_ProgressStatus ()
 Constructor.
 
 Base_ProgressStatus (const Base_ProgressStatus &theOther)
 Constructor. More...
 
 Base_ProgressStatus (const std::shared_ptr< internal::Base_ProgressStatusImpl > &theImpl)
 Constructor.
 
 ~Base_ProgressStatus ()
 Destructor.
 
Base_ProgressStatusoperator= (const Base_ProgressStatus &theOther)
 Assignment operator.
 
value_type Value () const
 Returns a current value. More...
 
void Register (Observer &theObserver, value_type theValueThreshold=0.1f, unsigned int theTimeThreshold=20U)
 Adds an observer that will be notified when the progress status has changed. More...
 
void Unregister (const Observer &theObserver)
 Removes a previously added observer. More...
 
void SetCancellationChecker (const CancellationChecker &theChecker)
 Sets the cancellation checker. More...
 
void RemoveCancellationChecker ()
 Removes the cancellation checker. More...
 
void Cancel ()
 Sets the flag that the operation has been canceled. More...
 
bool WasCanceled () const
 Returns true if the operation has been canceled. More...
 
const std::shared_ptr< internal::Base_ProgressStatusImpl > & Impl () const
 Returns an internal implementation object.
 

Static Public Member Functions

static value_type MinValue ()
 Returns a minimum value of the progress status. More...
 
static value_type MaxValue ()
 Returns a maximum value of the progress status. More...
 

Detailed Description

Provides progress status and notification mechanism.

Base_ProgressStatus has a current Value() which belongs to the range [0, 100]. The algorithms that support progress status update increment this value during their execution.

Upon value change the status object notifies its observers (subclasses of the Base_ProgressStatus::Observer class) registered with the Register() method. Thus, it implements the observer design pattern. The life span of the observer must be greater than the life span of the status object.

In the case there are no observers, the progress status incurs minimum overhead to the algorithm.

The status objects can be assigned to each other to create a chained range shared by several algorithms.

Base_ProgressScope objects can be used to split progress status range into smaller scopes. The scopes can be nested.

For details refer to Progress Status Support section and Progress Status Example.

Examples:
meshing/main.cxx, and progressindicator/main.cxx.

Constructor & Destructor Documentation

◆ Base_ProgressStatus()

cadex::Base_ProgressStatus::Base_ProgressStatus ( const Base_ProgressStatus theOther)

Constructor.

Copy constructor.

Member Function Documentation

◆ Cancel()

void cadex::Base_ProgressStatus::Cancel ( )

Sets the flag that the operation has been canceled.

See also
WasCanceled(), SetCancellationChecker().

◆ MaxValue()

static value_type cadex::Base_ProgressStatus::MaxValue ( )
inlinestatic

Returns a maximum value of the progress status.

By convention, returns 100.

◆ MinValue()

static value_type cadex::Base_ProgressStatus::MinValue ( )
inlinestatic

Returns a minimum value of the progress status.

By convention, returns 0.

◆ Register()

void cadex::Base_ProgressStatus::Register ( Base_ProgressStatus::Observer theObserver,
value_type  theValueThreshold = 0.1f,
unsigned int  theTimeThreshold = 20U 
)

Adds an observer that will be notified when the progress status has changed.

The life span of theObserver must be greater than one of this status object. If this cannot be guaranteed then the observer must be removed using the Unregister() method.

Registered observers will receive notification of a new value of this status object if the both following conditions are true:

  • the difference between a value used in previous notification is equal to or greater than theValueThreshold and
  • the time passed since previous notification is equal to or greater theTimeThreshold (specified in milliseconds).

Changing these thresholds you can manipulate frequency of the notifications for each observer.

See also
Unregister().
Examples:
progressindicator/main.cxx.

◆ RemoveCancellationChecker()

void cadex::Base_ProgressStatus::RemoveCancellationChecker ( )

Removes the cancellation checker.

Removes a checker set in SetCancellationChecker().

◆ SetCancellationChecker()

void cadex::Base_ProgressStatus::SetCancellationChecker ( const CancellationChecker theChecker)

Sets the cancellation checker.

The life span of theChecker must be greater than of this object (because internally only a pointer to theChecker is stored).

See also
RemoveCancellationChecker().
Examples:
progressindicator/main.cxx.

◆ Unregister()

void cadex::Base_ProgressStatus::Unregister ( const Observer theObserver)

Removes a previously added observer.

See also
Register().

◆ Value()

Base_ProgressStatus::value_type cadex::Base_ProgressStatus::Value ( ) const

Returns a current value.

The valus is in the range [0, 100].

Beware of internal rounding errors. You might want to round the returned value to get a required precision for more confident usage.

Examples:
progressindicator/main.cxx.

◆ WasCanceled()

bool cadex::Base_ProgressStatus::WasCanceled ( ) const

Returns true if the operation has been canceled.

The operation can be canceled either by explicit call to Cancel() or when a cancelation checker set with SetCancellationChecker() returned true.

See also
Cancel().
Examples:
meshing/main.cxx, and progressindicator/main.cxx.