Wt
3.3.8
|
A signal that propagates events to listeners. More...
#include <Wt/WSignal>
Public Member Functions | |
Signal (WObject *sender=0) | |
Creates a signal. More... | |
~Signal () | |
Destructor. | |
virtual Wt::Signals::connection | connect (WObject *target, WObject::Method method) |
Connects to a slot. More... | |
template<class F > | |
Wt::Signals::connection | connect (const F &function) |
Connects to a function. More... | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)()) |
Connects a slot that takes no arguments. More... | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)(A1)) |
Connects a slot that takes one argument. More... | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)(A1, A2)) |
Connects a slot that takes two arguments. More... | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)(A1, A2, A3)) |
Connects a slot that takes three arguments. More... | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)(A1, A2, A3, A4)) |
Connects a slot that takes four arguments. More... | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)(A1, A2, A3, A4, A5)) |
Connects a slot that takes five arguments. More... | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)(A1, A2, A3, A4, A5, A6)) |
Connects a slot that takes six arguments. More... | |
void | emit (A1 a1=NoClass::none, A2 a2=NoClass::none, A3 a3=NoClass::none, A4 a4=NoClass::none, A5 a5=NoClass::none, A6 a6=NoClass::none) const |
Emits the signal. More... | |
void | operator() (A1 a1=NoClass::none, A2 a2=NoClass::none, A3 a3=NoClass::none, A4 a4=NoClass::none, A5 a5=NoClass::none, A6 a6=NoClass::none) const |
Emits the signal. More... | |
virtual bool | isConnected () const |
Returns whether this signal is connected. More... | |
Public Member Functions inherited from Wt::SignalBase | |
WObject * | sender () const |
Returns the sender. More... | |
template<class T , class V > | |
Wt::Signals::connection | connect (T *target, void(V::*method)()) |
Connects to a slot. More... | |
A signal that propagates events to listeners.
Use Signal/slots to let one object (A) listen to events caused by another object (B). In this scenario, object B provides in its public interface access to a signal, to which object A connects one of its member function (which act as slot). Object A can then signal an event (which triggers the connected callback functions), by emitting the signal. Signal/slot is a generalization of the popular observer pattern used in GUIs.
A signal can provide details of the event, using up to 6 parameters. A slot must have a compatible signature to connect to a signal, based on its parameters. A compatible signature provides the same parameters in the member function, or less (leaving out parameters at the end).
The signal automatically disconnects from the slot when the target is deleted. In addition, the signal may be deleted at any time, in particular also while it is being emitted.
The Signal objects integrate with WObject objects. A Signal requires that the target of a connection, i.e. the object that listens for an event, is a WObject. In addition, every signal may specify one WObject to be the owner of the signal, and a target may find out the sender of a signal emission, using WObject::sender().
This widget could then be used from another class:
The WSignalMapper is a utility class that helps in situations where you want to connect multiple signals to a single slot, and still be identify the sender using some property.
Wt::Signal< A1, A2, A3, A4, A5, A6 >::Signal | ( | WObject * | sender = 0 | ) |
Creates a signal.
The sender
is the object that will be identified as WObject::sender() when executing connected slots may be passed as an argument.
The sender
should not be 0
when you want to map the signal using the WSignalMapper.
|
virtual |
Connects to a slot.
Every signal can be connected to a slot which does not take any arguments (and may thus ignore signal arguments).
Implements Wt::SignalBase.
Wt::Signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect | ( | const F & | function | ) |
Connects to a function.
This variant of the overloaded connect() method supports a template function object (which supports operator ()).
When the receiver function is an object method, the signal will automatically be disconnected when the object is deleted, as long as the object inherits from WObject (or Wt::Signals::trackable).
The function may leave up to N parameters unbound (e.g. using boost::bind placeholders _1 to _N) that may be bound to values passed by the signal.
Wt::Signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, |
void(V::*)() | method | ||
) |
Connects a slot that takes no arguments.
This is always possible (even when the signal specifies a number of arguments).
The slot is as a method
of an object target
of class T
, which equals class V
, or is a base class of class V
. Thus, the following statement must return a non-null pointer:
In practice, to facilitate automatic disconnects on deletion of the target
, class T
must be also be a descendant of WObject, but this is not enforced by the interface.
Wt::Signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, |
void(V::*)(A1) | method | ||
) |
Connects a slot that takes one argument.
This is only possible for signals that take at least one argument.
Wt::Signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, |
void(V::*)(A1, A2) | method | ||
) |
Connects a slot that takes two arguments.
This is only possible for signals that take at least two arguments.
Wt::Signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, |
void(V::*)(A1, A2, A3) | method | ||
) |
Connects a slot that takes three arguments.
This is only possible for signals that take at least three arguments.
Wt::Signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, |
void(V::*)(A1, A2, A3, A4) | method | ||
) |
Connects a slot that takes four arguments.
This is only possible for signals that take at least four arguments.
Wt::Signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, |
void(V::*)(A1, A2, A3, A4, A5) | method | ||
) |
Connects a slot that takes five arguments.
This is only possible for signals that take at least five arguments.
Wt::Signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect | ( | T * | target, |
void(V::*)(A1, A2, A3, A4, A5, A6) | method | ||
) |
Connects a slot that takes six arguments.
This is only possible for signals that take at least six arguments.
void Wt::Signal< A1, A2, A3, A4, A5, A6 >::emit | ( | A1 | a1 = NoClass::none , |
A2 | a2 = NoClass::none , |
||
A3 | a3 = NoClass::none , |
||
A4 | a4 = NoClass::none , |
||
A5 | a5 = NoClass::none , |
||
A6 | a6 = NoClass::none |
||
) | const |
Emits the signal.
The arguments must exactly match the arguments of the target function.
This will cause all connected slots to be triggered, with the given arguments.
|
virtual |
Returns whether this signal is connected.
Returns true when the signal was connected to to at least one slot.
Implements Wt::SignalBase.
void Wt::Signal< A1, A2, A3, A4, A5, A6 >::operator() | ( | A1 | a1 = NoClass::none , |
A2 | a2 = NoClass::none , |
||
A3 | a3 = NoClass::none , |
||
A4 | a4 = NoClass::none , |
||
A5 | a5 = NoClass::none , |
||
A6 | a6 = NoClass::none |
||
) | const |