1 #ifndef NODE_MAP_BASE_H
2 #define NODE_MAP_BASE_H
5 Template base class for implementing mapping on nodes.
6 \param The first template parameter is the Graph class. The Graph
7 must have an \emp node_maps member with \emp NodeMapRegistry class.
8 \param The second template parameter is the Node type of the class.
12 template <typename G, typename K>
15 #include "node_map_registry.h"
19 friend class NodeMapRegistry<G, K>;
27 NodeMapBase() : graph(0) {}
30 Simple constructor to register into a graph.
33 NodeMapBase(Graph& g) : graph(&g) {
34 graph->node_maps.add(*this);
38 Copy constructor with registering into the map.
41 NodeMapBase(const NodeMapBase& copy) : graph(copy.graph) {
43 graph->node_maps.add(*this);
51 const NodeMapBase& operator=(const NodeMapBase& copy) {
53 graph.node_maps.erase(*this);
57 graph->node_maps.add(*this);
67 virtual ~NodeMapBase() {
69 graph->node_maps.erase(*this);
80 Helper function to implement the default constructor in the subclasses.
84 for (typename Graph::NodeIt it(g); g.valid(it); g.next(it)) {
90 Helper function to implement the destructor in the subclasses.
94 for (typename Graph::NodeIt it(g); g.valid(it); g.next(it)) {
100 The add member function should be overloaded in the subclasses.
101 \e Add extends the map with the new node.
104 virtual void add(const KeyType&) = 0;
107 The erase member function should be overloaded in the subclasses.
108 \e Erase removes the node from the map.
111 virtual void erase(const KeyType&) = 0;
114 Exception class to throw at unsupported operation.
117 class NotSupportedOperationException {};