Abstract Base class for graph observers. More...
#include <ogdf/basic/Graph_d.h>
Public Member Functions | |
GraphObserver ()=default | |
Constructs instance of GraphObserver class. More... | |
GraphObserver (const Graph *G) | |
Constructs instance of GraphObserver class. More... | |
virtual void | cleared ()=0 |
Called by watched graph when its clear function is called, just before things are removed. More... | |
virtual void | edgeAdded (edge e)=0 |
Called by watched graph after an edge has been added. More... | |
virtual void | edgeDeleted (edge e)=0 |
Called by watched graph just before an edge is deleted. More... | |
const Graph * | getGraph () const |
virtual void | nodeAdded (node v)=0 |
Called by watched graph after a node has been added. More... | |
virtual void | nodeDeleted (node v)=0 |
Called by watched graph just before a node is deleted. More... | |
Public Member Functions inherited from ogdf::Observer< Graph, GraphObserver > | |
Observer ()=default | |
Constructs instance of Observer class. More... | |
Observer (const Observer ©)=delete | |
If you want to copy a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense. More... | |
Observer (Observer &&move)=delete | |
If you want to move a subclass of Observer, call the default Observer() constructor and optionally also call reregister if it makes sense. More... | |
virtual | ~Observer () |
Destroys the instance, unregisters it from watched instance. More... | |
const Graph * | getObserved () const |
Observer & | operator= (const Observer ©)=delete |
Observer & | operator= (Observer &&move)=delete |
virtual void | registrationChanged (const Graph *old) |
Called after reregister() changed the observed instance. More... | |
void | reregister (const Graph *obs) |
Associates observer instance with instance obs . More... | |
Abstract Base class for graph observers.
If a class needs to keep track of changes in a graph like addition or deletion of nodes or edges, you can derive it from GraphObserver and override the notification methods nodeDeleted, nodeAdded, edgeDeleted, edgeAdded and cleared.
It is guaranteed that the Graph is in a valid state (in terms of Graph::consistencyCheck()
, that means there are no-half added edges or the like) whenever the notification methods are called. Furthermore, on addition all registered Arrays have already been resized to accommodate the new object. On compound operations like Graph::split() or Graph::insert(), the notifications may be batched and thus delayed, that is, when the callback is made the Graph may already contain some further (fully initialized) nodes or edges for which the respective callbacks have not been called (but will be called right after).
Note that there are no callbacks for the reassignment of edge endpoints. Thus, Graph::split
will be seen by a GraphObserver as the creation of an isolated node plus addition of a new edge to this node. Rerouting the split edge to the new node between those two callbacks will not be reported.
|
default |
Constructs instance of GraphObserver class.
|
inlineexplicit |
Constructs instance of GraphObserver class.
G | is the graph to be watched |
|
pure virtual |
Called by watched graph when its clear function is called, just before things are removed.
Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.
|
pure virtual |
Called by watched graph after an edge has been added.
Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.
|
pure virtual |
Called by watched graph just before an edge is deleted.
Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.
|
inline |
|
pure virtual |
Called by watched graph after a node has been added.
Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.
|
pure virtual |
Called by watched graph just before a node is deleted.
Implemented in ogdf::ClusterGraph, ogdf::sync_plan::PMatching, ogdf::sync_plan::QPartitioning, and ogdf::PlanRepInc.