SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::patterns::Slot< Args > Class Template Referencefinal

A slot is a connection between a signal and a callback. More...

#include <Slot.h>

Public Member Functions

 Slot (const std::function< void(Args...)> &f)
 Instantiates a slot with a callback.
 
 Slot (std::function< void(Args...)> &&f)
 Instantiates a slot with a callback.
 
template<class T >
 Slot (T *target, void(T::*method)(Args...))
 Instantiates a slot from a non const method pointer.
 
template<class T >
 Slot (T *target, void(T::*method)(Args...) const)
 Instantiates a slot from a const method pointer.
 
 Slot (const Slot &slot)
 
 Slot (Slot &&slot) noexcept
 
Slotoperator= (const Slot &slot)
 
Slotoperator= (Slot &&slot) noexcept
 
bool isConnected () const
 Checks if this slot is connected to a signal.
 
void disconnect ()
 Disconnects this slot from the signal.
 

Friends

class details::Connection< Args... >
 
class Signal< Args... >
 

Detailed Description

template<typename... Args>
class spark::patterns::Slot< Args >

A slot is a connection between a signal and a callback.

Template Parameters
ArgsThe types of the arguments of the callback.

Constructor & Destructor Documentation

◆ Slot() [1/4]

template<typename... Args>
spark::patterns::Slot< Args >::Slot ( const std::function< void(Args...)> & f)
explicit

Instantiates a slot with a callback.

Parameters
fThe callback as a function object.

◆ Slot() [2/4]

template<typename... Args>
spark::patterns::Slot< Args >::Slot ( std::function< void(Args...)> && f)
explicit

Instantiates a slot with a callback.

Parameters
fThe callback as a function object.

◆ Slot() [3/4]

template<typename... Args>
template<class T >
spark::patterns::Slot< Args >::Slot ( T * target,
void(T::* method )(Args...) )

Instantiates a slot from a non const method pointer.

Template Parameters
TThe class containing the method.
Parameters
targetThe instance of the class containing the method.
methodThe address of the method to use as callback.

◆ Slot() [4/4]

template<typename... Args>
template<class T >
spark::patterns::Slot< Args >::Slot ( T * target,
void(T::* method )(Args...) const )

Instantiates a slot from a const method pointer.

Template Parameters
TThe class containing the method.
Parameters
targetThe instance of the class containing the method.
methodThe address of the method to use as callback.

Member Function Documentation

◆ isConnected()

template<typename... Args>
bool spark::patterns::Slot< Args >::isConnected ( ) const
nodiscard

Checks if this slot is connected to a signal.

Returns
True if this slot is connected to a signal, false otherwise.