ObservableBaseInterface Class Reference

#include <observable.h>

Inheritance diagram for ObservableBaseInterface:

详细描述

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

公共成员函数

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 < 数据 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

私有成员函数

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

成员函数文档编制

◆  MAXON_INTERFACE()

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

◆  Init()

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.
返回
True if the function operates successful.

◆  GetObservableId()

MAXON_METHOD Id GetObservableId ( ) const

This function returns the Id given in the Init function.

◆  _intDisconnectAll()

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.

◆  Disconnect()

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.

◆  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!

参数
[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.
返回
OK on success.

◆  Notify()

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

Send a notification to all subscribers.

参数
[in] args Arguments packed into a Block<ConstDataPtr>.
返回
The combined result of the observable. See CombinerInterface .

◆  RemoveObserver()

MAXON_METHOD Result <void> RemoveObserver ( const FunctionBaseRef &  observerEntry )

Remove a observable entry from the subscriber list.

参数
[in] observerEntry Entry to remove.
返回
OK on success.

◆  SetInverseNotification()

MAXON_METHOD void SetInverseNotification ( Bool   inverse )

Set true to Notify() in inverse order.

◆  GetObserverCount()

MAXON_METHOD Int GetObserverCount ( )

Gets the number of observers.

返回
The number of observers.

◆  GetOwner()

MAXON_METHOD ObserverObjectInterface * GetOwner ( ) const

Gets the owner of the observable.

返回
The owner of the observable.