Tizen Native API
5.0
|
Implementation class for Dali::Signal. More...
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:
- 2.4, DALi version 1.0.0
Constructor & Destructor Documentation
Constructor.
- Since:
- 2.4, DALi version 1.0.0
virtual Dali::BaseSignal::~BaseSignal | ( | ) | [virtual] |
Virtual destructor.
- Since:
- 2.4, DALi version 1.0.0
Member Function Documentation
void Dali::BaseSignal::Emit | ( | ) |
Emits a signal with no parameters.
- Since:
- 2.4, DALi version 1.0.0
- Precondition:
- Cannot be called from inside the same Signal's Emit methods.
void Dali::BaseSignal::Emit | ( | Arg0 | arg0 | ) |
Emits a signal with 1 parameter.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] arg0 The first parameter
- Precondition:
- Cannot be called from inside the same Signal's Emit methods.
void Dali::BaseSignal::Emit | ( | Arg0 | arg0, |
Arg1 | arg1 | ||
) |
Emits a signal with 2 parameters.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] arg0 The first parameter [in] arg1 The second parameter
- Precondition:
- Cannot be called from inside the same Signal's Emit methods.
void Dali::BaseSignal::Emit | ( | Arg0 | arg0, |
Arg1 | arg1, | ||
Arg2 | arg2 | ||
) |
Emits a signal with 3 parameters.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] arg0 The first parameter [in] arg1 The second parameter [in] arg2 The third parameter
- Precondition:
- Cannot be called from inside the same Signal's Emit methods.
Ret Dali::BaseSignal::EmitReturn | ( | ) |
Emits a signal with no parameters.
- Since:
- 2.4, 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.
Ret Dali::BaseSignal::EmitReturn | ( | Arg0 | arg0 | ) |
Emits a signal with 1 parameter.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] arg0 The first parameter
- Returns:
- The value returned by the last callback
- Precondition:
- Cannot be called from inside the same Signal's Emit methods.
Ret Dali::BaseSignal::EmitReturn | ( | Arg0 | arg0, |
Arg1 | arg1 | ||
) |
Emits a signal with 2 parameters.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] arg0 The first parameter [in] arg1 The second parameter
- Returns:
- The value returned by the last callback
- Precondition:
- Cannot be called from inside the same Signal's Emit methods.
Ret Dali::BaseSignal::EmitReturn | ( | Arg0 | arg0, |
Arg1 | arg1, | ||
Arg2 | arg2 | ||
) |
Emits a signal with 3 parameters.
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] arg0 The first parameter [in] arg1 The second parameter [in] arg2 The 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:
- 2.4, 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:
- 2.4, DALi version 1.0.0
- Returns:
- The number of slots connected to this signal
void Dali::BaseSignal::OnConnect | ( | CallbackBase * | callback | ) |
Called by Signal implementations, when the user calls Signal.Connect( ... ).
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] callback A newly allocated callback object (takes ownership)
void Dali::BaseSignal::OnConnect | ( | ConnectionTrackerInterface * | tracker, |
CallbackBase * | callback | ||
) |
Called by Signal implementations, when the user calls Signal.Connect( ... ).
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] tracker The connection tracker [in] callback A newly allocated callback object (takes ownership)
void Dali::BaseSignal::OnDisconnect | ( | CallbackBase * | callback | ) |
Called by Signal implementations, when the user calls Signal.Disconnect( ... ).
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] callback A newly allocated callback object (takes ownership)
void Dali::BaseSignal::OnDisconnect | ( | ConnectionTrackerInterface * | tracker, |
CallbackBase * | callback | ||
) |
Called by Signal implementations, when the user calls Signal.Disconnect( ... ).
- Since:
- 2.4, DALi version 1.0.0
- Parameters:
-
[in] tracker The connection tracker [in] callback A newly allocated callback object (takes ownership)