ObservableRef< DELEGATE > Class Template Reference

#include <observable.h>

Inheritance diagram for ObservableRef< DELEGATE >:

Detailed Description

template<typename DELEGATE>
class maxon::ObservableRef< DELEGATE >

Observable Class that allows to add subscribers to observables.

Template Parameters
DELEGATEDelegate of the observable class defined in the MAXON_OBSERVABLE macro. Usually "Delegate" is appended to the observable name, e.g. ObservableMachineStateChangedDelegate.

Public Member Functions

template<typename FN >
Result< FunctionBaseRef > AddObserver (ObserverObjectInterface *observer, FN &&fn, Int priority=ADDOBSERVER_DEFAULTPRIORITY) const
 
template<typename FN >
Result< FunctionBaseRef > AddObserver (ObserverObjectInterface *observer, FN &&fn, const JobQueueRef &queue, Int priority=ADDOBSERVER_DEFAULTPRIORITY) const
 
template<typename FN >
Result< FunctionBaseRef > AddObserver (FN &&fn, Int priority=ADDOBSERVER_DEFAULTPRIORITY) const
 
template<typename FN , typename = typename std::enable_if<!STD_IS_REPLACEMENT(convertible, typename std::decay<FN>::type, ObserverObjectInterface*)>::type>
Result< FunctionBaseRef > AddObserver (FN &&fn, const JobQueueRef &queue, Int priority=ADDOBSERVER_DEFAULTPRIORITY) const
 

Static Public Member Functions

static ObservableRef< DELEGATE > NullValue ()
 

Member Function Documentation

◆ AddObserver() [1/4]

Result<FunctionBaseRef> AddObserver ( ObserverObjectInterface observer,
FN &&  fn,
Int  priority = ADDOBSERVER_DEFAULTPRIORITY 
) const

Adds a notification lambda as a subscriber to a observable.

Parameters
[in]observerObject to connect with the observable. This can be nullptr.
[in]fnLambda function (or object with Handle* method) that should be called when the observable is fired.
[in]priorityPriority in execution. Use ADDOBSERVER_DEFAULTPRIORITY as default. Greater values will execute later.
Returns
If successful the entry object is returned. In case of failures a nullptr.

◆ AddObserver() [2/4]

Result<FunctionBaseRef> AddObserver ( ObserverObjectInterface observer,
FN &&  fn,
const JobQueueRef queue,
Int  priority = ADDOBSERVER_DEFAULTPRIORITY 
) const

Adds a notification lambda as a subscriber to a observable.

Parameters
[in]observerObject to connect with the observable. This can be nullptr.
[in]fnLambda function (or object with Handle* method) that should be called when the observable is fired.
[in]queueQueue in which the notification should be send. queuing is only possible if the observable has no return value.
[in]priorityPriority in execution. Use ADDOBSERVER_DEFAULTPRIORITY as default. Greater values will execute later.
Returns
If successful the entry object is returned. In case of failures a nullptr.

◆ AddObserver() [3/4]

Result<FunctionBaseRef> AddObserver ( FN &&  fn,
Int  priority = ADDOBSERVER_DEFAULTPRIORITY 
) const

Adds a notification lambda as a subscriber to a observable.

Parameters
[in]fnLambda function (or object with Handle* method) that should be called when the observable is fired.
[in]priorityPriority in execution. Use ADDOBSERVER_DEFAULTPRIORITY as default. Greater values will execute later.
Returns
If successful the entry object is returned. In case of failures a nullptr.

◆ AddObserver() [4/4]

Result<FunctionBaseRef> AddObserver ( FN &&  fn,
const JobQueueRef queue,
Int  priority = ADDOBSERVER_DEFAULTPRIORITY 
) const

Adds a notification lambda as a subscriber to a observable.

Parameters
[in]fnLambda function (or object with Handle* method) that should be called when the observable is fired.
[in]queueQueue in which the notification should be send. queuing is only possible if the observable has no return value.
[in]priorityPriority in execution. Use ADDOBSERVER_DEFAULTPRIORITY as default. Greater values will execute later.
Returns
If successful the entry object is returned. In case of failures a nullptr.

◆ NullValue()

static ObservableRef<DELEGATE> NullValue ( )
static

Helper function for data type registration.