src/lemon/alteration_observer_registry.h
changeset 971 643d3192ebc8
parent 946 c94ef40a22ce
child 978 175cf8c3a994
equal deleted inserted replaced
0:9420d09ded3d 1:6b8d6a9e1efa
   276       }
   276       }
   277     }
   277     }
   278   };
   278   };
   279 
   279 
   280 
   280 
   281   /// Class to extend a graph functionality with the possibility of alteration observing.
   281   /// \brief Class to extend a graph with the functionality of alteration
   282 
   282   /// observing.
   283   /// AlterableGraphExtender extends the _Base graphs functionality with the possibility of 
   283   ///
   284   /// alteration observing. It defines two observer registrys for the nodes and mapes.
   284   /// AlterableGraphExtender extends the _Base graphs functionality with
       
   285   /// the possibility of alteration observing. It defines two observer
       
   286   /// registrys for the nodes and mapes.
       
   287   /// 
       
   288   /// \todo Document what "alteration observing" is. And probably find a
       
   289   /// better (shorter) name.
   285   ///
   290   ///
   286   /// \param _Base is the base class to extend.
   291   /// \param _Base is the base class to extend.
   287   ///
   292   ///
   288   /// \pre _Base is conform to the BaseGraphComponent concept.
   293   /// \pre _Base is conform to the BaseGraphComponent concept.
   289   ///
   294   ///
   290   /// \post AlterableGraphExtender<_Base> is conform to the AlterableGraphComponent concept.
   295   /// \post AlterableGraphExtender<_Base> is conform to the
       
   296   /// AlterableGraphComponent concept.
   291   ///
   297   ///
   292   /// \author Balazs Dezso
   298   /// \author Balazs Dezso
   293 
   299 
   294   template <typename _Base> 
   300   template <typename _Base> 
   295   class AlterableGraphExtender : public _Base {
   301   class AlterableGraphExtender : public _Base {
   299     typedef _Base Parent;
   305     typedef _Base Parent;
   300 
   306 
   301     typedef typename Parent::Node Node;
   307     typedef typename Parent::Node Node;
   302     typedef typename Parent::Edge Edge;
   308     typedef typename Parent::Edge Edge;
   303 
   309 
       
   310     /// The edge observer registry.
       
   311     typedef AlterationObserverRegistry<Edge> EdgeObserverRegistry;
   304     /// The node observer registry.
   312     /// The node observer registry.
   305     typedef AlterationObserverRegistry<Edge> EdgeObserverRegistry;
       
   306     /// The edge observer registry.
       
   307     typedef AlterationObserverRegistry<Node> NodeObserverRegistry;
   313     typedef AlterationObserverRegistry<Node> NodeObserverRegistry;
   308 
   314 
   309 
   315 
   310   protected:
   316   protected:
   311 
   317 
   328       edge_observers.clear();
   334       edge_observers.clear();
   329     }
   335     }
   330     
   336     
   331   };
   337   };
   332 
   338 
       
   339   /// \brief Class to extend an undirected graph with the functionality of
       
   340   /// alteration observing.
       
   341   ///
       
   342   /// \todo Document.
       
   343   ///
       
   344   /// \sa AlterableGraphExtender
       
   345   ///
       
   346   /// \bug This should be done some other way. Possibilities: template
       
   347   /// specialization (not very easy, if at all possible); some kind of
       
   348   /// enable_if boost technique?
       
   349 
       
   350   template <typename _Base> 
       
   351   class AlterableUndirGraphExtender
       
   352     : public AlterableGraphExtender<_Base> {
       
   353   public:
       
   354 
       
   355     typedef AlterableUndirGraphExtender Graph;
       
   356     typedef AlterableGraphExtender<_Base> Parent;
       
   357 
       
   358     typedef typename Parent::UndirEdge UndirEdge;
       
   359 
       
   360     /// The edge observer registry.
       
   361     typedef AlterationObserverRegistry<UndirEdge> UndirEdgeObserverRegistry;
       
   362 
       
   363   protected:
       
   364 
       
   365     mutable UndirEdgeObserverRegistry undir_edge_observers;
       
   366 
       
   367     UndirEdgeObserverRegistry& getUndirEdgeObserverRegistry() const {
       
   368       return undir_edge_observers;
       
   369     }
       
   370 
       
   371     ~AlterableUndirGraphExtender() {
       
   372       undir_edge_observers.clear();
       
   373     }
       
   374   };
   333   
   375   
   334 /// @}
   376 /// @}
   335   
   377   
   336 
   378 
   337 }
   379 }