LibrePCB Developers Documentation
Loading...
Searching...
No Matches
Signal< Tsender, Args > Class Template Reference

The Signal class is used to emit signals on non-QObject derived classes. More...

#include <signalslot.h>

+ Inheritance diagram for Signal< Tsender, Args >:
+ Collaboration diagram for Signal< Tsender, Args >:

Public Member Functions

 Signal ()=delete
 
 Signal (const Signal &other)=delete
 
 Signal (const Tsender &sender) noexcept
 Constructor.
 
 ~Signal () noexcept
 Destructor.
 
int getSlotCount () const noexcept
 Get the count of registered slots.
 
void attach (Slot< Tsender, Args... > &slot) const noexcept
 Attach a slot.
 
void detach (Slot< Tsender, Args... > &slot) const noexcept
 Detach a slot.
 
void notify (Args... args) noexcept
 Notify all attached slots.
 
Signaloperator= (Signal const &other)=delete
 

Private Attributes

const Tsender & mSender
 Reference to the sender object.
 
QSet< Slot< Tsender, Args... > * > mSlots
 All attached slots.
 

Friends

class Slot< Tsender, Args... >
 

Detailed Description

template<typename Tsender, typename... Args>
class librepcb::Signal< Tsender, Args >

The Signal class is used to emit signals on non-QObject derived classes.

The classes librepcb::Signal and librepcb::Slot are similar to Qt's signal/slot concept. The main difference is that senders and receivers of signals do not need to be derived from QObject, thus our own signal/slot mechanism is better suited for low-level classes.

This gives the advantage of avoiding QObject overhead, but has several drawbacks:

  • No thread-safety
  • Always synchronous, no queued connections are possible
  • No endless loop detection
See also
librepcb::Slot
Template Parameters
TsenderType of the sender object
ArgsArguments passed from librepcb::Signal::notify() to the callbacks

Constructor & Destructor Documentation

◆ Signal() [1/3]

template<typename Tsender , typename... Args>
Signal ( )
delete

◆ Signal() [2/3]

template<typename Tsender , typename... Args>
Signal ( const Signal< Tsender, Args > &  other)
delete

◆ Signal() [3/3]

template<typename Tsender , typename... Args>
Signal ( const Tsender &  sender)
inlineexplicitnoexcept

Constructor.

Parameters
senderReference to the sender object of the signal

◆ ~Signal()

template<typename Tsender , typename... Args>
~Signal ( )
inlinenoexcept

Destructor.

Automatically disconnects from all slots.

Member Function Documentation

◆ getSlotCount()

template<typename Tsender , typename... Args>
int getSlotCount ( ) const
inlinenoexcept

Get the count of registered slots.

Returns
Count of registered slots

◆ attach()

template<typename Tsender , typename... Args>
void attach ( Slot< Tsender, Args... > &  slot) const
inlinenoexcept

Attach a slot.

Parameters
slotReference to the slot to attach

◆ detach()

template<typename Tsender , typename... Args>
void detach ( Slot< Tsender, Args... > &  slot) const
inlinenoexcept

Detach a slot.

Parameters
slotReference to the slot to detach

◆ notify()

template<typename Tsender , typename... Args>
void notify ( Args...  args)
inlinenoexcept

Notify all attached slots.

Parameters
argsArguments passed to the slots

◆ operator=()

template<typename Tsender , typename... Args>
Signal & operator= ( Signal< Tsender, Args > const &  other)
delete

Friends And Related Symbol Documentation

◆ Slot< Tsender, Args... >

template<typename Tsender , typename... Args>
friend class Slot< Tsender, Args... >
friend

Member Data Documentation

◆ mSender

template<typename Tsender , typename... Args>
const Tsender& mSender
private

Reference to the sender object.

◆ mSlots

template<typename Tsender , typename... Args>
QSet<Slot<Tsender, Args...>*> mSlots
mutableprivate

All attached slots.


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