Wt::Signal< A1, A2, A3, A4, A5, A6 > Class Template Reference
[Signal/slot system]

A signal that propagates events to listeners. More...

#include <Wt/WSignal>

Inherits Wt::SignalBase.

Inherited by Wt::Signal< void >.

List of all members.

Public Member Functions

 Signal (WObject *sender=0)
 Create a WSignal.
 ~Signal ()
 Delete a WSignal.
template<class T, class V>
boost::signals::connection connect (T *target, void(V::*method)())
 Connect a slot that takes no arguments.
template<class T, class V>
boost::signals::connection connect (T *target, void(V::*method)(A1))
 Connect a slot that takes one argument.
template<class T, class V>
boost::signals::connection connect (T *target, void(V::*method)(A1, A2))
 Connect a slot that takes two arguments.
template<class T, class V>
boost::signals::connection connect (T *target, void(V::*method)(A1, A2, A3))
 Connect a slot that takes three arguments.
template<class T, class V>
boost::signals::connection connect (T *target, void(V::*method)(A1, A2, A3, A4))
 Connect a slot that takes four arguments.
template<class T, class V>
boost::signals::connection connect (T *target, void(V::*method)(A1, A2, A3, A4, A5))
 Connect a slot that takes five arguments.
template<class T, class V>
boost::signals::connection connect (T *target, void(V::*method)(A1, A2, A3, A4, A5, A6))
 Connect a slot that takes six arguments.
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)
 Emit the signal.
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)
 Emit the signal.
bool isConnected () const
 Is this signal connected to at least one slot ?


Detailed Description

template<typename A1 = NoClass, typename A2 = NoClass, typename A3 = NoClass, typename A4 = NoClass, typename A5 = NoClass, typename A6 = NoClass>
class Wt::Signal< A1, A2, A3, A4, A5, A6 >

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 a signal, to which object A connects one of its member function (which act as slot). Object A initiates the event (and 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 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().


Constructor & Destructor Documentation

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
Wt::Signal< A1, A2, A3, A4, A5, A6 >::Signal ( WObject sender = 0  )  [inline]

Create a WSignal.

The object that will be identified as sender() when executing connected slots may be passed as an argument.


Member Function Documentation

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
template<class T, class V>
boost::signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)()  method 
) [inline]

Connect a slot that takes no arguments.

This is always possible (even when the signal specifies a number of arguments).

The slot is specified as a method of class V, which is equal to class V, or a base class of class V. Thus, the following statement must return a non-null pointer:

 V *v = dynamic_cast<V *>(target);

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.

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
template<class T, class V>
boost::signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1)  method 
) [inline]

Connect a slot that takes one argument.

This is only possible for signals that take at least one argument.

See also:
connect(T *target, void (V::*method)())

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
template<class T, class V>
boost::signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2)  method 
) [inline]

Connect a slot that takes two arguments.

This is only possible for signals that take at least two arguments.

See also:
connect(T *target, void (V::*method)())

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
template<class T, class V>
boost::signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2, A3)  method 
) [inline]

Connect a slot that takes three arguments.

This is only possible for signals that take at least three arguments.

See also:
connect(T *target, void (V::*method)())

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
template<class T, class V>
boost::signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2, A3, A4)  method 
) [inline]

Connect a slot that takes four arguments.

This is only possible for signals that take at least four arguments.

See also:
connect(T *target, void (V::*method)())

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
template<class T, class V>
boost::signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2, A3, A4, A5)  method 
) [inline]

Connect a slot that takes five arguments.

This is only possible for signals that take at least five arguments.

See also:
connect(T *target, void (V::*method)())

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
template<class T, class V>
boost::signals::connection Wt::Signal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2, A3, A4, A5, A6)  method 
) [inline]

Connect a slot that takes six arguments.

This is only possible for signals that take at least six arguments.

See also:
connect(T *target, void (V::*method)())

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
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 
) [inline]

Emit 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.

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
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 
) [inline]

Emit the signal.

This is equivalent to emit().

See also:
emit


Generated on Mon Jan 26 14:14:10 2009 for Wt by doxygen 1.5.6