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

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

#include <WJavaScript>

Inheritance diagram for Wt::JSignal< A1, A2, A3, A4, A5, A6 >:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 JSignal (WObject *object, const std::string &name, bool collectSlotJavaScript=false)
 Construct a signal for the given object, and name.
const std::string & name () const
 Get the name of this signal.
const std::string createCall (std::string arg1=std::string(), std::string arg2=std::string(), std::string arg3=std::string(), std::string arg4=std::string(), std::string arg5=std::string(), std::string arg6=std::string()) const
 The JavaScript call which will trigger 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 connect (JSlot &slot)
 Connect a slot that is specified as JavaScript only.
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.


Detailed Description

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

Construct a signal for the given object, and name.

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

If collectSlotJavaScript is true, then javascript specified for connected slots (using JSlot) or learned using stateless slot learning, is collected, and therefore the signal must be called from client-side JavaScript using the JavaScript code generated by createCall().

Reimplemented in Wt::JSignal< void >.


Member Function Documentation

template<typename A1, typename A2, typename A3, typename A4, typename A5, typename A6>
const std::string Wt::JSignal< A1, A2, A3, A4, A5, A6 >::createCall ( std::string  arg1 = std::string(),
std::string  arg2 = std::string(),
std::string  arg3 = std::string(),
std::string  arg4 = std::string(),
std::string  arg5 = std::string(),
std::string  arg6 = std::string() 
) const [inline]

The JavaScript call which will trigger this signal.

For a JSignal constructed with inlineJavaScript = false, this is simply WtSignalEmit([element], [name], arg1, ...) with the element corresponding to the owner object, and name corresponding to the signal name.

Otherwise, the inline JavaScript from slots is included as well.

Reimplemented in Wt::JSignal< void >.

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 
) [inline]

Connect a slot that takes no arguments.

If a stateless implementation is specified for the slot, then the visual behaviour will be learned in terms of JavaScript, and will be cached on the client side for instant feed-back, in addition running the slot on the server.

The slot is specified as a method of class V, which is equal to class V, or a base class of class V. In addition, to check for stateless implementations, class T must be also be a descendant of WObject. Thus, the following statement must return a non-null pointer:

 WObject *o = dynamic_cast<WObject *>(dynamic_cast<V *>(target));

Reimplemented in Wt::JSignal< void >.

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 
) [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::JSignal< 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::JSignal< 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::JSignal< 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::JSignal< 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::JSignal< 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::JSignal< A1, A2, A3, A4, A5, A6 >::connect ( JSlot slot  )  [inline]

Connect a slot that is specified as JavaScript only.

This will provide a client-side connection between the event and some JavaScript code as implemented by the slot. Unlike other connects, this does not cause the event to propagated to the application, and thus the state may not be tracked.

Reimplemented in Wt::JSignal< void >.

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 = 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::JSignal< 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


The documentation for this class was generated from the following file:
Generated on Mon Apr 14 15:15:01 2008 for Wt by doxygen 1.5.3