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) const
 
template<typename FN >
Result< FunctionBaseRef > AddObserver (ObserverObjectInterface *observer, FN &&fn, const JobQueueRef &queue) const
 
template<typename FN >
Result< FunctionBaseRef > AddObserver (FN &&fn) const
 
template<typename FN , typename = typename std::enable_if<!std::is_convertible<typename std::decay<FN>::type, ObserverObjectInterface*>::value>::type>
Result< FunctionBaseRef > AddObserver (FN &&fn, const JobQueueRef &queue) const
 

Static Public Member Functions

static ObservableRef< DELEGATENullValue ()
 

Member Function Documentation

◆ AddObserver() [1/4]

Result<FunctionBaseRef> AddObserver ( ObserverObjectInterface observer,
FN &&  fn 
) 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.
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 
) 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.
Returns
If successful the entry object is returned. In case of failures a nullptr.

◆ AddObserver() [3/4]

Result<FunctionBaseRef> AddObserver ( FN &&  fn) 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.
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 
) 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.
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.