NAP
Public Types | Public Member Functions | List of all members
Slot< Args > Class Template Reference

#include <nap/signalslot.h>

Public Types

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

Public Member Functions

 Slot ()=default
 
 Slot (Function inFunction)
 
template<typename U , typename F >
 Slot (U *parent, F memberFunction)
 
template<typename U , typename F >
 Slot (U *parent, F memberFunction, Signal< Args... > &signal)
 
 ~Slot ()
 
void disconnect ()
 
void setFunction (Function func)
 
void trigger (Args... args)
 
void copyCauses (const Slot &rhs)
 
Slotoperator= (Slot &&other)
 
Slotoperator= (const Slot &other)
 

Description

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

Manages a function call that can be connected to a signal. A slot hides the connect / disconnect behavior of an event.

Member Typedef Documentation

◆ Function

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

Constructor & Destructor Documentation

◆ Slot() [1/4]

Slot ( )
default

◆ Slot() [2/4]

Slot ( Function  inFunction)

Initialize this slot with the function to call

Parameters
inFunctionfunction to call

◆ Slot() [3/4]

Slot ( U *  parent,
memberFunction 
)

This templated constructor can be used to initialize the slot with a member function with one single parameter

Parameters
parentparent object
memberFunctionmember function to call

◆ Slot() [4/4]

Slot ( U *  parent,
memberFunction,
Signal< Args... > &  signal 
)

This templated constructor can be used to initialize the slot with a member function with one single parameter, last argument is a signal to connect to straightaway after construction

Parameters
parentparent object
memberFunctionmember function to call

◆ ~Slot()

~Slot ( )

Member Function Documentation

◆ copyCauses()

void copyCauses ( const Slot< Args > &  rhs)

Clears existing and copies rhs connections

Parameters
rhs

◆ disconnect()

void disconnect

Disconnects the slot from all signals it is connected to

◆ operator=() [1/2]

Slot& operator= ( const Slot< Args > &  other)

Assign a slot by copying all signal connections and callable function. Note that the assigned callback is NOT copied, only the connections. The data of the other slot is invalidated -> all active connections are removed.

◆ operator=() [2/2]

Slot& operator= ( Slot< Args > &&  other)

Assign a slot by copying all connections and callable function Note that the function is NOT copied, only the active signal connections.

◆ setFunction()

void setFunction ( Function  func)

Update callable function

Parameters
functhe function to set

◆ trigger()

void trigger ( Args...  args)

Trigger function using given argument

Parameters
argscallabale argument