Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

ClusterGraphObserver.h
Go to the documentation of this file.
1 
37 #pragma once
38 
39 #include <ogdf/basic/List.h>
41 
42 namespace ogdf {
43 
54  friend class ClusterGraph;
55 
56 public:
57  ClusterGraphObserver() : m_pClusterGraph(nullptr) {}
58 
59  explicit ClusterGraphObserver(const ClusterGraph* CG) : m_pClusterGraph(CG)
60  {
61  m_itCGList = CG->registerObserver(this);
62  }//constructor
63 
65  {
66  if (m_pClusterGraph) m_pClusterGraph->unregisterObserver(m_itCGList);
67  }//destructor
68 
69  // associates structure with different graph
70  void reregister(const ClusterGraph *pCG) {
71  //small speedup: check if == m_pGraph
72  if (m_pClusterGraph) m_pClusterGraph->unregisterObserver(m_itCGList);
73  if ((m_pClusterGraph = pCG) != nullptr) m_itCGList = pCG->registerObserver(this);
74  }
75 
76  virtual void clusterDeleted(cluster v) = 0;
77  virtual void clusterAdded(cluster v) = 0;
78 #if 0
79  virtual void reInit() = 0;
80  virtual void cleared() = 0;//Graph cleared
81 #endif
82 
83  const ClusterGraph* getGraph() const { return m_pClusterGraph;}
84 
85 protected:
86  const ClusterGraph* m_pClusterGraph; //underlying clustergraph
87 
88  //List entry in cluster graphs list of all registered observers
90 };
91 
92 } // end of namespace
ListIterator< ClusterGraphObserver * > m_itCGList
ListIterator< ClusterGraphObserver * > registerObserver(ClusterGraphObserver *pObserver) const
Registers a cluster graph observer.
Derived class of GraphObserver providing additional functionality to handle clustered graphs...
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
const ClusterGraph * m_pClusterGraph
ClusterGraphObserver(const ClusterGraph *CG)
Representation of clustered graphs.
Definition: ClusterGraph.h:291
Encapsulates a pointer to a list element.
Definition: List.h:41
void reregister(const ClusterGraph *pCG)
Representation of clusters in a clustered graph.
Definition: ClusterGraph.h:53
Abstract base class for cluster graph observers.
const ClusterGraph * getGraph() const
The namespace for all OGDF objects.
Declaration of doubly linked lists and iterators.