LibrePCB Developers Documentation
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. More...
 
 ~Signal () noexcept
 Destructor. More...
 
int getSlotCount () const noexcept
 Get the count of registered slots. More...
 
void attach (Slot< Tsender, Args... > &slot) const noexcept
 Attach a slot. More...
 
void detach (Slot< Tsender, Args... > &slot) const noexcept
 Detach a slot. More...
 
void notify (Args... args) noexcept
 Notify all attached slots. More...
 
Signaloperator= (Signal const &other)=delete
 

Private Attributes

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

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]

Signal ( )
delete

◆ Signal() [2/3]

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

◆ Signal() [3/3]

Signal ( const Tsender &  sender)
inlineexplicitnoexcept

Constructor.

Parameters
senderReference to the sender object of the signal

◆ ~Signal()

~Signal ( )
inlinenoexcept

Destructor.

Automatically disconnects from all slots.

Member Function Documentation

◆ getSlotCount()

int getSlotCount ( ) const
inlinenoexcept

Get the count of registered slots.

Returns
Count of registered slots

◆ attach()

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

Attach a slot.

Parameters
slotReference to the slot to attach

◆ detach()

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

Detach a slot.

Parameters
slotReference to the slot to detach

◆ notify()

void notify ( Args...  args)
inlinenoexcept

Notify all attached slots.

Parameters
argsArguments passed to the slots
+ Here is the caller graph for this function:

◆ operator=()

Signal& operator= ( Signal< Tsender, Args > const &  other)
delete
+ Here is the caller graph for this function:

Friends And Related Function Documentation

◆ Slot< Tsender, Args... >

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

Member Data Documentation

◆ mSender

const Tsender& mSender
private

Reference to the sender object.

◆ mSlots

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

All attached slots.


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