#include <observable.h>
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 | _intDisconnectAll (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< Data > | Notify (const Block< const ConstDataPtr > &args) const |
MAXON_METHOD Result< void > | RemoveObserver (const FunctionBaseRef &observerEntry) |
MAXON_METHOD void | SetInverseNotification (Bool inverse) |
MAXON_METHOD Int | GetObserverCount () |
MAXON_METHOD ObserverObjectInterface * | GetOwner () const |
Private Member Functions | |
MAXON_INTERFACE (ObservableBaseInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.observablebase") | |
|
private |
MAXON_METHOD Result<void> Init | ( | ObserverObjectInterface * | owner, |
const Id & | observableName | ||
) |
This function needs to be called in the implementation InitComponent() function.
[in] | owner | Pointer to the observable owner. |
[in] | observableName | Name of the observable. This observable name is sent via ObserverConnectNotify/ObserverDisconnectNotify. |
MAXON_METHOD Id GetObservableId | ( | ) | const |
This function returns the Id given in the Init function.
MAXON_METHOD void _intDisconnectAll | ( | 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!
[in] | observer | Nullptr if all observables should be disconnected. If a object is given only this specific observables are disconnected. |
[in] | pass | Internal use only. |
MAXON_FUNCTION void Disconnect | ( | ObserverObjectInterface * | observer | ) |
This function needs to be called in the implementation FreeComponent() function.
[in] | observer | Nullptr if all observables should be disconnected. If a object is given only this specific observables are disconnected. |
MAXON_FUNCTION void Free | ( | ) |
This function needs to be called in the implementation FreeComponent() function.
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!
[in] | observer | Pointer to a observer object. This parameter can be nullptr. |
[in] | observerFunction | Function object that is stored with in the observable. |
[in] | priority | Priority in execution. Use ADDOBSERVER_DEFAULTPRIORITY as default. Greater values will execute later. |
MAXON_METHOD Result<Data> Notify | ( | const Block< const ConstDataPtr > & | args | ) | const |
Send a notification to all subscribers.
[in] | args | Arguments packed into a Block<ConstDataPtr>. |
MAXON_METHOD Result<void> RemoveObserver | ( | const FunctionBaseRef & | observerEntry | ) |
Remove a observable entry from the subscriber list.
[in] | observerEntry | Entry to remove. |
MAXON_METHOD void SetInverseNotification | ( | Bool | inverse | ) |
Set true to Notify() in inverse order.
MAXON_METHOD Int GetObserverCount | ( | ) |
Gets the number of observers.
MAXON_METHOD ObserverObjectInterface* GetOwner | ( | ) | const |
Gets the owner of the observable.