ObservableBaseInterface Class Reference

#include <observable.h>

Inheritance diagram for ObservableBaseInterface:

Detailed Description

Base Observable Class that allows to add subscribers to observables. Never use this directly, instead use ObservableRef<>.

Public Member Functions

MAXON_METHOD Result< void > Init (ObserverObjectInterface *owner, const Id &observableName)
 
MAXON_METHOD Id GetObservableId () const
 
MAXON_METHOD void PrivateDisconnectAll (ObserverObjectInterface *observer, Int pass)
 
MAXON_FUNCTION void Disconnect (ObserverObjectInterface *observer)
 
MAXON_FUNCTION void Free ()
 
MAXON_METHOD Result< void > AddObserver (ObserverObjectInterface *observer, const FunctionBaseRef &observerFunction, Int priority=ADDOBSERVER_DEFAULTPRIORITY)
 
MAXON_METHOD Result< DataNotify (const Block< const ConstDataPtr > &args) const
 
MAXON_METHOD Bool RemoveObserver (const FunctionBaseRef &observerEntry)
 
MAXON_METHOD void SetInverseNotification (Bool inverse)
 
MAXON_METHOD Int GetObserverCount ()
 
MAXON_METHOD ObserverObjectInterfaceGetOwner () const
 

Private Member Functions

 MAXON_INTERFACE (ObservableBaseInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.observablebase", MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel"))
 

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( ObservableBaseInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.observablebase"  ,
MAXON_IMPLEMENTATION_MODULE("net.maxon.kernel")   
)
private

◆ Init()

MAXON_METHOD Result<void> Init ( ObserverObjectInterface owner,
const Id observableName 
)

This function needs to be called in the implementation InitComponent() function.

Parameters
[in]ownerPointer to the observable owner.
[in]observableNameName of the observable. This observable name is sent via ObserverConnectNotify/ObserverDisconnectNotify.
Returns
True if the function operates successful.

◆ GetObservableId()

MAXON_METHOD Id GetObservableId ( ) const

This function returns the Id given in the Init function.

◆ PrivateDisconnectAll()

MAXON_METHOD void PrivateDisconnectAll ( ObserverObjectInterface observer,
Int  pass 
)

This function needs to be called in the implementation FreeComponent() function. Don't use this function directly, only for internal use!

Parameters
[in]observerNullptr if all observables should be disconnected. If a object is given only this specific observables are disconnected.
[in]passInternal use only.

◆ Disconnect()

MAXON_FUNCTION void Disconnect ( ObserverObjectInterface observer)

This function needs to be called in the implementation FreeComponent() function.

Parameters
[in]observerNullptr if all observables should be disconnected. If a object is given only this specific observables are disconnected.

◆ Free()

MAXON_FUNCTION void Free ( )

This function needs to be called in the implementation FreeComponent() function.

◆ AddObserver()

MAXON_METHOD Result<void> AddObserver ( ObserverObjectInterface observer,
const FunctionBaseRef &  observerFunction,
Int  priority = ADDOBSERVER_DEFAULTPRIORITY 
)

Add a subscriber to the observable. Notes: the implementation need to take the ownership of the observerFunction only if the function succeeds. in the case of an error (returning nullptr) the wrapper class outside frees the memory!

Parameters
[in]observerPointer to a observer object. This parameter can be nullptr.
[in]observerFunctionFunction object that is stored with in the observable.
[in]priorityPriority in execution. Use ADDOBSERVER_DEFAULTPRIORITY as default. Greater values will execute later.
Returns
OK on success.

◆ Notify()

MAXON_METHOD Result<Data> Notify ( const Block< const ConstDataPtr > &  args) const

Send a notification to all subscribers.

Parameters
[in]argsArguments packed into a Block<ConstDataPtr>.
Returns
The combined result of the observable. See CombinerInterface.

◆ RemoveObserver()

MAXON_METHOD Bool RemoveObserver ( const FunctionBaseRef &  observerEntry)

Remove a observable entry from the subscriber list.

Parameters
[in]observerEntryEntry to remove.

◆ SetInverseNotification()

MAXON_METHOD void SetInverseNotification ( Bool  inverse)

Set true to Notify() in inverse order.

◆ GetObserverCount()

MAXON_METHOD Int GetObserverCount ( )

Gets the number of observers.

Returns
The number of observers.

◆ GetOwner()

Gets the owner of the observable.

Returns
The owner of the observable.