00001 /* 00002 * $Revision: 2299 $ 00003 * 00004 * last checkin: 00005 * $Author: gutwenger $ 00006 * $Date: 2012-05-07 15:57:08 +0200 (Mon, 07 May 2012) $ 00007 ***************************************************************/ 00008 00048 #ifdef _MSC_VER 00049 #pragma once 00050 #endif 00051 00052 #ifndef OGDF_GRAPH_STRUCTURE_H 00053 #define OGDF_GRAPH_STRUCTURE_H 00054 00055 00056 #include <ogdf/basic/List.h> 00057 #include <ogdf/basic/Graph.h> 00058 00059 namespace ogdf { 00060 00061 // 00062 // in embedded graphs, adjacency lists are given in clockwise order. 00063 // 00064 00065 00066 //class Graph; 00067 //class node; 00068 //class edge; 00069 00070 00071 //---------------------------------------------------------- 00072 // GraphObserver 00073 //---------------------------------------------------------- 00084 class OGDF_EXPORT GraphObserver { 00085 friend class Graph; 00086 00087 public: 00089 GraphObserver() : m_pGraph(0) {} 00094 GraphObserver(const Graph* G) : m_pGraph(G) 00095 { 00096 m_itGList = G->registerStructure(this); 00097 }//constructor 00099 virtual ~GraphObserver() 00100 { 00101 if (m_pGraph) m_pGraph->unregisterStructure(m_itGList); 00102 }//destructor 00103 00105 void reregister(const Graph *pG) { 00106 //small speedup: check if == m_pGraph 00107 if (m_pGraph) m_pGraph->unregisterStructure(m_itGList); 00108 if ((m_pGraph = pG) != 0) m_itGList = pG->registerStructure(this); 00109 } 00110 00113 virtual void nodeDeleted(node v) = 0; 00116 virtual void nodeAdded(node v) = 0; 00119 virtual void edgeDeleted(edge e) = 0; 00122 virtual void edgeAdded(edge e) = 0; 00125 virtual void reInit() = 0; 00128 virtual void cleared() = 0; 00129 00130 const Graph* getGraph() const {return m_pGraph;} 00131 00132 protected: 00133 const Graph* m_pGraph; 00134 ListIterator<GraphObserver*> m_itGList; 00135 00136 00137 }; 00138 00139 } //end namespace ogdf 00140 00141 #endif