Tizen Native API  4.0
Dali::BaseSignal Class Reference

Implementation class for Dali::Signal. More...

Inheritance diagram for Dali::BaseSignal:
Dali::SlotObserver

Classes

struct  EmitGuard
 Used to guard against nested Emit() calls. More...

Public Member Functions

 BaseSignal ()
 Constructor.
virtual ~BaseSignal ()
 Virtual destructor.
bool Empty () const
 Queries whether there are any connected slots.
std::size_t GetConnectionCount () const
 Queries the number of slots.
void Emit ()
 Emits a signal with no parameters.
template<typename Ret >
Ret EmitReturn ()
 Emits a signal with no parameters.
template<typename Arg0 >
void Emit (Arg0 arg0)
 Emits a signal with 1 parameter.
template<typename Ret , typename Arg0 >
Ret EmitReturn (Arg0 arg0)
 Emits a signal with 1 parameter.
template<typename Arg0 , typename Arg1 >
void Emit (Arg0 arg0, Arg1 arg1)
 Emits a signal with 2 parameters.
template<typename Ret , typename Arg0 , typename Arg1 >
Ret EmitReturn (Arg0 arg0, Arg1 arg1)
 Emits a signal with 2 parameters.
template<typename Arg0 , typename Arg1 , typename Arg2 >
void Emit (Arg0 arg0, Arg1 arg1, Arg2 arg2)
 Emits a signal with 3 parameters.
template<typename Ret , typename Arg0 , typename Arg1 , typename Arg2 >
Ret EmitReturn (Arg0 arg0, Arg1 arg1, Arg2 arg2)
 Emits a signal with 3 parameters.
void OnConnect (CallbackBase *callback)
 Called by Signal implementations, when the user calls Signal.Connect( ... ).
void OnDisconnect (CallbackBase *callback)
 Called by Signal implementations, when the user calls Signal.Disconnect( ... ).
void OnConnect (ConnectionTrackerInterface *tracker, CallbackBase *callback)
 Called by Signal implementations, when the user calls Signal.Connect( ... ).
void OnDisconnect (ConnectionTrackerInterface *tracker, CallbackBase *callback)
 Called by Signal implementations, when the user calls Signal.Disconnect( ... ).

Detailed Description

Implementation class for Dali::Signal.

A slot can be connected to many signals A signal can be connected to many slots

To provide automatic disconnection when either a signal or the object owning the slot dies, observers are used.

A signal is an object with state. It holds a list of SignalConnections.

E.g. Signal OnTouch. mSignalConnections contains

Callback 0 Signal Observer 0
Callback 1 Signal Observer 1
Callback 2 Signal Observer 2

OnTouch.Emit() will run callbacks 0, 1 and 2.

When the signal is destroyed. SignalDisconnected() is called on each Signal Observer.

Slots are just static or member functions, so have no state. E.g. they can't keep track of how many signals they are connected to. If the object owning a slot dies, it must automatically disconnected from all signals. If it doesn't disconnect and the signal is emitted, there will be a crash.

To keep track of connections between slots and signals, a Connection tracker is used. It holds a list of SlotConnections.

Callback 0 Slot Observer 0
Callback 1 Slot Observer 1
Callback 2 Slot Observer 2

When the connection tracker is destroyed, SlotDisconnected() is called on every slot observer ( signal ). Signals implement the Slot Observer interface, to be told when a slot has disconnected. Connection tracker implements the Signal Observer interface, to be told when a signal has disconnected (died).

Since:
3.0, DALi version 1.0.0

Constructor & Destructor Documentation

Constructor.

Since:
3.0, DALi version 1.0.0
virtual Dali::BaseSignal::~BaseSignal ( ) [virtual]

Virtual destructor.

Since:
3.0, DALi version 1.0.0

Member Function Documentation

Emits a signal with no parameters.

Since:
3.0, DALi version 1.0.0
Precondition:
Cannot be called from inside the same Signal's Emit methods.
template<typename Arg0 >
void Dali::BaseSignal::Emit ( Arg0  arg0)

Emits a signal with 1 parameter.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]arg0The first parameter
Precondition:
Cannot be called from inside the same Signal's Emit methods.
template<typename Arg0 , typename Arg1 >
void Dali::BaseSignal::Emit ( Arg0  arg0,
Arg1  arg1 
)

Emits a signal with 2 parameters.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]arg0The first parameter
[in]arg1The second parameter
Precondition:
Cannot be called from inside the same Signal's Emit methods.
template<typename Arg0 , typename Arg1 , typename Arg2 >
void Dali::BaseSignal::Emit ( Arg0  arg0,
Arg1  arg1,
Arg2  arg2 
)

Emits a signal with 3 parameters.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]arg0The first parameter
[in]arg1The second parameter
[in]arg2The third parameter
Precondition:
Cannot be called from inside the same Signal's Emit methods.
template<typename Ret >
Ret Dali::BaseSignal::EmitReturn ( )

Emits a signal with no parameters.

Since:
3.0, DALi version 1.0.0
Returns:
The value returned by the last callback
Precondition:
Cannot be called from inside the same Signal's Emit methods.
template<typename Ret , typename Arg0 >
Ret Dali::BaseSignal::EmitReturn ( Arg0  arg0)

Emits a signal with 1 parameter.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]arg0The first parameter
Returns:
The value returned by the last callback
Precondition:
Cannot be called from inside the same Signal's Emit methods.
template<typename Ret , typename Arg0 , typename Arg1 >
Ret Dali::BaseSignal::EmitReturn ( Arg0  arg0,
Arg1  arg1 
)

Emits a signal with 2 parameters.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]arg0The first parameter
[in]arg1The second parameter
Returns:
The value returned by the last callback
Precondition:
Cannot be called from inside the same Signal's Emit methods.
template<typename Ret , typename Arg0 , typename Arg1 , typename Arg2 >
Ret Dali::BaseSignal::EmitReturn ( Arg0  arg0,
Arg1  arg1,
Arg2  arg2 
)

Emits a signal with 3 parameters.

Since:
3.0, DALi version 1.0.0
Parameters:
[in]arg0The first parameter
[in]arg1The second parameter
[in]arg2The third parameter
Returns:
The value returned by the last callback
Precondition:
Cannot be called from inside the same Signal's Emit methods.
bool Dali::BaseSignal::Empty ( ) const

Queries whether there are any connected slots.

Since:
3.0, DALi version 1.0.0
Returns:
True if there are any slots connected to the signal.
std::size_t Dali::BaseSignal::GetConnectionCount ( ) const

Queries the number of slots.

Since:
3.0, DALi version 1.0.0
Returns:
The number of slots connected to this signal

Called by Signal implementations, when the user calls Signal.Connect( ... ).

Since:
3.0, DALi version 1.0.0
Parameters:
[in]callbackA newly allocated callback object (takes ownership)

Called by Signal implementations, when the user calls Signal.Connect( ... ).

Since:
3.0, DALi version 1.0.0
Parameters:
[in]trackerThe connection tracker
[in]callbackA newly allocated callback object (takes ownership)

Called by Signal implementations, when the user calls Signal.Disconnect( ... ).

Since:
3.0, DALi version 1.0.0
Parameters:
[in]callbackA newly allocated callback object (takes ownership)

Called by Signal implementations, when the user calls Signal.Disconnect( ... ).

Since:
3.0, DALi version 1.0.0
Parameters:
[in]trackerThe connection tracker
[in]callbackA newly allocated callback object (takes ownership)