Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

GraphObserver.h
Go to the documentation of this file.
1 
37 #pragma once
38 
39 #include <ogdf/basic/List.h>
40 #include <ogdf/basic/Graph.h>
41 
42 namespace ogdf {
43 
44 //
45 // in embedded graphs, adjacency lists are given in clockwise order.
46 //
47 
48 
50 
58  friend class Graph;
59 
60 public:
62  GraphObserver() : m_pGraph(nullptr) { }
63 
68  explicit GraphObserver(const Graph* G) : m_pGraph(G)
69  {
70  m_itGList = G->registerStructure(this);
71  }//constructor
72 
74  virtual ~GraphObserver()
75  {
76  if (m_pGraph) m_pGraph->unregisterStructure(m_itGList);
77  }//destructor
78 
80  void reregister(const Graph *pG) {
81  //small speedup: check if == m_pGraph
82  if (m_pGraph) m_pGraph->unregisterStructure(m_itGList);
83  if ((m_pGraph = pG) != nullptr) m_itGList = pG->registerStructure(this);
84  }
85 
88  virtual void nodeDeleted(node v) = 0;
89 
92  virtual void nodeAdded(node v) = 0;
93 
96  virtual void edgeDeleted(edge e) = 0;
97 
100  virtual void edgeAdded(edge e) = 0;
101 
104  virtual void reInit() = 0;
105 
108  virtual void cleared() = 0;
109 
110  const Graph* getGraph() const { return m_pGraph; }
111 
112 protected:
113  const Graph* m_pGraph;
115 
116 
117 };
118 
119 } //end namespace ogdf
GraphObserver()
Constructs instance of GraphObserver class.
Definition: GraphObserver.h:62
Data type for general directed graphs (adjacency list representation).
Definition: Graph_d.h:472
ListIterator< GraphObserver * > registerStructure(GraphObserver *pStructure) const
Registers a graph observer (e.g. a ClusterGraph).
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
ListIterator< GraphObserver * > m_itGList
watched graph
GraphObserver(const Graph *G)
Constructs instance of GraphObserver class.
Definition: GraphObserver.h:68
const Graph * getGraph() const
const Graph * m_pGraph
void reregister(const Graph *pG)
Associates observer instance with graph G.
Definition: GraphObserver.h:80
Class for the representation of edges.
Definition: Graph_d.h:291
Class for the representation of nodes.
Definition: Graph_d.h:167
Encapsulates a pointer to a list element.
Definition: List.h:41
virtual ~GraphObserver()
Destroys the instance, unregisters it from watched graph.
Definition: GraphObserver.h:74
Includes declaration of graph class.
The namespace for all OGDF objects.
Abstract Base class for graph observers.
Definition: GraphObserver.h:57
Declaration of doubly linked lists and iterators.