LibrePCB Developers Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 ( )
delete
Signal ( const Signal< Tsender, Args > &  other)
delete
Signal ( const Tsender &  sender)
inlineexplicitnoexcept

Constructor.

Parameters
senderReference to the sender object of the signal
~Signal ( )
inlinenoexcept

Destructor.

Automatically disconnects from all slots.

Member Function Documentation

int getSlotCount ( ) const
inlinenoexcept

Get the count of registered slots.

Returns
Count of registered slots
void attach ( Slot< Tsender, Args...> &  slot) const
inlinenoexcept

Attach a slot.

Parameters
slotReference to the slot to attach
void detach ( Slot< Tsender, Args...> &  slot) const
inlinenoexcept

Detach a slot.

Parameters
slotReference to the slot to detach
void notify ( Args...  args)
inlinenoexcept

Notify all attached slots.

Parameters
argsArguments passed to the slots
Signal& operator= ( Signal< Tsender, Args > const &  other)
delete

Friends And Related Function Documentation

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

Member Data Documentation

const Tsender& mSender
private

Reference to the sender object.

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

All attached slots.


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