aGrUM  0.13.3
gum::Listener Class Reference

Every class who would catch signal from signaler should derive from Listener. More...

#include <agrum/core/signal/listener.h>

+ Inheritance diagram for gum::Listener:

Public Member Functions

 Listener ()
 Class constructor. More...
 
 Listener (const Listener &l)
 
virtual ~Listener ()
 
void attachSignal__ (__sig__::ISignaler *sender)
 
void detachSignal__ (__sig__::ISignaler *sender)
 

Detailed Description

Every class who would catch signal from signaler should derive from Listener.

Definition at line 72 of file listener.h.

Member Typedef Documentation

◆ Senders_list

typedef std::vector< __sig__::ISignaler* > gum::Listener::Senders_list
private

Alias for the list of signal senders.

Definition at line 75 of file listener.h.

Constructor & Destructor Documentation

◆ Listener() [1/2]

gum::Listener::Listener ( )

Class constructor.

Definition at line 32 of file listener.cpp.

32 { GUM_CONSTRUCTOR(Listener); }
Listener()
Class constructor.
Definition: listener.cpp:32

◆ Listener() [2/2]

gum::Listener::Listener ( const Listener l)

Definition at line 34 of file listener.cpp.

References __senders.

34  {
35  GUM_CONS_CPY(Listener);
36 
37  for (const auto el : __senders) {
38  el->duplicateTarget(&l, this);
39  };
40  }
Listener()
Class constructor.
Definition: listener.cpp:32
Senders_list __senders
Definition: listener.h:92

◆ ~Listener()

gum::Listener::~Listener ( )
virtual

Definition at line 42 of file listener.cpp.

References __senders.

42  {
43  GUM_DESTRUCTOR(Listener);
44 
45  for (const auto el : __senders) {
46  el->detachFromTarget(this);
47  }
48 
49  __senders.clear();
50  }
Listener()
Class constructor.
Definition: listener.cpp:32
Senders_list __senders
Definition: listener.h:92

Member Function Documentation

◆ attachSignal__()

INLINE void gum::Listener::attachSignal__ ( __sig__::ISignaler *  sender)

Definition at line 33 of file listener_inl.h.

References __senders.

33  {
34  __senders.push_back(sender);
35  }
Senders_list __senders
Definition: listener.h:92

◆ detachSignal__()

INLINE void gum::Listener::detachSignal__ ( __sig__::ISignaler *  sender)

Definition at line 37 of file listener_inl.h.

References __senders.

37  {
38  auto del = std::remove(__senders.begin(), __senders.end(), sender);
39 
40  if (del != __senders.end()) __senders.erase(del, __senders.end());
41  }
Senders_list __senders
Definition: listener.h:92

Member Data Documentation

◆ __senders

Senders_list gum::Listener::__senders
private

Definition at line 92 of file listener.h.

Referenced by attachSignal__(), detachSignal__(), Listener(), and ~Listener().


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