aGrUM  0.15.0
listener.h
Go to the documentation of this file.
1 
31 #ifndef GUM_LISTENER_H
32 #define GUM_LISTENER_H
33 
34 #include <algorithm>
35 #include <vector>
36 
37 #include <agrum/agrum.h>
38 #include <agrum/core/debug.h>
39 
40 namespace gum {
41 
42 #ifndef DOXYGEN_SHOULD_SKIP_THIS
43 
44  class Listener;
45 
46  namespace __sig__ {
47 
55  class ISignaler {
56  public:
57  virtual ~ISignaler(){};
58  virtual void detachFromTarget(Listener* target) = 0;
59  virtual void duplicateTarget(const Listener* oldtarget,
60  Listener* newtarget) = 0;
61  virtual bool hasListener() = 0;
62  };
63  } // namespace __sig__
64 
65 #endif // DOXYGEN_SHOULD_SKIP_THIS
66 
74  class Listener {
75  private:
77  typedef std::vector< __sig__::ISignaler* > Senders_list;
78 
79  public:
83  Listener();
84 
85  Listener(const Listener& l);
86 
87  virtual ~Listener();
88 
89  void attachSignal__(__sig__::ISignaler* sender);
90 
91  void detachSignal__(__sig__::ISignaler* sender);
92 
93  private:
94  Senders_list __senders;
95  };
96 } // namespace gum
97 
98 #define GUM_CONNECT(sender, signal, receiver, target) \
99  (sender).signal.attach(&(receiver), &target)
100 
101 #ifndef GUM_NO_INLINE
103 #endif // GUM_NO_INLINE
104 
105 #endif // GUM_LISTENER_H
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
std::vector< __sig__::ISignaler *> Senders_list
Alias for the list of signal senders.
Definition: listener.h:77
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Senders_list __senders
Definition: listener.h:94
Every class who would catch signal from signaler should derive from Listener.
Definition: listener.h:74