COIN-OR::LEMON - Graph Library

Changeset 701:c03e073b8394 in lemon-0.x for src/work/deba/map_registry.h


Ignore:
Timestamp:
07/14/04 12:06:27 (18 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@952
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/work/deba/map_registry.h

    r676 r701  
    99
    1010/**
    11     Registry class to register edge or node maps in the graph. The
    12    registry helps you to implement an observer pattern. If you add
    13    or erase an edge or node you must notify all the maps about the
    14    event.
     11 * Registry class to register edge or node maps into the graph. The
     12 * registry helps you to implement an observer pattern. If you add
     13 * or erase an edge or node you must notify all the maps about the
     14 * event.
    1515*/
    1616  template <typename G, typename K, typename KIt>
     
    2323
    2424
    25     ///.
    26 
    27     ///.
    28     ///
     25    /**
     26     * MapBase is the base class of the registered maps.
     27     * It defines the core modification operations on the maps and
     28     * implements some helper functions.
     29     */
    2930    class MapBase {
    3031    public:
     
    3536       
    3637      friend class Registry;
    37                
    38       /** 
    39           Default constructor.
    40       */       
    41                
     38
     39      /**
     40       * Default constructor for MapBase.
     41       */
     42
    4243      MapBase() : graph(0), registry(0) {}
    43 
    44       /**
    45           Simple constructor to register into a graph registry.
    46       */
    47        
    48       MapBase(Graph& g, Registry& r) : graph(&g), registry(0) {
     44               
     45      /**
     46       * Simple constructor to register into a graph registry.
     47      */
     48       
     49      MapBase(const Graph& g, Registry& r) : graph(&g), registry(0) {
    4950        r.attach(*this);
    5051      }
    5152
    5253      /**
    53           Copy constructor with registering into the map.
     54       * Copy constructor to register into the registry.
    5455      */       
    5556       
     
    6162       
    6263      /**
    63           Assign operator.
     64       * Assign operator.
    6465      */       
    6566
     
    7677
    7778      /**
    78           Destructor.
     79       * Destructor.
    7980      */               
    8081
     
    8485        }
    8586      }
    86        
     87
     88      /*
     89       * Returns the graph that the map belongs to.
     90      */
     91
     92      const Graph* getGraph() const { return graph; }
     93       
     94    private:
     95               
     96      const Graph* graph;
     97      Registry* registry;
     98
     99      int registry_index;
     100
    87101    protected:
    88                
    89       Graph* graph;
    90       Registry* registry;
    91 
    92       int registry_index;
    93102       
    94103      /**
     
    107116       
    108117      virtual void destroy() {
    109         for (KeyIt it(*graph); graph->valid(it); graph->next(it)) {
     118        for (KeyIt it(*getGraph()); getGraph()->valid(it); getGraph()->next(it)) {
    110119          erase(it);
    111120        }
     
    135144  protected:
    136145       
     146    /**
     147     * The container type of the maps.
     148     */
    137149    typedef std::vector<MapBase*> Container;
     150
     151    /**
     152     * The container of the registered maps.
     153     */
    138154    Container container;
    139155
    140156               
    141     public:
    142        
    143     ///.
     157  public:
     158       
     159    /**
     160     * Default Constructor of the MapRegistry. It creates an empty registry.
     161     */
    144162    MapRegistry() {}
    145163       
    146     ///.
     164    /**
     165     * Copy Constructor of the MapRegistry. The new registry does not steal
     166     * the maps from the right value. The new registry will be an empty.
     167     */
    147168    MapRegistry(const MapRegistry&) {}
    148169               
    149     ///.
     170    /**
     171     * Assign operator. The left value does not steal the maps
     172     * from the right value. The left value will be an empty registry.
     173     */
    150174    MapRegistry& operator=(const MapRegistry&) {
    151175      for (it = container.begin(); it != container.end(); ++it) {
     
    156180    }
    157181                               
    158     ///.
     182    /**
     183     * Destructor of the MapRegistry.
     184     */
    159185    ~MapRegistry() {
    160186      typename Container::iterator it;
     
    169195    public:
    170196       
    171     ///.
     197    /**
     198     * Attach a map into thr registry. If the map has been attached
     199     * into an other registry it is detached from that automaticly.
     200     */
    172201    void attach(MapBase& map) {
    173202      if (map.registry) {
     
    179208    }
    180209       
    181     ///.
     210    /**
     211     * Detach the map from the registry.
     212     */
    182213    void detach(MapBase& map) {
    183214      container.back()->registry_index = map.registry_index;
     
    189220       
    190221               
    191     ///.
     222    /**
     223     * Notify all the registered maps about a Key added.
     224     */
    192225    virtual void add(Key& key) {
    193226      typename Container::iterator it;
     
    197230    }   
    198231               
    199     ///.
     232    /**
     233     * Notify all the registered maps about a Key erased.
     234     */
    200235    virtual void erase(Key& key) {
    201236      typename Container::iterator it;
Note: See TracChangeset for help on using the changeset viewer.