Public Member Functions | Private Attributes | List of all members
ecl::Slot< Data > Class Template Reference

Function loading component of a callback system. More...

#include <slot.hpp>

Public Member Functions

void connect (const std::string &topic)
 Make a connection to the specified topic. More...
 
const std::set< std::string > & connections ()
 Lists the topics this slot is connected to. More...
 
void disconnect ()
 Disconnect the slot from all topics. More...
 
 Slot (const Slot &slot)
 Copy constructor. More...
 
 Slot (void(*f)(Data))
 Load with a global/static function. More...
 
 Slot (void(*f)(Data), const std::string &topic)
 Load with a global/static function and connect. More...
 
template<typename C >
 Slot (void(C::*f)(Data), C &c)
 Load with a member function. More...
 
template<typename C >
 Slot (void(C::*f)(Data), C &c, const std::string &topic)
 Load with a member function and connect. More...
 
 ~Slot ()
 Default destructor. More...
 

Private Attributes

SigSlot< Data > * sigslot
 

Detailed Description

template<typename Data = Void>
class ecl::Slot< Data >

Function loading component of a callback system.

Anywhere that a callback is required can be implemented with a slot. These can be placed anywhere in your code and are initialised with either a free (static or global) function, or a member function. Once initialised, they can be hooked up to a signal.

Usage examples are provided in the main page's documentation for this package.

See also
Signal<Void>, Slot.

Definition at line 54 of file slot.hpp.

Constructor & Destructor Documentation

◆ Slot() [1/5]

template<typename Data = Void>
ecl::Slot< Data >::Slot ( void(*)(Data)  f)
inline

Load with a global/static function.

Note that the function must have exactly one argument and it must be of the same type as the slot. It also must return void.

Parameters
f: the global/static function.

Definition at line 72 of file slot.hpp.

◆ Slot() [2/5]

template<typename Data = Void>
ecl::Slot< Data >::Slot ( void(*)(Data)  f,
const std::string &  topic 
)
inline

Load with a global/static function and connect.

Note that the function must have exactly one argument and it must be of the same type as the slot. It also must return void.

It additionally connects to the specified topic rapi style.

Parameters
f: the global/static function.
topic: the slot topic name to connect to.

Definition at line 86 of file slot.hpp.

◆ Slot() [3/5]

template<typename Data = Void>
template<typename C >
ecl::Slot< Data >::Slot ( void(C::*)(Data)  f,
C &  c 
)
inline

Load with a member function.

Note that the function must have exactly one argument and it must be of the same type as the slot. It also must return void.

Parameters
f: the member function.
c: the class instance.

Definition at line 101 of file slot.hpp.

◆ Slot() [4/5]

template<typename Data = Void>
template<typename C >
ecl::Slot< Data >::Slot ( void(C::*)(Data)  f,
C &  c,
const std::string &  topic 
)
inline

Load with a member function and connect.

Note that the function must have exactly one argument and it must be of the same type as the slot. It also must return void.

It additionally connects to the specified topic rapi style.

Parameters
f: the member function.
c: the class instance.
topic: the slot topic name to connect to.

Definition at line 117 of file slot.hpp.

◆ Slot() [5/5]

template<typename Data = Void>
ecl::Slot< Data >::Slot ( const Slot< Data > &  slot)
inline

Copy constructor.

This is specially designed so that copying a slot is perfectly acceptable. Copies do not increase the number of callbacks that are fired - they just preserve the slot when used with things like stl containers. When the last copy disappears, the object destroys its connection automagically.

Parameters
slot: the object to be copied.

Definition at line 133 of file slot.hpp.

◆ ~Slot()

template<typename Data = Void>
ecl::Slot< Data >::~Slot ( )
inline

Default destructor.

This handles the cleanup operation, first decrementing and then checking if its the last of its instance. If it is, it cleans up the sigslot connection with the sigslots manager.

Definition at line 145 of file slot.hpp.

Member Function Documentation

◆ connect()

template<typename Data = Void>
void ecl::Slot< Data >::connect ( const std::string &  topic)
inline

Make a connection to the specified topic.

This contacts the sigslots manager to connect the signal to the specified topic - creating the topic if it is not yet existing.

Parameters
topic: the topic to connect to.

Definition at line 166 of file slot.hpp.

◆ connections()

template<typename Data = Void>
const std::set<std::string>& ecl::Slot< Data >::connections ( )
inline

Lists the topics this slot is connected to.

Useful for debugging.

Returns
set<string> : a set of topic names this slot is listening to.

Definition at line 157 of file slot.hpp.

◆ disconnect()

template<typename Data = Void>
void ecl::Slot< Data >::disconnect ( )
inline

Disconnect the slot from all topics.

This completely disconnects the slot.

Definition at line 172 of file slot.hpp.

Member Data Documentation

◆ sigslot

template<typename Data = Void>
SigSlot<Data>* ecl::Slot< Data >::sigslot
private

Definition at line 175 of file slot.hpp.


The documentation for this class was generated from the following file:


ecl_sigslots
Author(s): Daniel Stonier
autogenerated on Wed Mar 2 2022 00:16:47