1 #ifndef EDGE_MAP_BASE_H
2 #define EDGE_MAP_BASE_H
5 Template base class for implementing mapping on edges.
6 \param The first template parameter is the Graph class. The Graph
7 must have an \emp edge_maps member with \emp EdgeMapRegistry class.
8 \param The second template parameter is the Edge type of the class.
12 template <typename G, typename K>
23 EdgeMapBase() : graph(0) {}
26 Simple constructor to register into a graph.
29 EdgeMapBase(Graph& g) : graph(&g) {
30 graph->edge_maps.add(*this);
34 Copy constructor with registering into the map.
37 EdgeMapBase(const EdgeMapBase& copy) : graph(copy.graph) {
39 graph->edge_maps.add(*this);
47 const EdgeMapBase& operator=(const EdgeMapBase& copy) {
49 graph.edge_maps.erase(*this);
53 graph->edge_maps.add(*this);
63 virtual ~EdgeMapBase() {
65 graph.edge_maps.erase(*this);
76 Helper function to implement the default constructor in the subclasses.
80 for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
86 Helper function to implement the destructor in the subclasses.
90 for (Graph::EdgeIt it(g); g.valid(it); g.next(it)) {
96 The add member function should be overloaded in the subclasses.
97 \e Add extends the map with the new edge.
100 virtual void add(const KeyType&) = 0;
103 The erase member function should be overloaded in the subclasses.
104 \e Erase removes the edge from the map.
107 virtual void erase(const KeyType&) = 0;
110 Exception class to throw at unsupported operation.
113 class NotSupportedOperationException {};