aGrUM  0.15.1
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 74 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 77 of file listener.h.

Constructor & Destructor Documentation

◆ Listener() [1/2]

gum::Listener::Listener ( )

Class constructor.

Definition at line 35 of file listener.cpp.

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

◆ Listener() [2/2]

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

Definition at line 37 of file listener.cpp.

References __senders.

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

◆ ~Listener()

gum::Listener::~Listener ( )
virtual

Definition at line 45 of file listener.cpp.

References __senders.

45  {
46  GUM_DESTRUCTOR(Listener);
47 
48  for (const auto el : __senders) {
49  el->detachFromTarget(this);
50  }
51 
52  __senders.clear();
53  }
Listener()
Class constructor.
Definition: listener.cpp:35
Senders_list __senders
Definition: listener.h:94

Member Function Documentation

◆ attachSignal__()

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

Definition at line 36 of file listener_inl.h.

References __senders.

36  {
37  __senders.push_back(sender);
38  }
Senders_list __senders
Definition: listener.h:94

◆ detachSignal__()

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

Definition at line 40 of file listener_inl.h.

References __senders.

40  {
41  auto del = std::remove(__senders.begin(), __senders.end(), sender);
42 
43  if (del != __senders.end()) __senders.erase(del, __senders.end());
44  }
Senders_list __senders
Definition: listener.h:94

Member Data Documentation

◆ __senders

Senders_list gum::Listener::__senders
private

Definition at line 94 of file listener.h.

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


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