src/hugo/map_registry.h
changeset 816 a39579c35dd7
parent 785 a9b0863c2265
child 822 88226d9fe821
equal deleted inserted replaced
2:63fa69657807 3:abdd3287f807
    23 */
    23 */
    24   template <typename G, typename K, typename KIt>
    24   template <typename G, typename K, typename KIt>
    25   class MapRegistry {
    25   class MapRegistry {
    26   public:
    26   public:
    27     typedef G Graph;
    27     typedef G Graph;
    28     typedef K Key;
    28     typedef K KeyType;
    29     typedef KIt KeyIt;
    29     typedef KIt KeyIt;
    30 	
    30 	
    31 
    31 
    32 
    32 
    33     /**
    33     /**
    36      * implements some helper functions. 
    36      * implements some helper functions. 
    37      */
    37      */
    38     class MapBase {
    38     class MapBase {
    39     public:
    39     public:
    40       typedef G Graph;
    40       typedef G Graph;
    41       typedef K Key;
    41       typedef K KeyType;
    42       typedef KIt KeyIt;
    42       typedef KIt KeyIt;
    43 
    43 
    44       typedef MapRegistry<G, K, KIt> Registry;
    44       typedef MapRegistry<G, K, KIt> Registry;
    45 	
    45 	
    46       friend class MapRegistry<G, K, KIt>;
    46       friend class MapRegistry<G, K, KIt>;
   133       /** 
   133       /** 
   134 	  The add member function should be overloaded in the subclasses.
   134 	  The add member function should be overloaded in the subclasses.
   135 	  \e Add extends the map with the new node.
   135 	  \e Add extends the map with the new node.
   136       */
   136       */
   137 	
   137 	
   138       virtual void add(const Key&) = 0;	
   138       virtual void add(const KeyType&) = 0;	
   139       /** 
   139       /** 
   140 	  The erase member function should be overloaded in the subclasses.
   140 	  The erase member function should be overloaded in the subclasses.
   141 	  \e Erase removes the node from the map.
   141 	  \e Erase removes the node from the map.
   142       */
   142       */
   143 	
   143 	
   144       virtual void erase(const Key&) = 0;
   144       virtual void erase(const KeyType&) = 0;
   145 
   145 
   146       /**
   146       /**
   147        *  The clear member function should be overloaded in the subclasses.
   147        *  The clear member function should be overloaded in the subclasses.
   148        *  \e Clear makes empty the data structure.
   148        *  \e Clear makes empty the data structure.
   149        */
   149        */
   238 	
   238 	
   239 		
   239 		
   240     /**
   240     /**
   241      * Notify all the registered maps about a Key added.
   241      * Notify all the registered maps about a Key added.
   242      */
   242      */
   243     void add(Key& key) {
   243     void add(KeyType& key) {
   244       typename Container::iterator it;
   244       typename Container::iterator it;
   245       for (it = container.begin(); it != container.end(); ++it) {
   245       for (it = container.begin(); it != container.end(); ++it) {
   246 	(*it)->add(key);
   246 	(*it)->add(key);
   247       }
   247       }
   248     }	
   248     }	
   249 		
   249 		
   250     /**
   250     /**
   251      * Notify all the registered maps about a Key erased.
   251      * Notify all the registered maps about a Key erased.
   252      */ 
   252      */ 
   253     void erase(Key& key) {
   253     void erase(KeyType& key) {
   254       typename Container::iterator it;
   254       typename Container::iterator it;
   255       for (it = container.begin(); it != container.end(); ++it) {
   255       for (it = container.begin(); it != container.end(); ++it) {
   256 	(*it)->erase(key);
   256 	(*it)->erase(key);
   257       }
   257       }
   258     }
   258     }