Public Member Functions | Protected Attributes | Related Functions

TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type > Class Template Reference

Basic signals and slots support. More...

#include <Signals.hpp>

Inherits TRTK::Signals::SignalBase.

List of all members.

Public Member Functions

template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void connect (slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static non-constant member function with four parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void connect (slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static non-constant member function with three parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void connect (slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static non-constant member function with two parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type >
void connect (slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static non-constant member function with one parameter.
template<typename slot_class_type , typename slot_return_type >
void connect (slot_class_type *object, slot_return_type(slot_class_type::*function)(), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static non-constant member function with zero parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void connect (const slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type) const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static constant member function with four parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void connect (const slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type) const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static constant member function with three parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void connect (const slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type) const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static constant member function with two parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type >
void connect (const slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type) const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static constant member function with one parameter.
template<typename slot_class_type , typename slot_return_type >
void connect (const slot_class_type *object, slot_return_type(slot_class_type::*function)() const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects to a non-static constant member function with zero parameters.
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void connect (slot_return_type(*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects a global or a static member function with four parameters.
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void connect (slot_return_type(*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects a global or a static member function with three parameters.
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void connect (slot_return_type(*function)(slot_arg1_type, slot_arg2_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects a global or a static member function with two parameters.
template<typename slot_return_type , typename slot_arg1_type >
void connect (slot_return_type(*function)(slot_arg1_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects a global or a static member function with one parameter.
template<typename slot_return_type >
void connect (slot_return_type(*function)(), ConnectionType connection_type=SINGLE_CONNECTION) const
 Connects a global or a static member function with zero parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void disconnect (slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static non-constant member function with four parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void disconnect (slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static non-constant member function with three parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void disconnect (slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static non-constant member function with two parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type >
void disconnect (slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static non-constant member function with one parameter.
template<typename slot_class_type , typename slot_return_type >
void disconnect (slot_class_type *object, slot_return_type(slot_class_type::*function)(), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static non-constant member function with zero parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void disconnect (const slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type) const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static constant member function with four parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void disconnect (const slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type) const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static constant member function with three parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void disconnect (const slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type, slot_arg2_type) const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static constant member function with two parameters.
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type >
void disconnect (const slot_class_type *object, slot_return_type(slot_class_type::*function)(slot_arg1_type) const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static constant member function with one parameter.
template<typename slot_class_type , typename slot_return_type >
void disconnect (const slot_class_type *object, slot_return_type(slot_class_type::*function)() const, ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a non-static constant member function with zero parameters.
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void disconnect (slot_return_type(*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a global or a static member function with four parameters.
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void disconnect (slot_return_type(*function)(slot_arg1_type, slot_arg2_type, slot_arg3_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a global or a static member function with three parameters.
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void disconnect (slot_return_type(*function)(slot_arg1_type, slot_arg2_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a global or a static member function with two parameters.
template<typename slot_return_type , typename slot_arg1_type >
void disconnect (slot_return_type(*function)(slot_arg1_type), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a global or a static member function with one parameter.
template<typename slot_return_type >
void disconnect (slot_return_type(*function)(), ConnectionType connection_type=SINGLE_CONNECTION) const
 Disconnects a global or a static member function with zero parameters.
void send (arg1_type arg1, arg2_type arg2, arg3_type arg3, arg4_type arg4) const
 Emits a signal.
void connect (SlotAdapterBase *slot, const ConnectionType connection_type=SINGLE_CONNECTION) const
void disconnect (SlotAdapterBase *slot, const ConnectionType connection_type=SINGLE_CONNECTION) const
void disconnectReceiver (const SlotAdapterBase *slot) const
bool isConnected (const SlotAdapterBase *slot) const

Protected Attributes

std::list< SlotAdapterBase * > m_slots
std::set< const Receiver * > m_receivers

Related Functions

(Note that these are not member functions.)


enum  ConnectionType { MULTIPLE_CONNECTIONS, SINGLE_CONNECTION }
 

Slot connection type.

More...

Detailed Description

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
class TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >

Basic signals and slots support.

Signals and slots are callbacks with multiple targets. They work according to the publish/subscribe pattern which facilitates decoupling and modularization. A signal with certain properties is defined and subscribers with the same method signature are able to connect to this signal (or in other words: if a signal is instanciated, only a defined set of functions is able to be connected to the signal). If the signal is called (or emitted or send), the subscribers are informed (or called) as well. A publisher does not care about its subscribers---it just publishes and the subscribers are informed. All this is done fully transparently. (See below for some examples.)

This signals and slots implementation is compatible with Qt, which means that it does not interfere with Qt's own signals and slots concept as well as its defined keywords emit, signals and slots.

The interface is designed to be flexible and easy to use. Connections are even managed fully automatically in the case that objects are (virtually) derived from the Receiver class.

 class Object : virtual public Receiver
 {
     // ...
 };

A signal is defined by instanciating the Signal template class. For instance:

 Signal<int> signal;

All functions that take an integer as its first argument can be connected to the above defined signal. This implies global functions as well as all kinds of member functions where the type of the return value can be arbitrary.

Note:
If a function's signature differs from the signal's signature, a connection is still possible if the argument types can be converted to each other. For instance, the following function can still be connected to the above signal:
 void function(double); 
Note:
Since version 1.2.0 it is also possible to connect to functions with less parameters than those given in the signature of the signal. For instance, it is also possible to connect to the above signal a slot like
 void function(); 

Up to four parameters can be specified:

 Signal<arg1_type, arg2_type, arg3_type, arg4_type> signal;

Now, a connection can be established as follows:

 signal.connect(&function);              // global function slot
 signal.connect(&object, &function);     // member function slot

If a signal is emitted (or send) the connected functions are called in the order they were connected to a signal. Connections can either be unique or multiple-connected. The former is the default behaviour. To change this, you can specify the connection type, for instance:

 signal.connect(&function, TRTK::Signals::MULTIPLE_CONNECTIONS);

A slot is disconnected as follows:

 signal.disconnect(&function);           // global function slot
 signal.disconnect(&object, &function);  // member function slot

Always, the last found/connected slot is disconnected (or all slots if MULTIPLE_CONNECTIONS is passed as an additional argument). It follows, that the former connection order is preserved. If object in the former example is derived from the Receiver class, all connections are disconnected automatically during the destruction of this object. This avoids hanging references within the signal.

Now, we will present an example to show, how signals and slots can be used.

Example:

 #include <iostream>
 #include <TRTK/Clock.hpp>
 #include <TRTK/Signals.hpp>

 using namespace std;
 using namespace TRTK;


 class DisplayClass // This could be a status bar, for instance.
 {
 public:
     void print(unsigned int value)
     {
         cout << value << endl;
     }
 };


 class CountDown
 {
 public:
     CountDown(unsigned int counter) : m_counter(counter) {}

     void start()
     {
         for (int i = m_counter; i >= 0; --i)
         {
             Clock().wait_seconds(1);
             state.send(i);
         }

         finished.send();
     }

     Signal<unsigned int> state;
     Signal<void> finished;

 private:
     unsigned int m_counter;
 };


 void print()
 {
     cout << "print() was called." << endl;
 }


 int main()
 {
     CountDown countDown(10);

     DisplayClass displayClass;

     countDown.state.connect(&displayClass, &DisplayClass::print);

     countDown.finished.connect(&print);
     countDown.finished.connect(&print, MULTIPLE_CONNECTIONS); // print is called twice

     countDown.start();

     // The next line could be ommited, if DisplayClass was derived from Receiver.
     countDown.state.disconnect(&displayClass, &DisplayClass::print);
     countDown.finished.connect(&print, MULTIPLE_CONNECTIONS);

     return 0;
 }

Output:

 10
 9
 8
 7
 6
 5
 4
 3
 2
 1
 0
 print() was called.
 print() was called.

As we can see, now, the CountDown class is fully decoupled from its graphical representation.

Note:
  • For convenience reasons, the Signals and the Receiver class as well as the connection types are also directly available in the TRTK namespace.
  • Signals can always be modified, even if they are declared const.
Author:
Christoph Haenisch
Version:
1.2.2
Date:
last changed on 2014-07-03

Definition at line 1656 of file Signals.hpp.


Member Function Documentation

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static non-constant member function with four parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1677 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type, slot_arg3_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static non-constant member function with three parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1698 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static non-constant member function with one parameter.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1740 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type) const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static constant member function with two parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1824 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type) const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static constant member function with one parameter.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1845 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)()  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static non-constant member function with zero parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1761 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)() const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static constant member function with zero parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1866 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_return_type(*)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects a global or a static member function with four parameters.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&function);

Definition at line 1886 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static non-constant member function with two parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1719 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type) const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static constant member function with four parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1782 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_return_type(*)(slot_arg1_type, slot_arg2_type, slot_arg3_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects a global or a static member function with three parameters.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&function);

Definition at line 1906 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_return_type(*)(slot_arg1_type, slot_arg2_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects a global or a static member function with two parameters.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&function);

Definition at line 1926 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type, slot_arg3_type) const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects to a non-static constant member function with three parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&object, &class::function);

Definition at line 1803 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type , typename slot_arg1_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_return_type(*)(slot_arg1_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects a global or a static member function with one parameter.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&function);

Definition at line 1946 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::connect ( slot_return_type(*)()  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Connects a global or a static member function with zero parameters.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

Example:

 signal.connect(&function);

Definition at line 1966 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_return_type(*)(slot_arg1_type, slot_arg2_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a global or a static member function with two parameters.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&function);

Definition at line 2300 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static non-constant member function with one parameter.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 2069 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static non-constant member function with four parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 1991 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type, slot_arg3_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static non-constant member function with three parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 2017 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type) const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static constant member function with two parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 2173 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type) const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static constant member function with one parameter.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 2199 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_return_type(*)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a global or a static member function with four parameters.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&function);

Definition at line 2250 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_return_type(*)(slot_arg1_type, slot_arg2_type, slot_arg3_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a global or a static member function with three parameters.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&function);

Definition at line 2275 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_return_type(*)()  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a global or a static member function with zero parameters.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&function);

Definition at line 2350 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)()  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static non-constant member function with zero parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 2095 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static non-constant member function with two parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 2043 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_return_type , typename slot_arg1_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( slot_return_type(*)(slot_arg1_type)  function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a global or a static member function with one parameter.

Parameters:
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&function);

Definition at line 2325 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type, slot_arg3_type) const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static constant member function with three parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 2147 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)() const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static constant member function with zero parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 2225 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
template<typename slot_class_type , typename slot_return_type , typename slot_arg1_type , typename slot_arg2_type , typename slot_arg3_type , typename slot_arg4_type >
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::disconnect ( const slot_class_type *  object,
slot_return_type(slot_class_type::*)(slot_arg1_type, slot_arg2_type, slot_arg3_type, slot_arg4_type) const   function,
ConnectionType  connection_type = SINGLE_CONNECTION 
) const [inline]

Disconnects a non-static constant member function with four parameters.

Parameters:
[in]objectInstance whose function shall be called.
[in]functionFunction to be called.
[in]connection_typeType of connection.

If connection_type is SINGLE_CONNECTION, only the last found connection is deleted.
If connection_type is MULTIPLE_CONNECTIONS, all connections found are deleted.

Example:

 signal.disconnect(&object, &class::function);

Definition at line 2121 of file Signals.hpp.

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
void TRTK::Signals::Signal< arg1_type, arg2_type, arg3_type, arg4_type >::send ( arg1_type  arg1,
arg2_type  arg2,
arg3_type  arg3,
arg4_type  arg4 
) const [inline]

Emits a signal.

Parameters:
[in]arg1First input argument of the called slot.
[in]arg2Second input argument of the called slot.
[in]arg3Third input argument of the called slot.
[in]arg4Fourth input argument of the called slot.

Currently, only up to four arguments are supported. An argument may only (and then must) be given, if the signal and the corresponding slots provide the particular signature.

Example:

 Signal<void> signal1;
 Signal<string> signal2;

 signal1.send();
 signal2.send("Some text.");

Definition at line 2380 of file Signals.hpp.


Friends And Related Function Documentation

template<typename arg1_type = void, typename arg2_type = void, typename arg3_type = void, typename arg4_type = void>
enum ConnectionType [related]

Slot connection type.

Author:
Christoph Haenisch
Version:
0.1.0
Date:
last changed on 2011-08-25
Enumerator:
MULTIPLE_CONNECTIONS 

Allows multiple connections of the same slot to a certain signal.

SINGLE_CONNECTION 

Allows only a single connection of a certain slot to a certain signal. If multiple connections were established before, the number of connections remains the same.

Definition at line 1267 of file Signals.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines