src/work/deba/node_map_base.h
changeset 377 33fe0ee01dc5
parent 340 a2ce3c4780b7
equal deleted inserted replaced
2:9e44531ef926 3:43f859e9d9e8
     9 	
     9 	
    10 */
    10 */
    11 
    11 
    12 template <typename G, typename K>
    12 template <typename G, typename K>
    13 class NodeMapBase {
    13 class NodeMapBase {
       
    14 
       
    15 #include "node_map_registry.h"
       
    16 
    14 public:
    17 public:
    15 	typedef G Graph;
    18 	typedef G Graph;
       
    19 	friend class NodeMapRegistry<G, K>;
    16 
    20 
    17 	typedef K KeyType;
    21 	typedef K KeyType;
    18 	
    22 	
    19 	/** 
    23 	/** 
    20 		Default constructor.
    24 		Default constructor.
    60 		Destructor.
    64 		Destructor.
    61 	*/	
    65 	*/	
    62 
    66 
    63 	virtual ~NodeMapBase() {
    67 	virtual ~NodeMapBase() {
    64 		if (graph) {
    68 		if (graph) {
    65 			graph.node_maps.erase(*this);
    69 			graph->node_maps.erase(*this);
    66 		}
    70 		}
    67 	}
    71 	}
    68 	
    72 	
    69 protected:
    73 protected:
    70 	
    74 	
    75 	/**
    79 	/**
    76 		Helper function to implement the default constructor in the subclasses.
    80 		Helper function to implement the default constructor in the subclasses.
    77 	*/
    81 	*/
    78 	
    82 	
    79 	void init() {
    83 	void init() {
    80 		for (Graph::NodeIt it(g); g.valid(it); g.next(it)) {
    84 		for (typename Graph::NodeIt it(g); g.valid(it); g.next(it)) {
    81 			add(it);
    85 			add(it);
    82 		}
    86 		}
    83 	}
    87 	}
    84 	
    88 	
    85 	/**
    89 	/**
    86 		Helper function to implement the destructor in the subclasses.
    90 		Helper function to implement the destructor in the subclasses.
    87 	*/
    91 	*/
    88 	
    92 	
    89 	void destroy() {
    93 	void destroy() {
    90 		for (Graph::NodeIt it(g); g.valid(it); g.next(it)) {
    94 		for (typename Graph::NodeIt it(g); g.valid(it); g.next(it)) {
    91 			erase(it);
    95 			erase(it);
    92 		}
    96 		}
    93 	}
    97 	}
    94 	
    98 	
    95 	/** 
    99 	/** 
   110 		Exception class to throw at unsupported operation.
   114 		Exception class to throw at unsupported operation.
   111 	*/
   115 	*/
   112 	
   116 	
   113 	class NotSupportedOperationException {};
   117 	class NotSupportedOperationException {};
   114 
   118 
   115 	friend class Graph;
       
   116 };
   119 };
   117 
   120 
   118 #endif
   121 #endif