aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
undiGraphListener.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 undirected graph listeners
24  *
25  * @author Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 #ifndef GUM_UNDIGRAPH_LISTENER_H
28 #define GUM_UNDIGRAPH_LISTENER_H
29 
30 #include <agrum/tools/core/signal/listener.h>
31 #include <agrum/tools/graphs/undiGraph.h>
32 
33 namespace gum {
34  /** @class UndiGraphListener
35  * @brief Abstract Base class for all undiGraph Listener
36  *
37  * \ingroup graph_group
38  *
39  *
40  * This is the virtual base class for not-oriented graphs meta-listener.
41  *
42  * An UndiGraphListener will have to implement following pure methods :
43  * - void whenNodeAdded( const void * ,gum::NodeId )
44  * - void whenNodeDeleted( const void *,gum::NodeId )
45  * - void whenEdgeAdded( const void *,gum::NodeId,gum::NodeId )
46  * - void whenEdgeDeleted( const void *,gum::NodeId,gum::NodeId )
47  */
48  class UndiGraphListener: 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  UndiGraphListener(UndiGraph* g);
61 
62  /// destructor
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 edge is inserted into the graph
83  /** @param src the object that sent the signal
84  * @param id1 the id of one node of the edge inserted into the graph
85  * @param id2 the id of the other node of the edge inserted into the graph
86  */
87  virtual void whenEdgeAdded(const void* src, NodeId id1, NodeId id2) = 0;
88 
89  /// the action to take when an edge has just been removed from the graph
90  /** @param src the object that sent the signal
91  * @param from the id of one node of the edge removed from the graph
92  * @param to the id of the other node of the edge removed from the graph */
93  virtual void whenEdgeDeleted(const void* src, NodeId from, NodeId to) = 0;
94 
95  /// @}
96 
97  protected:
98  /// the graph to listen to
100 
101  private:
102  /// copy constructor (for the moment, this operation is forbidden)
103  /** @param d the UndiGraphListener to copy */
105 
106  /// copy operator (for the moment, this operation is forbidden)
107  /** @param d the UndiGraphListener to copy */
109  };
110 
111 } // namespace gum
112 
113 #ifndef GUM_NO_INLINE
114 # include <agrum/tools/graphs/parts/listeners/undiGraphListener_inl.h>
115 #endif // GUM_NOINLINE
116 
117 #endif // GUM_UNDIGRAPH_LISTENER_H
UndiGraphListener(const UndiGraphListener &d)
copy constructor (for the moment, this operation is forbidden)
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
UndiGraphListener(UndiGraph *g)
default constructor
UndiGraphListener & operator=(const UndiGraphListener &d)
copy operator (for the moment, this operation is forbidden)
virtual void whenEdgeAdded(const void *src, NodeId id1, NodeId id2)=0
the action to take when a new edge is inserted into the graph
Abstract Base class for all undiGraph Listener.
UndiGraph * graph_
the graph to listen to
virtual void whenNodeDeleted(const void *src, NodeId id)=0
the action to take when a node has just been removed from the graph
virtual void whenEdgeDeleted(const void *src, NodeId from, NodeId to)=0
the action to take when an edge has just been removed from the graph
virtual void whenNodeAdded(const void *src, NodeId id)=0
the action to take when a new node is inserted into the graph