src/work/deba/map_base.h
changeset 627 6cc21a9c9fda
parent 626 0015642b0990
child 628 a3a53d7cedc2
     1.1 --- a/src/work/deba/map_base.h	Wed May 12 14:07:00 2004 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,133 +0,0 @@
     1.4 -#ifndef MAP_BASE_H
     1.5 -#define MAP_BASE_H
     1.6 -
     1.7 -using namespace std;
     1.8 -
     1.9 -/**
    1.10 -	Template base class for implementing mapping on nodes and edges.
    1.11 -	\param The first template parameter is the Graph class.
    1.12 -	\param The second template parameter is the key type.
    1.13 -	\param The third template parameter is an iterator on
    1.14 -		the keys.
    1.15 -*/
    1.16 -
    1.17 -
    1.18 -namespace hugo {
    1.19 -	template <typename G, typename K, typename KIt>
    1.20 -	class MapBase;
    1.21 -}
    1.22 -
    1.23 -#include "map_registry.h"
    1.24 -
    1.25 -namespace hugo {
    1.26 -
    1.27 -	template <typename G, typename K, typename KIt>
    1.28 -	class MapBase {
    1.29 -	public:
    1.30 -		typedef G Graph;
    1.31 -		typedef MapRegistry<G, K, KIt> Registry;
    1.32 -		typedef K Key;
    1.33 -		typedef KIt KeyIt;
    1.34 -	
    1.35 -		friend class Registry;
    1.36 -		
    1.37 -		/** 
    1.38 -			Default constructor.
    1.39 -		*/	
    1.40 -		
    1.41 -		MapBase() : graph(0), registry(0) {}
    1.42 -
    1.43 -		/** 
    1.44 -			Simple constructor to register into a graph registry.
    1.45 -		*/
    1.46 -	
    1.47 -		MapBase(Graph& g, Registry& r) : graph(&g), registry(0) {
    1.48 -			r.attach(*this);
    1.49 -		}
    1.50 -
    1.51 -		/** 
    1.52 -			Copy constructor with registering into the map.
    1.53 -		*/	
    1.54 -	
    1.55 -		MapBase(const MapBase& copy) : registry(0), graph(copy.graph) {
    1.56 -			if (copy.registry) {
    1.57 -				copy.registry->attach(*this);
    1.58 -			}
    1.59 -		} 
    1.60 -	
    1.61 -		/** 
    1.62 -			Assign operator.
    1.63 -		*/	
    1.64 -
    1.65 -		const MapBase& operator=(const MapBase& copy) {
    1.66 -			if (registry) {
    1.67 -				registry->detach(*this);
    1.68 -			}
    1.69 -			graph = copy.graph;
    1.70 -			if (copy.registry) {
    1.71 -				copy.registry->attach(*this);
    1.72 -			}
    1.73 -		}
    1.74 -	
    1.75 -
    1.76 -		/** 
    1.77 -			Destructor.
    1.78 -		*/		
    1.79 -
    1.80 -		virtual ~MapBase() {
    1.81 -			if (registry) {
    1.82 -				registry->detach(*this);
    1.83 -			}
    1.84 -		}
    1.85 -	
    1.86 -	protected:
    1.87 -		
    1.88 -		Graph* graph;
    1.89 -		Registry* registry;
    1.90 -
    1.91 -		int registry_index;
    1.92 -	
    1.93 -		/**
    1.94 -			Helper function to implement constructors in the subclasses.
    1.95 -		*/
    1.96 -	
    1.97 -		virtual void init() {
    1.98 -			for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
    1.99 -				add(it);
   1.100 -			}
   1.101 -		}
   1.102 -	
   1.103 -		/**
   1.104 -			Helper function to implement the destructor in the subclasses.
   1.105 -		*/
   1.106 -	
   1.107 -		virtual void destroy() {
   1.108 -			for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
   1.109 -				erase(it);
   1.110 -			}
   1.111 -		}
   1.112 -	
   1.113 -		/** 
   1.114 -			The add member function should be overloaded in the subclasses.
   1.115 -			\e Add extends the map with the new node.
   1.116 -		*/
   1.117 -	
   1.118 -		virtual void add(const Key&) = 0;	
   1.119 -		/** 
   1.120 -			The erase member function should be overloaded in the subclasses.
   1.121 -			\e Erase removes the node from the map.
   1.122 -		*/
   1.123 -	
   1.124 -		virtual void erase(const Key&) = 0;
   1.125 -	
   1.126 -		/**
   1.127 -			Exception class to throw at unsupported operation.
   1.128 -		*/
   1.129 -	
   1.130 -		class NotSupportedOperationException {};
   1.131 -
   1.132 -	};
   1.133 -	
   1.134 -}
   1.135 -
   1.136 -#endif