Photon Quantum 3.0.0

Public Member Functions | Protected Member Functions | Static Protected Member Functions | List of all members
Quantum.CallbackDispatcher Class Reference

A subscribe and publish pattern for Quantum callbacks. A Quantum callback is a invocation from inside the simulation during certain situations. More...

Inheritance diagram for Quantum.CallbackDispatcher:
Quantum.DispatcherBase Quantum.ICallbackDispatcher Quantum.QuantumUnityCallbackDispatcher

Public Member Functions

 CallbackDispatcher ()
 Constructor calls GetBuiltInTypes. More...
 
bool HasAnyListeners (CallbackBase e)
 Returns true if the callback has any listeners.
 
bool Publish (CallbackBase e)
 Publish a callback. More...
 
- Public Member Functions inherited from Quantum.DispatcherBase
void Clear ()
 Removes all subscriptions. More...
 
int GetIndex< TDispatchable > ()
 Returns the index of a specific dispatchable type. Throws in case the type is not registered. More...
 
void RemoveDeadListeners ()
 Removes every subscription for which GetListenerStatus returns ListenerStatus.Dead More...
 
DispatcherSubscription Subscribe< TDispatchable > (object listener, DispatchableHandler< TDispatchable > handler, bool once=false, uint flags=0, DispatchableFilter filter=null)
 Creates a subscription. Subscriptions can be cancelled manually by calling UnsubscribeHandler<TDispatchable>(DispatchableHandler<TDispatchable>), but as long as the derived class overrides GetListenerStatus(object, uint) and calls DispatcherBase.RemoveDeadListeners() periodically, the dispatcher will be free of memory leaks. More...
 
IDisposable SubscribeManual< TDispatchable > (DispatchableHandler< TDispatchable > handler, bool once=false, DispatchableFilter filter=null)
 Creates a subscription that is active until the caller disposes the result. More...
 
IDisposable SubscribeManual< TDispatchable > (object listener, DispatchableHandler< TDispatchable > handler, bool once=false, DispatchableFilter filter=null)
 Creates a subscription that is active until the caller disposes the result or calls Unsubscribe. More...
 
bool Unsubscribe (DispatcherSubscription subscription)
 Cancel a specific subscription. More...
 
bool UnsubscribeHandler< TDispatchable > (DispatchableHandler< TDispatchable > handler)
 Cancel every subscription using a handler. More...
 
bool UnsubscribeListener (object listener)
 Cancel every subscription for a listener. More...
 
bool UnsubscribeListener< TDispatchable > (object listener)
 Cancel every specific subscription type for a listener. More...
 

Protected Member Functions

 CallbackDispatcher (Dictionary< Type, Int32 > callbackTypes)
 Constructor to add the callback type mapping manually. More...
 
- Protected Member Functions inherited from Quantum.DispatcherBase
 DispatcherBase (Dictionary< Type, Int32 > typeToIndex)
 Initializes the dispatcher with a mapping of types to ids. The ids are used to quickly find the correct event handler. More...
 
virtual ListenerStatus GetListenerStatus (object listener, uint flags)
 Returns ListenerStatus.Active if listener is not null, ListenerStatus.Dead otherwise. Override this method to provide custom listener status. More...
 
bool InvokeMeta (int metaIndex, IDispatchable e)
 Invokes handlers for a specific dispatchable. More...
 
bool InvokeMeta< TDispatchable > (TDispatchable e)
 Invokes handlers for a specific dispatchable. More...
 
DispatcherSubscription SubscribeInternal< TDispatchable > (object listener, DispatchableHandler< TDispatchable > handler, DispatchableFilter filter, uint flags)
 Creates a subscription. Subscriptions can be cancelled manually by calling UnsubscribeHandler<TDispatchable>(DispatchableHandler<TDispatchable>). More...
 
IDisposable SubscribeManualInternal< TDispatchable > (object listener, DispatchableHandler< TDispatchable > handler, DispatchableFilter filter, bool once)
 Creates a subscription that is active until the caller disposes the result. More...
 
bool UnsubscribeInternal< TDispatchable > (object listener, DispatchableHandler< TDispatchable > handler)
 Unsubscribes a listener from a handler. More...
 

Static Protected Member Functions

static Dictionary< Type, Int32 > GetBuiltInTypes ()
 Assembles a dictionary of built-in Quantum callback types. More...
 

Additional Inherited Members

- Public Types inherited from Quantum.DispatcherBase
enum  ListenerStatus
 Status of a listener. Used to determine if a listener is still alive. More...
 
- Properties inherited from Quantum.DispatcherBase
bool IsEmpty [get]
 Returns true if there are no active subscriptions. More...
 
DispatcherBase Next [get, set]
 A reference to the next dispatcher in the chain. If set, the dispatcher will forward events to the next dispatcher after. More...
 

Detailed Description

A subscribe and publish pattern for Quantum callbacks. A Quantum callback is a invocation from inside the simulation during certain situations.

Constructor & Destructor Documentation

◆ CallbackDispatcher() [1/2]

Quantum.CallbackDispatcher.CallbackDispatcher ( )
inline

Constructor calls GetBuiltInTypes.

◆ CallbackDispatcher() [2/2]

Quantum.CallbackDispatcher.CallbackDispatcher ( Dictionary< Type, Int32 >  callbackTypes)
inlineprotected

Constructor to add the callback type mapping manually.

Parameters
callbackTypes

Member Function Documentation

◆ GetBuiltInTypes()

static Dictionary<Type, Int32> Quantum.CallbackDispatcher.GetBuiltInTypes ( )
inlinestaticprotected

Assembles a dictionary of built-in Quantum callback types.

Returns
Callback mapping

◆ Publish()

bool Quantum.CallbackDispatcher.Publish ( CallbackBase  e)
inline

Publish a callback.

Parameters
e
Returns
True if the callback has been handled by any subscriber

Implements Quantum.ICallbackDispatcher.