Wt::JSignal< A1, A2, A3, A4, A5, A6 > Class Template Reference

A signal to relay JavaScript to C++ calls. More...

#include <WJavaScript>

Inherited by Wt::JSignal< void >.

List of all members.

Public Member Functions

 JSignal (WObject *object, const std::string name)
 Construct a signal for the given object, and name.
std::string name () const
 Get the name of this signal.
virtual bool isConnected () const
 Is this signal connected to at least one slot ?
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=None::none, A2 a2=None::none, A3 a3=None::none, A4 a4=None::none, A5 a5=None::none, A6 a6=None::none)
 Emit the signal.
void operator() (A1 a1=None::none, A2 a2=None::none, A3 a3=None::none, A4 a4=None::none, A5 a5=None::none, A6 a6=None::none)
 Emit the signal.


Detailed Description

template<typename A1 = None, typename A2 = None, typename A3 = None, typename A4 = None, typename A5 = None, typename A6 = None>
class Wt::JSignal< A1, A2, A3, A4, A5, A6 >

A signal to relay JavaScript to C++ calls.

A JSignal, like an EventSignal, provides communicates events from JavaScript to C++ code. However, it not tied to a built-in event. Instead, it can be emitted from within custom JavaScript code using the JavaScript WtEmitSignal() function.

The signal is identified by a unique name, within the scope of a WObject, which are specified in its constructor.

The signal supports up to 6 arguments. Values for these arguments may be specified in the JavaScript WtEmitSignal().

For example, consider the following signal, and constructor:

 class MyWidget : public WCompositeWidget
 {
 public:
   // ...
   JSignal<std::string, int> doSome;
   // ...
 };

 MyWidget::MyWidget()
   : doSome(this, "dosome")
 { 
   //...
 }
 

The following JavaScript code will then emit the signal for a DOM element, which corresponds to a MyWidget widget:

 WtSignalEmit(element, 'dosome', 'foo', 42);
 

The conversion between the JavaScript argument (ax) and the C++ type Ax uses boost::lexical_cast<Ax>(ax).

See also:
WWidget::jsRef(), WObject::id()


Constructor & Destructor Documentation

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
Wt::JSignal< A1, A2, A3, A4, A5, A6 >::JSignal ( WObject object,
const std::string  name 
)

Construct a signal for the given object, and name.

The name must be unique for all user signals specified for a single class.


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::JSignal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2, A3, A4, A5, A6)  method 
)

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>
template<class T, class V>
boost::signals::connection Wt::JSignal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2, A3, A4, A5)  method 
)

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::JSignal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2, A3, A4)  method 
)

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::JSignal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2, A3)  method 
)

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::JSignal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1, A2)  method 
)

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::JSignal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)(A1)  method 
)

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::JSignal< A1, A2, A3, A4, A5, A6 >::connect ( T *  target,
void(V::*)()  method 
)

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>
void Wt::JSignal< A1, A2, A3, A4, A5, A6 >::emit ( A1  a1 = None::none,
A2  a2 = None::none,
A3  a3 = None::none,
A4  a4 = None::none,
A5  a5 = None::none,
A6  a6 = None::none 
)

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::JSignal< A1, A2, A3, A4, A5, A6 >::operator() ( A1  a1 = None::none,
A2  a2 = None::none,
A3  a3 = None::none,
A4  a4 = None::none,
A5  a5 = None::none,
A6  a6 = None::none 
)

Emit the signal.

This is equivalent to emit().

See also:
emit


The documentation for this class was generated from the following file:
Generated on Sun Jul 1 19:37:18 2007 for Wt by doxygen 1.4.7