Open
Graph Drawing
Framework

 v. snapshot-2017-02-16
 

HypergraphObserver.h
Go to the documentation of this file.
1 
40 #pragma once
41 
42 #include <ogdf/basic/List.h>
44 
45 namespace ogdf {
46 
47 // HypergraphObserver
49 {
50  friend class Hypergraph;
51 
52 protected:
53 
56 
59 
60 public:
61 
64  : m_hypergraph(nullptr)
65  {
66  }
67 
69  explicit HypergraphObserver(const Hypergraph *pH)
70  {
71  m_hypergraph = pH;
72  m_itObserver = pH->registerObserver(this);
73  }
74 
77  {
78  if (m_hypergraph)
79  m_hypergraph->unregisterObserver(m_itObserver);
80  }
81 
83  void init(const Hypergraph *pH) {
84  if (m_hypergraph)
85  m_hypergraph->unregisterObserver(m_itObserver);
86 
87  if (pH) {
88  m_hypergraph = pH;
89  m_itObserver = pH->registerObserver(this);
90  }
91  }
92 
94  virtual void hypernodeDeleted(hypernode v) = 0;
95 
97  virtual void hypernodeAdded(hypernode v) = 0;
98 
100  virtual void hyperedgeDeleted(hyperedge e) = 0;
101 
103  virtual void hyperedgeAdded(hyperedge e) = 0;
104 
106  virtual void cleared() = 0;
107 
109  const Hypergraph * hypergraph() const
110  {
111  return m_hypergraph;
112  }
113 
114 };
115 
116 } //end namespace ogdf
#define OGDF_EXPORT
Specifies that a function or class is exported by the OGDF DLL.
Definition: config.h:99
ListIterator< HypergraphObserver * > registerObserver(HypergraphObserver *pObserver) const
Registers a hypergraph observer (e.g. a EdgeStandardRep).
void init(const Hypergraph *pH)
Associates an observer instance with hypergraph pH.
const Hypergraph * hypergraph() const
Returns the observer hypergraph.
const Hypergraph * m_hypergraph
Observed hypergraph.
Class for the representation of hypernodes.
Definition: Hypergraph.h:265
void unregisterObserver(ListIterator< HypergraphObserver *> it) const
Unregisters a hypergraph observer.
Declaration and a partial implementation of a Hypergraph class partly based on the original classes f...
Encapsulates a pointer to a list element.
Definition: List.h:41
virtual ~HypergraphObserver()
Destructor.
ListIterator< HypergraphObserver * > m_itObserver
List of all registered hypergraph observers.
Class for the representation of hyperedges.
Definition: Hypergraph.h:156
The namespace for all OGDF objects.
HypergraphObserver()
Constructor.
HypergraphObserver(const Hypergraph *pH)
Constructor assigning pH hypergraph to the observer.
Declaration of doubly linked lists and iterators.