aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
diGraphListener.h
Go to the documentation of this file.
1 /**
2  *
3  * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(@LIP6) & Christophe GONZALES(@AMU)
4  * info_at_agrum_dot_org
5  *
6  * This library is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 
22 /** @file
23  * @brief Base classes for oriented graph listeners
24  *
25  * @author Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 #ifndef GUM_DIGRAPH_LISTENER_H
28 #define GUM_DIGRAPH_LISTENER_H
29 
30 #include <agrum/tools/core/signal/listener.h>
31 #include <agrum/tools/graphs/diGraph.h>
32 
33 namespace gum {
34  /** @class DiGraphListener
35  * @brief Abstract Base class for all diGraph Listener
36  *
37  * \ingroup graph_group
38  *
39  *
40  * This is the virtual base class for graphs meta-listener.
41  *
42  * A DiGraphListener will have to implement following pure methods :
43  * - void whenNodeAdded( const void * ,gum::NodeId )
44  * - void whenNodeDeleted( const void *,gum::NodeId )
45  * - void whenArcAdded( const void *,gum::NodeId,gum::NodeId )
46  * - void whenArcDeleted( const void *,gum::NodeId,gum::NodeId )
47  */
48  class DiGraphListener: public Listener {
49  public:
50  // ############################################################################
51  /// @name Constructors / Destructors
52  // ############################################################################
53  /// @{
54 
55  /// default constructor
56  /** @param g the graph to listen to.
57  * @warning Note that, by the aGrUM's constructor parameter's rule, the fact
58  * that g is passed as a pointer means that g is not copied, but only
59  * referenced by the listener. */
60  DiGraphListener(const DiGraph* g);
61 
62  /// destructor
63  ~DiGraphListener();
64 
65  /// @}
66 
67  // ############################################################################
68  /// @name signals to listen to
69  // ############################################################################
70  /// @{
71 
72  /// the action to take when a new node is inserted into the graph
73  /** @param src the object that sent the signal
74  * @param id the id of the new node inserted into the graph */
75  virtual void whenNodeAdded(const void* src, NodeId id) = 0;
76 
77  /// the action to take when a node has just been removed from the graph
78  /** @param src the object that sent the signal
79  * @param id the id of the node has just been removed from the graph */
80  virtual void whenNodeDeleted(const void* src, NodeId id) = 0;
81 
82  /// the action to take when a new arc is inserted into the graph
83  /** @param src the object that sent the signal
84  * @param from the id of tail of the new arc inserted into the graph
85  * @param to the id of head of the new arc inserted into the graph */
86  virtual void whenArcAdded(const void* src, NodeId from, NodeId to) = 0;
87 
88  /// the action to take when an arc has just been removed from the graph
89  /** @param src the object that sent the signal
90  * @param from the id of tail of the arc removed from the graph
91  * @param to the id of head of the arc removed from the graph */
92  virtual void whenArcDeleted(const void* src, NodeId from, NodeId to) = 0;
93 
94  /// @}
95 
96  protected:
97  /// the graph to listen to
99 
100  private:
101  /// copy constructor (for the moment, this operation is forbidden)
102  /** @param d the DiGraphListener to copy */
104 
105  /// copy operator (for the moment, this operation is forbidden)
106  /** @param d the DiGraphListener to copy */
108  };
109 
110 } // namespace gum
111 
112 #ifndef GUM_NO_INLINE
113 # include <agrum/tools/graphs/parts/listeners/diGraphListener_inl.h>
114 #endif // GUM_NOINLINE
115 
116 #endif // GUM_DIGRAPH_LISTENER_H
DiGraphListener(const DiGraphListener &d)
copy constructor (for the moment, this operation is forbidden)
Abstract Base class for all diGraph Listener.
DiGraphListener(const DiGraph *g)
default constructor
virtual void whenArcAdded(const void *src, NodeId from, NodeId to)=0
the action to take when a new arc is inserted into the graph
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual void whenNodeDeleted(const void *src, NodeId id)=0
the action to take when a node has just been removed from the graph
DiGraphListener & operator=(const DiGraphListener &d)
copy operator (for the moment, this operation is forbidden)
~DiGraphListener()
destructor
virtual void whenNodeAdded(const void *src, NodeId id)=0
the action to take when a new node is inserted into the graph
DiGraph * graph_
the graph to listen to
virtual void whenArcDeleted(const void *src, NodeId from, NodeId to)=0
the action to take when an arc has just been removed from the graph