AlterationNotifier< _Container, _Item > Class Template Reference
[Tools for Graph Implementation]


Detailed Description

template<typename _Container, typename _Item>
class lemon::AlterationNotifier< _Container, _Item >

The simple graph's can be refered as two containers, one node container and one edge container. But they are not standard containers they does not store values directly they are just key continars for more value containers which are the node and edge maps.

The graph's node and edge sets can be changed as we add or erase nodes and edges in the graph. Lemon would like to handle easily that the node and edge maps should contain values for all nodes or edges. If we want to check on every indicing if the map contains the current indicing key that cause a drawback in the performance in the library. We use another solution we notify all maps about an alteration in the graph, which cause only drawback on the alteration of the graph.

This class provides an interface to the container. The first() and next() member functions make possible to iterate on the keys of the container. The id() function returns an integer id for each key. The maxId() function gives back an upper bound of the ids.

For the proper functonality of this class, we should notify it about each alteration in the container. The alterations have four type as add(), erase(), build() and clear(). The add() and erase() signals that only one or few items added or erased to or from the graph. If all items are erased from the graph or from an empty graph a new graph is builded then it can be signaled with the clear() and build() members. Important rule that if we erase items from graph we should first signal the alteration and after that erase them from the container, on the other way on item addition we should first extend the container and just after that signal the alteration.

The alteration can be observed with a class inherited from the ObserverBase nested class. The signals can be handled with overriding the virtual functions defined in the base class. The observer base can be attached to the notifier with the attach() member and can be detached with detach() function. The alteration handlers should not call any function which signals an other alteration in the same notifier and should not detach any observer from the notifier.

Alteration observers try to be exception safe. If an add() or a clear() function throws an exception then the remaining observeres will not be notified and the fulfilled additions will be rolled back by calling the erase() or clear() functions. Thence the erase() and clear() should not throw exception. Actullay, it can be throw only AlterationObserver::ImmediateDetach ImmediateDetach exception which detach the observer from the notifier.

There are some place when the alteration observing is not completly reliable. If we want to carry out the node degree in the graph as in the InDegMap and we use the reverseEdge that cause unreliable functionality. Because the alteration observing signals only erasing and adding but not the reversing it will stores bad degrees. The sub graph adaptors cannot signal the alterations because just a setting in the filter map can modify the graph and this cannot be watched in any way.

Parameters:
_Container The container which is observed.
_Item The item type which is obserbved.
Author:
Balazs Dezso
#include <lemon/bits/alteration_notifier.h>

List of all members.

Classes

struct  ImmediateDetach
 Exception which can be called from clear() and erase(). More...
class  ObserverBase
 ObserverBase is the base class for the observers. More...

Public Member Functions

 AlterationNotifier ()
 Default constructor.
 AlterationNotifier (const Container &_container)
 Constructor.
 AlterationNotifier (const AlterationNotifier &_notifier)
 Copy Constructor of the AlterationNotifier.
 ~AlterationNotifier ()
 Destructor.
void setContainer (const Container &_container)
void first (Item &item) const
 First item in the container.
void next (Item &item) const
 Next item in the container.
int id (const Item &item) const
 Returns the id of the item.
int maxId () const
void add (const Item &item)
 Notifies all the registed observers about an item added to the container.
void add (const std::vector< Item > &items)
 Notifies all the registed observers about more item added to the container.
void erase (const Item &item) throw ()
 Notifies all the registed observers about an item erased from the container.
void erase (const std::vector< Item > &items)
 Notifies all the registed observers about more item erased from the container.
void build ()
 Notifies all the registed observers about the container is built.
void clear ()
 Notifies all the registed observers about all items are erased.


Constructor & Destructor Documentation

AlterationNotifier (  )  [inline]

The default constructor of the AlterationNotifier. It creates an empty notifier.

AlterationNotifier ( const Container &  _container  )  [inline]

Constructor with the observed container parameter.

AlterationNotifier ( const AlterationNotifier< _Container, _Item > &  _notifier  )  [inline]

Copy constructor of the AlterationNotifier. It creates only an empty notifier because the copiable notifier's observers have to be registered still into that notifier.

~AlterationNotifier (  )  [inline]

Destructor of the AlterationNotifier.


Member Function Documentation

void setContainer ( const Container &  _container  )  [inline]

Sets the container.

void first ( Item &  item  )  const [inline]

Returns the first item in the container. It is for start the iteration on the container.

void next ( Item &  item  )  const [inline]

Returns the next item in the container. It is for iterate on the container.

int id ( const Item &  item  )  const [inline]

Returns the id of the item provided by the container.

int maxId (  )  const [inline]

Returns the maximum id of the container.

void add ( const Item &  item  )  [inline]

It notifies all the registed observers about an item added to the container.

void add ( const std::vector< Item > &  items  )  [inline]

It notifies all the registed observers about more item added to the container.

void erase ( const Item &  item  )  throw () [inline]

It notifies all the registed observers about an item erased from the container.

void erase ( const std::vector< Item > &  items  )  [inline]

It notifies all the registed observers about more item erased from the container.

void build (  )  [inline]

Notifies all the registed observers about the container is built from an empty container.

void clear (  )  [inline]

Notifies all the registed observers about all items are erased from the container.


Generated on Thu Jun 4 04:06:41 2009 for LEMON by  doxygen 1.5.9