aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
mixedGraphListener.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 mixed graph listeners
24  *
25  * @author Pierre-Henri WUILLEMIN(@LIP6)
26  */
27 #ifndef GUM_MIXEDGRAPH_LISTENER_H
28 #define GUM_MIXEDGRAPH_LISTENER_H
29 
30 #include <agrum/tools/core/signal/listener.h>
31 #include <agrum/tools/graphs/mixedGraph.h>
32 
33 namespace gum {
34  /** @class MixedGraphListener
35  * @brief Abstract Base class for all mixed Graph Listener
36  *
37  * \ingroup graph_group
38  *
39  *
40  * This is the virtual base class for mixed graphs meta-listener.
41  *
42  * A MixedGraphListener 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  * - void whenEdgeAdded( const void *,gum::NodeId,gum::NodeId )
48  * - void whenEdgeDeleted( const void *,gum::NodeId,gum::NodeId )
49  */
50  class MixedGraphListener: public Listener {
51  public:
52  // ############################################################################
53  /// @name Constructors / Destructors
54  // ############################################################################
55  /// @{
56 
57  /// default constructor
58  /** @param g the graph to listen to
59  * @warning Note that, by the aGrUM's constructor parameter's rule, the fact
60  * that g is passed as a pointer means that g is not copied, but only
61  * referenced by the listener. */
62  MixedGraphListener(MixedGraph* g);
63 
64  /// destructor
66 
67  /// @}
68 
69  // ############################################################################
70  /// @name signals to listen to
71  // ############################################################################
72  /// @{
73 
74  /// the action to take when a new node is inserted into the graph
75  /** @param src the object that sent the signal
76  * @param id the id of the new node inserted into the graph */
77  virtual void whenNodeAdded(const void* src, NodeId id) = 0;
78 
79  /// the action to take when a node has just been removed from the graph
80  /** @param src the object that sent the signal
81  * @param id the id of the node has just been removed from the graph */
82  virtual void whenNodeDeleted(const void* src, NodeId id) = 0;
83 
84  /// the action to take when a new arc is inserted into the graph
85  /** @param src the object that sent the signal
86  * @param from the id of tail of the new arc inserted into the graph
87  * @param to the id of head of the new arc inserted into the graph */
88  virtual void whenArcAdded(const void* src, NodeId from, NodeId to) = 0;
89 
90  /// the action to take when an arc has just been removed from the graph
91  /** @param src the object that sent the signal
92  * @param from the id of tail of the arc removed from the graph
93  * @param to the id of head of the arc removed from the graph */
94  virtual void whenArcDeleted(const void* src, NodeId from, NodeId to) = 0;
95 
96  /// the action to take when a new edge is inserted into the graph
97  /** @param src the object that sent the signal
98  * @param id1 the id of one node of the edge inserted into the graph
99  * @param id2 the id of the other node of the edge inserted into the graph
100  */
101  virtual void whenEdgeAdded(const void* src, NodeId id1, NodeId id2) = 0;
102 
103  /// the action to take when an edge has just been removed from the graph
104  /** @param src the object that sent the signal
105  * @param from the id of one node of the edge removed from the graph
106  * @param to the id of the other node of the edge removed from the graph */
107  virtual void whenEdgeDeleted(const void* src, NodeId from, NodeId to) = 0;
108 
109  /// @}
110 
111  protected:
112  /// the graph to listen to
114 
115  private:
116  /// copy constructor (for the moment, this operation is forbidden)
117  /** @param d the MixedGraphListener to copy */
119 
120  /// copy operator (for the moment, this operation is forbidden)
121  /** @param d the MixedGraphListener to copy */
123  };
124 
125 } // namespace gum
126 
127 #ifndef GUM_NO_INLINE
128 # include <agrum/tools/graphs/parts/listeners/mixedGraphListener_inl.h>
129 #endif // GUM_NOINLINE
130 
131 #endif // GUM_MIXEDGRAPH_LISTENER_H
virtual void whenEdgeAdded(const void *src, NodeId id1, NodeId id2)=0
the action to take when a new edge is inserted into the graph
MixedGraphListener & operator=(const MixedGraphListener &d)
copy operator (for the moment, this operation is forbidden)
INLINE void emplace(Args &&... args)
Definition: set_tpl.h:643
virtual void whenArcAdded(const void *src, NodeId from, NodeId to)=0
the action to take when a new arc is inserted into the graph
MixedGraph * graph_
the graph to listen to
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
Abstract Base class for all mixed Graph Listener.
virtual void whenNodeAdded(const void *src, NodeId id)=0
the action to take when a new node is inserted into the graph
MixedGraphListener(MixedGraph *g)
default constructor
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 whenArcDeleted(const void *src, NodeId from, NodeId to)=0
the action to take when an arc has just been removed from the graph
MixedGraphListener(const MixedGraphListener &d)
copy constructor (for the moment, this operation is forbidden)