Open
Graph Drawing
Framework

 v.2012.07
 

GraphObserver.h
Go to the documentation of this file.
1 /*
2  * $Revision: 2615 $
3  *
4  * last checkin:
5  * $Author: gutwenger $
6  * $Date: 2012-07-16 14:23:36 +0200 (Mo, 16. Jul 2012) $
7  ***************************************************************/
8 
49 #ifdef _MSC_VER
50 #pragma once
51 #endif
52 
53 #ifndef OGDF_GRAPH_STRUCTURE_H
54 #define OGDF_GRAPH_STRUCTURE_H
55 
56 
57 #include <ogdf/basic/List.h>
58 #include <ogdf/basic/Graph.h>
59 
60 namespace ogdf {
61 
62 //
63 // in embedded graphs, adjacency lists are given in clockwise order.
64 //
65 
66 
67 //----------------------------------------------------------
68 // GraphObserver
69 //----------------------------------------------------------
81  friend class Graph;
82 
83 public:
85  GraphObserver() : m_pGraph(0) { }
86 
91  GraphObserver(const Graph* G) : m_pGraph(G)
92  {
93  m_itGList = G->registerStructure(this);
94  }//constructor
95 
97  virtual ~GraphObserver()
98  {
99  if (m_pGraph) m_pGraph->unregisterStructure(m_itGList);
100  }//destructor
101 
103  void reregister(const Graph *pG) {
104  //small speedup: check if == m_pGraph
105  if (m_pGraph) m_pGraph->unregisterStructure(m_itGList);
106  if ((m_pGraph = pG) != 0) m_itGList = pG->registerStructure(this);
107  }
108 
111  virtual void nodeDeleted(node v) = 0;
112 
115  virtual void nodeAdded(node v) = 0;
116 
119  virtual void edgeDeleted(edge e) = 0;
120 
123  virtual void edgeAdded(edge e) = 0;
124 
127  virtual void reInit() = 0;
128 
131  virtual void cleared() = 0;
132 
133  const Graph* getGraph() const { return m_pGraph; }
134 
135 protected:
136  const Graph* m_pGraph;
138 
139 
140 };
141 
142 } //end namespace ogdf
143 
144 #endif