COIN-OR::LEMON - Graph Library

Changeset 937:d4e911acef3d in lemon-0.x for src/lemon/map_registry.h


Ignore:
Timestamp:
10/04/04 19:13:21 (17 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1264
Message:

Revert backport changes -r1230.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/map_registry.h

    r921 r937  
    2828namespace lemon {
    2929
    30 /// \addtogroup graphmapfactory
    31 /// @{
    32 
    33 /**
    34  * Registry class to register edge or node maps into the graph. The
    35  * registry helps you to implement an observer pattern. If you add
    36  * or erase an edge or node you must notify all the maps about the
    37  * event.
    38 */
     30  /// \addtogroup graphmapfactory
     31  /// @{
     32
     33  /// Map registry for graph maps.
     34
     35  /**
     36   * Registry class to register edge or node maps into the graph. The
     37   * registry helps you to implement an observer pattern. If you add
     38   * or erase an edge or node you must notify all the maps about the
     39   * event.
     40   *
     41   * \param G The graph type to register maps.
     42   * \param K The key type of the maps registered into the registry.
     43   * \param KIt The key iterator type iterates on the keys.
     44   *
     45   * \author Balazs Dezso
     46   */
     47
    3948  template <typename G, typename K, typename KIt>
    4049  class MapRegistry {
     
    4352    typedef K KeyType;
    4453    typedef KIt KeyIt;
    45        
    46     /**
    47      * MapBase is the base class of the registered maps.
     54
     55    /// MapBase is the base class of the dynamic maps.
     56       
     57    /**
     58     * MapBase is the base class of the dynamic maps.
    4859     * It defines the core modification operations on the maps and
    4960     * implements some helper functions.
     
    5970      friend class MapRegistry<G, K, KIt>;
    6071
     72      /// Default constructor.
     73
    6174      /**
    6275       * Default constructor for MapBase.
     
    6477
    6578      MapBase() : graph(0), registry(0) {}
    66                
    67       /**
    68        * Simple constructor to register into a graph registry.
     79
     80      /// Constructor to register map into a graph registry.
     81               
     82      /**
     83       * Simple constructor to register dynamic map into a graph registry.
    6984      */
    7085       
     
    7388      }
    7489
     90      /// Copy constructor.
     91
    7592      /**
    7693       * Copy constructor to register into the registry.
     94       * If the copiable map is registered into a registry
     95       * the construated map will be registered to the same registry.
    7796      */       
    7897       
     
    82101        }
    83102      }
    84        
    85       /**
    86        * Assign operator.
     103
     104      /// Assign operator.
     105       
     106      /**
     107       * Assign operator. This member detach first the map
     108       * from the current registry and then it attach to the
     109       * copiable map's registry if it exists.
    87110      */       
    88111      const MapBase& operator=(const MapBase& copy) {
     
    97120      }
    98121       
    99 
    100       /**
    101        * Destructor.
     122      /// Destructor
     123
     124      /**
     125       * This member detach the map from the its registry if the
     126       * registry exists.
    102127      */               
    103128
     
    108133      }
    109134
     135      /// The graph of the map.
     136
    110137      /*
    111138       * Returns the graph that the map belongs to.
     
    122149
    123150    protected:
    124        
    125       /**
    126          Helper function to implement constructors in the subclasses.
     151
     152      /// Helper function to implement constructors in the subclasses.
     153       
     154      /**
     155       * Helper function to implement constructors in the subclasses.
     156       * It adds all of the nodes or edges to the map via the
     157       * \ref MapRegistry::MapBase::add add
     158       * member function.
    127159      */
    128160       
     
    133165      }
    134166       
    135       /**
    136          Helper function to implement the destructor in the subclasses.
     167
     168      /// Helper function to implement destructors in the subclasses.
     169       
     170      /**
     171       * Helper function to implement destructors in the subclasses.
     172       * It erases all of the nodes or edges of the map via the
     173       * \ref MapRegistry::MapBase::erase erase
     174       * member function. It can be used by the clear function also.
    137175      */
    138176       
     
    142180        }
    143181      }
     182
     183      /// The member function to add new node or edge to the map.
    144184       
    145185      /**
    146186          The add member function should be overloaded in the subclasses.
    147           \e Add extends the map with the new node.
     187          \e Add extends the map with the new node or edge.
    148188      */
    149189       
    150190      virtual void add(const KeyType&) = 0;     
     191
     192
     193      /// The member function to erase a node or edge from the map.
     194
    151195      /**
    152196          The erase member function should be overloaded in the subclasses.
    153           \e Erase removes the node from the map.
     197          \e Erase removes the node or edge from the map.
    154198      */
    155199       
     
    162206
    163207      virtual void clear() = 0;
    164        
    165       /**
    166          Exception class to throw at unsupported operation.
     208
     209      /// Exception class to throw at unsupported operation.
     210       
     211      /**
     212       * Exception class to throw at unsupported operation.
     213       * If the map does not support erasing or adding new
     214       * node or key it must be throwed.
    167215      */
    168216       
     
    173221  protected:
    174222       
    175     /**
    176      * The container type of the maps.
    177      */
     223
    178224    typedef std::vector<MapBase*> Container;
    179225
    180     /**
    181      * The container of the registered maps.
    182      */
    183226    Container container;
    184227
    185228               
    186229  public:
    187        
    188     /**
    189      * Default Constructor of the MapRegistry. It creates an empty registry.
     230
     231    /// Default constructor.
     232       
     233    /**
     234     * Default constructor of the \e MapRegistry.
     235     * It creates an empty registry.
    190236     */
    191237    MapRegistry() {}
    192        
    193     /**
    194      * Copy Constructor of the MapRegistry. The new registry does not steal
    195      * the maps from the right value. The new registry will be an empty.
     238
     239    /// Copy Constructor of the MapRegistry.
     240       
     241    /**
     242     * Copy constructor of the \e MapRegistry.
     243     * The new registry does not steal
     244     * the maps from the copiable registry.
     245     * The new registry will be empty.
    196246     */
    197247    MapRegistry(const MapRegistry&) {}
    198                
    199     /**
    200      * Assign operator. The left value does not steal the maps
    201      * from the right value. The left value will be an empty registry.
     248
     249    /// Assign operator.
     250               
     251    /**
     252     * Assign operator. This registry does not steal the maps
     253     * from the copiable registry. This registry will be an empty registry.
     254     * This operator will be called when a graph is assigned.
    202255     */
    203256    MapRegistry& operator=(const MapRegistry&) {
    204257      typename Container::iterator it;
    205258      for (it = container.begin(); it != container.end(); ++it) {
    206         (*it)->destroy();
     259        (*it)->clear();
    207260        (*it)->graph = 0;
    208261        (*it)->registry = 0;
    209262      }
    210263    }
     264
     265    /// Destructor.
    211266                               
    212267    /**
    213      * Destructor of the MapRegistry.
     268     * Destructor of the MapRegistry. It makes empty the attached map
     269     * first then detachs them.
    214270     */
    215271    ~MapRegistry() {
    216272      typename Container::iterator it;
    217273      for (it = container.begin(); it != container.end(); ++it) {
    218         (*it)->destroy();
     274        (*it)->clear();
    219275        (*it)->registry = 0;
    220276        (*it)->graph = 0;
     
    224280       
    225281    public:
    226        
    227     /**
    228      * Attach a map into thr registry. If the map has been attached
     282
     283    /// Attachs a map to the \e MapRegistry.
     284       
     285    /**
     286     * Attachs a map into thr registry. If the map has been attached
    229287     * into an other registry it is detached from that automaticly.
    230288     */
     
    237295      map.registry_index = container.size()-1;
    238296    }
    239        
    240     /**
    241      * Detach the map from the registry.
     297
     298    /// Detachs a map from the \e MapRegistry.
     299       
     300    /**
     301     * Detachs a map from the \e MapRegistry.
    242302     */
    243303    void detach(MapBase& map) {
     
    249309    }
    250310       
     311    /// Notify all the registered maps about a Key added.
    251312               
    252313    /**
    253314     * Notify all the registered maps about a Key added.
    254      */
    255     void add(KeyType& key) {
     315     * This member should be called whenever a node or edge
     316     * is added to the graph.
     317     */
     318    void add(const KeyType& key) {
    256319      typename Container::iterator it;
    257320      for (it = container.begin(); it != container.end(); ++it) {
     
    259322      }
    260323    }   
     324
     325    /// Notify all the registered maps about a Key erased.
    261326               
    262327    /**
    263328     * Notify all the registered maps about a Key erased.
     329     * This member should be called whenever a node or edge
     330     * is erased from the graph.
    264331     */
    265     void erase(KeyType& key) {
     332    void erase(const KeyType& key) {
    266333      typename Container::iterator it;
    267334      for (it = container.begin(); it != container.end(); ++it) {
     
    270337    }
    271338
     339
     340    /// Notify all the registered maps about all the Keys are erased.
     341
    272342    /**
    273343     * Notify all the registered maps about the map should be cleared.
     344     * This member should be called whenever all of the nodes or edges
     345     * are erased from the graph.
    274346     */
    275347    void clear() {
Note: See TracChangeset for help on using the changeset viewer.