aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::DiGraphListener Class Referenceabstract

Abstract Base class for all diGraph Listener. More...

#include <diGraphListener.h>

+ Inheritance diagram for gum::DiGraphListener:
+ Collaboration diagram for gum::DiGraphListener:

Public Member Functions

void _attachSignal_ (__sig__::ISignaler *sender)
 
void _detachSignal_ (__sig__::ISignaler *sender)
 
Constructors / Destructors
 DiGraphListener (const DiGraph *g)
 default constructor More...
 
 ~DiGraphListener ()
 destructor More...
 
signals to listen to
virtual void whenNodeAdded (const void *src, NodeId id)=0
 the action to take when a new node is inserted into the graph More...
 
virtual void whenNodeDeleted (const void *src, NodeId id)=0
 the action to take when a node has just been removed from the graph More...
 
virtual void whenArcAdded (const void *src, NodeId from, NodeId to)=0
 the action to take when a new arc is inserted into the graph More...
 
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 More...
 

Protected Attributes

DiGraphgraph_
 the graph to listen to More...
 

Detailed Description

Abstract Base class for all diGraph Listener.

This is the virtual base class for graphs meta-listener.

A DiGraphListener will have to implement following pure methods :

Definition at line 48 of file diGraphListener.h.

Constructor & Destructor Documentation

◆ DiGraphListener() [1/2]

gum::DiGraphListener::DiGraphListener ( const DiGraph g)

default constructor

Parameters
gthe graph to listen to.
Warning
Note that, by the aGrUM's constructor parameter's rule, the fact that g is passed as a pointer means that g is not copied, but only referenced by the listener.

Definition at line 46 of file diGraphListener.cpp.

References gum::Set< Key, Alloc >::emplace().

46  {
47  if (!g) { GUM_ERROR(OperationNotAllowed, "A graph listener need a graph to listen to") }
48 
49  GUM_CONSTRUCTOR(DiGraphListener);
50  graph_ = const_cast< DiGraph* >(g);
51 
52  GUM_CONNECT((*graph_), onNodeAdded, (*this), DiGraphListener::whenNodeAdded);
53  GUM_CONNECT((*graph_), onNodeDeleted, (*this), DiGraphListener::whenNodeDeleted);
54  GUM_CONNECT((*graph_), onArcAdded, (*this), DiGraphListener::whenArcAdded);
55  GUM_CONNECT((*graph_), onArcDeleted, (*this), DiGraphListener::whenArcDeleted);
56  }
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
virtual void whenNodeDeleted(const void *src, NodeId id)=0
the action to take when a node has just been removed from the graph
#define GUM_CONNECT(sender, signal, receiver, target)
Definition: listener.h:96
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
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ ~DiGraphListener()

gum::DiGraphListener::~DiGraphListener ( )

destructor

Definition at line 58 of file diGraphListener.cpp.

References gum::Set< Key, Alloc >::emplace().

58  {
59  GUM_DESTRUCTOR(DiGraphListener);
60  ;
61  }
DiGraphListener(const DiGraph *g)
default constructor
+ Here is the call graph for this function:

◆ DiGraphListener() [2/2]

gum::DiGraphListener::DiGraphListener ( const DiGraphListener d)
private

copy constructor (for the moment, this operation is forbidden)

Parameters
dthe DiGraphListener to copy

Definition at line 36 of file diGraphListener.cpp.

References gum::Set< Key, Alloc >::emplace().

36  {
37  GUM_CONS_CPY(DiGraphListener);
38  GUM_ERROR(OperationNotAllowed, "No copy constructor for DiGraphListener")
39  }
DiGraphListener(const DiGraph *g)
default constructor
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

Member Function Documentation

◆ _attachSignal_()

INLINE void gum::Listener::_attachSignal_ ( __sig__::ISignaler *  sender)
inherited

Definition at line 35 of file listener_inl.h.

References gum::Set< Key, Alloc >::emplace().

35 { _senders_.push_back(sender); }
Senders_list _senders_
Definition: listener.h:92
+ Here is the call graph for this function:

◆ _detachSignal_()

INLINE void gum::Listener::_detachSignal_ ( __sig__::ISignaler *  sender)
inherited

Definition at line 37 of file listener_inl.h.

References gum::Set< Key, Alloc >::emplace().

37  {
38  auto del = std::remove(_senders_.begin(), _senders_.end(), sender);
39 
40  if (del != _senders_.end()) _senders_.erase(del, _senders_.end());
41  }
Senders_list _senders_
Definition: listener.h:92
+ Here is the call graph for this function:

◆ operator=()

DiGraphListener & gum::DiGraphListener::operator= ( const DiGraphListener d)
private

copy operator (for the moment, this operation is forbidden)

Parameters
dthe DiGraphListener to copy

Definition at line 41 of file diGraphListener.cpp.

References gum::Set< Key, Alloc >::emplace().

41  {
42  GUM_OP_CPY(DiGraphListener);
43  GUM_ERROR(OperationNotAllowed, "No copy operator for DiGraphListener")
44  }
DiGraphListener(const DiGraph *g)
default constructor
#define GUM_ERROR(type, msg)
Definition: exceptions.h:51
+ Here is the call graph for this function:

◆ whenArcAdded()

virtual void gum::DiGraphListener::whenArcAdded ( const void *  src,
NodeId  from,
NodeId  to 
)
pure virtual

the action to take when a new arc is inserted into the graph

Parameters
srcthe object that sent the signal
fromthe id of tail of the new arc inserted into the graph
tothe id of head of the new arc inserted into the graph

Implemented in gum::BayesNetFragment< GUM_SCALAR >.

◆ whenArcDeleted()

virtual void gum::DiGraphListener::whenArcDeleted ( const void *  src,
NodeId  from,
NodeId  to 
)
pure virtual

the action to take when an arc has just been removed from the graph

Parameters
srcthe object that sent the signal
fromthe id of tail of the arc removed from the graph
tothe id of head of the arc removed from the graph

Implemented in gum::BayesNetFragment< GUM_SCALAR >.

◆ whenNodeAdded()

virtual void gum::DiGraphListener::whenNodeAdded ( const void *  src,
NodeId  id 
)
pure virtual

the action to take when a new node is inserted into the graph

Parameters
srcthe object that sent the signal
idthe id of the new node inserted into the graph

Implemented in gum::BayesNetFragment< GUM_SCALAR >.

◆ whenNodeDeleted()

virtual void gum::DiGraphListener::whenNodeDeleted ( const void *  src,
NodeId  id 
)
pure virtual

the action to take when a node has just been removed from the graph

Parameters
srcthe object that sent the signal
idthe id of the node has just been removed from the graph

Implemented in gum::BayesNetFragment< GUM_SCALAR >.

Member Data Documentation

◆ graph_

DiGraph* gum::DiGraphListener::graph_
protected

the graph to listen to

Definition at line 98 of file diGraphListener.h.


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