Loading [MathJax]/extensions/tex2jax.js

Open
Graph Drawing
Framework

 v. 2023.09 (Elderberry)
 

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
GraphObserver.h
Go to the documentation of this file.
1
37#pragma once
38
39#include <ogdf/basic/Graph.h>
40#include <ogdf/basic/List.h>
41
42namespace ogdf {
43
44//
45// in embedded graphs, adjacency lists are given in clockwise order.
46//
47
48
50
58 friend class Graph;
59
60public:
62 GraphObserver() : m_pGraph(nullptr) { }
63
68 explicit GraphObserver(const Graph* G) : m_pGraph(G) { m_itGList = G->registerStructure(this); }
69
71 virtual ~GraphObserver() {
72 if (m_pGraph) {
73 m_pGraph->unregisterStructure(m_itGList);
74 }
75 }
76
78 void reregister(const Graph* pG) {
79 //small speedup: check if == m_pGraph
80 if (m_pGraph) {
81 m_pGraph->unregisterStructure(m_itGList);
82 }
83 if ((m_pGraph = pG) != nullptr) {
84 m_itGList = pG->registerStructure(this);
85 }
86 }
87
90 virtual void nodeDeleted(node v) = 0;
91
94 virtual void nodeAdded(node v) = 0;
95
98 virtual void edgeDeleted(edge e) = 0;
99
102 virtual void edgeAdded(edge e) = 0;
103
106 virtual void cleared() = 0;
107
108 const Graph* getGraph() const { return m_pGraph; }
109
110protected:
113};
114
115}
Includes declaration of graph class.
Declaration of doubly linked lists and iterators.
Class for the representation of edges.
Definition Graph_d.h:300
Data type for general directed graphs (adjacency list representation).
Definition Graph_d.h:521
Abstract Base class for graph observers.
virtual ~GraphObserver()
Destroys the instance, unregisters it from watched graph.
const Graph * getGraph() const
virtual void edgeDeleted(edge e)=0
Called by watched graph when an edge is deleted Has to be implemented by derived classes.
void reregister(const Graph *pG)
Associates observer instance with graph G.
ListIterator< GraphObserver * > m_itGList
watched graph
const Graph * m_pGraph
virtual void nodeDeleted(node v)=0
Called by watched graph when a node is deleted Has to be implemented by derived classes.
virtual void edgeAdded(edge e)=0
Called by watched graph when an edge is added Has to be implemented by derived classes.
virtual void nodeAdded(node v)=0
Called by watched graph when a node is added Has to be implemented by derived classes.
virtual void cleared()=0
Called by watched graph when its clear function is called Has to be implemented by derived classes.
GraphObserver(const Graph *G)
Constructs instance of GraphObserver class.
GraphObserver()
Constructs instance of GraphObserver class.
Encapsulates a pointer to a list element.
Definition List.h:103
Class for the representation of nodes.
Definition Graph_d.h:177
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition config.h:101
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.