Hide menu
Loading...
Searching...
No Matches
cadex::Base_ProgressStatus::Observer Class Referenceabstract

Base abstract class for observers registered in Base_ProgressStatus. More...

#include <cadex/Base_ProgressStatus.hxx>

Inherited by cadex::internal::Base_InterprocessClient::ProgressStatusObserver, cadex::internal::Base_InterprocessServer< Executor >::ProgressStatusObserver, and cadex::internal::CadExModelXDEBrowser_ProgressBarObserver.

Public Member Functions

 Observer ()
 Constructor.
 
 Observer (const Observer &theOther)
 Constructor.
 
virtual ~Observer ()
 Destructor.
 
Observeroperator= (const Observer &theOther)
 Assignment operator.
 
virtual void ChangedValue (const Base_ProgressStatus &theStatus)=0
 A callback called when the progress status has changed its value.
 
virtual void Completed (const Base_ProgressStatus &theStatus)=0
 A callback called when the progress status object is being destructed.
 
virtual void Canceled (const Base_ProgressStatus &theStatus)
 A callback called when the progress status object was set to the canceled state.
 
void SetNotifyingThread ()
 Sets the current thread as the only thread sending notifications.
 
void SetNotifyingThread (const Observer &theOther)
 Sets the same notification thread as used by theOther observer.
 
void SetAllNotifyingThreads ()
 Enables sending notifications from any thread.
 
bool CanBeNotifiedFromThisThread () const
 Returns true if notifications can be send from the current thread.
 

Detailed Description

Base abstract class for observers registered in Base_ProgressStatus.

Subclasses must redefined virtual functions ChangedValue() and Completed(). User-defined observers must be registered in the progress status object with the help of Base_ProgressStatus::Register().

By default the observer will only be notified in the same thread it was created. This is to minimize a risk of data race in multi-threaded applications if the user-defined observer is not thread-safe. To enable notifications from other threads use SetAllNotifyingThreads() to allow notifications from any thread or different syntaxes of SetNotifyingThread() to enable notifications from single thread.

Examples
misc/progressindicator/main.cxx, and misc/progressindicatorgui/main.cxx.

Constructor & Destructor Documentation

◆ Observer() [1/2]

cadex::Base_ProgressStatus::Observer::Observer ( )

Constructor.

Default constructor.

◆ Observer() [2/2]

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

Constructor.

Copy constructor.

Member Function Documentation

◆ Canceled()

void cadex::Base_ProgressStatus::Observer::Canceled ( const Base_ProgressStatus theStatus)
virtual

A callback called when the progress status object was set to the canceled state.

This callback is called when Base_ProgressStatus::Cancel() was called. Default implementation is empty.

◆ ChangedValue()

virtual void cadex::Base_ProgressStatus::Observer::ChangedValue ( const Base_ProgressStatus theStatus)
pure virtual

A callback called when the progress status has changed its value.

Subclasses must redefine this method to process this event.

◆ Completed()

virtual void cadex::Base_ProgressStatus::Observer::Completed ( const Base_ProgressStatus theStatus)
pure virtual

A callback called when the progress status object is being destructed.

Subclasses must redefine this method to process this event.

◆ SetAllNotifyingThreads()

void cadex::Base_ProgressStatus::Observer::SetAllNotifyingThreads ( )

Enables sending notifications from any thread.

See also
SetNotifyingThread().

◆ SetNotifyingThread() [1/2]

void cadex::Base_ProgressStatus::Observer::SetNotifyingThread ( )

Sets the current thread as the only thread sending notifications.

See also
SetAllNotifyingThreads().

◆ SetNotifyingThread() [2/2]

void cadex::Base_ProgressStatus::Observer::SetNotifyingThread ( const Observer theOther)

Sets the same notification thread as used by theOther observer.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
SetAllNotifyingThreads().