NAP
Public Types | Public Member Functions | List of all members
Signal< Args > Class Template Referencefinal

#include <nap/signalslot.h>

Public Types

using Function = std::function< void(Args... args)>
 

Public Member Functions

 ~Signal ()
 
void connect (Signal< Args... > &signal)
 
void disconnect (Signal< Args... > &signal)
 
void connect (Slot< Args... > &slot)
 
void disconnect (Slot< Args... > &slot)
 
void connect (const Function &inFunction)
 
template<typename U , typename F >
void connect (U *object, F memberFunction)
 
void operator() (Args... args)
 
void trigger (Args... args)
 

Description

template<typename... Args>
class nap::Signal< Args >

A callable signal to which slots, functions or other signals can be connected to provide loose coupling. The signal variadic template arguments to be able to work with different sets of arguments.

Member Typedef Documentation

◆ Function

using Function = std::function<void(Args... args)>

Constructor & Destructor Documentation

◆ ~Signal()

Member Function Documentation

◆ connect() [1/4]

void connect ( const Function inFunction)

Connect a raw function object. Note that when any captured data in a connected function is deleted this signal will be unsafe to call. Also disconnecting a raw function is not possible. Connecting a function is mainly only good practice when the scope of the signal is the same as the function's.

◆ connect() [2/4]

void connect ( Signal< Args... > &  signal)

Connect to another signal that can call other functions, slots or signals in turn

◆ connect() [3/4]

void connect ( Slot< Args... > &  slot)

Connect to a slot with similar signature. A slot is an object managing a function to be called. Advantages of connecting to a slot instead of a raw function:

  • the slot disconnects itself on destruction, so it's still safe to call the signal afterwards
  • the slot can be disconnected from the signal

◆ connect() [4/4]

void connect ( U *  object,
memberFunction 
)

Convenience method to connect a member function with one argument.

◆ disconnect() [1/2]

void disconnect ( Signal< Args... > &  signal)

Disconnect from another signal

◆ disconnect() [2/2]

void disconnect ( Slot< Args... > &  slot)

Disconnect from a slot

◆ operator()()

void operator() ( Args...  args)

Call operator to trigger the signal to be emitted.

◆ trigger()

void trigger ( Args...  args)

Trigger the signal to be emitted