# HG changeset patch
# User Peter Kovacs <kpeter@inf.elte.hu>
# Date 1239698052 -7200
# Node ID 2313edd0db0bc70d7c72eca4b0404f79ef22ea61
# Parent  d11bf79989052e478a8691be32c34c28c598c92b
Standard graph maps are required to be reference maps (#190)

diff -r d11bf7998905 -r 2313edd0db0b lemon/bits/graph_adaptor_extender.h
--- a/lemon/bits/graph_adaptor_extender.h	Tue Apr 14 10:33:17 2009 +0200
+++ b/lemon/bits/graph_adaptor_extender.h	Tue Apr 14 10:34:12 2009 +0200
@@ -22,8 +22,6 @@
 #include <lemon/core.h>
 #include <lemon/error.h>
 
-#include <lemon/bits/default_map.h>
-
 namespace lemon {
 
   template <typename _Digraph>
diff -r d11bf7998905 -r 2313edd0db0b lemon/bits/map_extender.h
--- a/lemon/bits/map_extender.h	Tue Apr 14 10:33:17 2009 +0200
+++ b/lemon/bits/map_extender.h	Tue Apr 14 10:34:12 2009 +0200
@@ -47,6 +47,8 @@
 
     typedef typename Parent::Key Key;
     typedef typename Parent::Value Value;
+    typedef typename Parent::Reference Reference;
+    typedef typename Parent::ConstReference ConstReference;
 
     class MapIt;
     class ConstMapIt;
@@ -187,6 +189,8 @@
 
     typedef typename Parent::Key Key;
     typedef typename Parent::Value Value;
+    typedef typename Parent::Reference Reference;
+    typedef typename Parent::ConstReference ConstReference;
 
     class MapIt;
     class ConstMapIt;
diff -r d11bf7998905 -r 2313edd0db0b lemon/concepts/digraph.h
--- a/lemon/concepts/digraph.h	Tue Apr 14 10:33:17 2009 +0200
+++ b/lemon/concepts/digraph.h	Tue Apr 14 10:34:12 2009 +0200
@@ -421,12 +421,11 @@
       /// Gives back the opposite node on the given arc.
       Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
 
-      /// \brief Read write map of the nodes to type \c T.
+      /// \brief Reference map of the nodes to type \c T.
       ///
-      /// ReadWrite map of the nodes to type \c T.
-      /// \sa Reference
+      /// Reference map of the nodes to type \c T.
       template<class T>
-      class NodeMap : public ReadWriteMap< Node, T > {
+      class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
       public:
 
         ///\e
@@ -436,7 +435,8 @@
 
       private:
         ///Copy constructor
-        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
+        NodeMap(const NodeMap& nm) : 
+          ReferenceMap<Node, T, T&, const T&>(nm) { }
         ///Assignment operator
         template <typename CMap>
         NodeMap& operator=(const CMap&) {
@@ -445,12 +445,11 @@
         }
       };
 
-      /// \brief Read write map of the arcs to type \c T.
+      /// \brief Reference map of the arcs to type \c T.
       ///
       /// Reference map of the arcs to type \c T.
-      /// \sa Reference
       template<class T>
-      class ArcMap : public ReadWriteMap<Arc,T> {
+      class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
       public:
 
         ///\e
@@ -459,7 +458,8 @@
         ArcMap(const Digraph&, T) { }
       private:
         ///Copy constructor
-        ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
+        ArcMap(const ArcMap& em) :
+          ReferenceMap<Arc, T, T&, const T&>(em) { }
         ///Assignment operator
         template <typename CMap>
         ArcMap& operator=(const CMap&) {
@@ -471,6 +471,7 @@
       template <typename _Digraph>
       struct Constraints {
         void constraints() {
+          checkConcept<BaseDigraphComponent, _Digraph>();
           checkConcept<IterableDigraphComponent<>, _Digraph>();
           checkConcept<IDableDigraphComponent<>, _Digraph>();
           checkConcept<MappableDigraphComponent<>, _Digraph>();
diff -r d11bf7998905 -r 2313edd0db0b lemon/concepts/graph.h
--- a/lemon/concepts/graph.h	Tue Apr 14 10:33:17 2009 +0200
+++ b/lemon/concepts/graph.h	Tue Apr 14 10:34:12 2009 +0200
@@ -497,12 +497,11 @@
         InArcIt& operator++() { return *this; }
       };
 
-      /// \brief Read write map of the nodes to type \c T.
+      /// \brief Reference map of the nodes to type \c T.
       ///
-      /// ReadWrite map of the nodes to type \c T.
-      /// \sa Reference
+      /// Reference map of the nodes to type \c T.
       template<class T>
-      class NodeMap : public ReadWriteMap< Node, T >
+      class NodeMap : public ReferenceMap<Node, T, T&, const T&>
       {
       public:
 
@@ -513,7 +512,8 @@
 
       private:
         ///Copy constructor
-        NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
+        NodeMap(const NodeMap& nm) :
+          ReferenceMap<Node, T, T&, const T&>(nm) { }
         ///Assignment operator
         template <typename CMap>
         NodeMap& operator=(const CMap&) {
@@ -522,12 +522,11 @@
         }
       };
 
-      /// \brief Read write map of the directed arcs to type \c T.
+      /// \brief Reference map of the arcs to type \c T.
       ///
-      /// Reference map of the directed arcs to type \c T.
-      /// \sa Reference
+      /// Reference map of the arcs to type \c T.
       template<class T>
-      class ArcMap : public ReadWriteMap<Arc,T>
+      class ArcMap : public ReferenceMap<Arc, T, T&, const T&>
       {
       public:
 
@@ -537,7 +536,8 @@
         ArcMap(const Graph&, T) { }
       private:
         ///Copy constructor
-        ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
+        ArcMap(const ArcMap& em) :
+          ReferenceMap<Arc, T, T&, const T&>(em) { }
         ///Assignment operator
         template <typename CMap>
         ArcMap& operator=(const CMap&) {
@@ -546,12 +546,11 @@
         }
       };
 
-      /// Read write map of the edges to type \c T.
+      /// Reference map of the edges to type \c T.
 
-      /// Reference map of the arcs to type \c T.
-      /// \sa Reference
+      /// Reference map of the edges to type \c T.
       template<class T>
-      class EdgeMap : public ReadWriteMap<Edge,T>
+      class EdgeMap : public ReferenceMap<Edge, T, T&, const T&>
       {
       public:
 
@@ -561,7 +560,8 @@
         EdgeMap(const Graph&, T) { }
       private:
         ///Copy constructor
-        EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
+        EdgeMap(const EdgeMap& em) :
+          ReferenceMap<Edge, T, T&, const T&>(em) {}
         ///Assignment operator
         template <typename CMap>
         EdgeMap& operator=(const CMap&) {
@@ -748,6 +748,7 @@
       template <typename _Graph>
       struct Constraints {
         void constraints() {
+          checkConcept<BaseGraphComponent, _Graph>();
           checkConcept<IterableGraphComponent<>, _Graph>();
           checkConcept<IDableGraphComponent<>, _Graph>();
           checkConcept<MappableGraphComponent<>, _Graph>();
diff -r d11bf7998905 -r 2313edd0db0b lemon/concepts/graph_components.h
--- a/lemon/concepts/graph_components.h	Tue Apr 14 10:33:17 2009 +0200
+++ b/lemon/concepts/graph_components.h	Tue Apr 14 10:34:12 2009 +0200
@@ -988,8 +988,9 @@
     /// This class describes the concept of standard graph maps, i.e.
     /// the \c NodeMap, \c ArcMap and \c EdgeMap subtypes of digraph and 
     /// graph types, which can be used for associating data to graph items.
+    /// The standard graph maps must conform to the ReferenceMap concept.
     template <typename GR, typename K, typename V>
-    class GraphMap : public ReadWriteMap<K, V> {
+    class GraphMap : public ReferenceMap<K, V, V&, const V&> {
     public:
 
       typedef ReadWriteMap<K, V> Parent;
@@ -1000,6 +1001,13 @@
       typedef K Key;
       /// The value type of the map.
       typedef V Value;
+      /// The reference type of the map.
+      typedef Value& Reference;
+      /// The const reference type of the map.
+      typedef const Value& ConstReference;
+
+      // The reference map tag.
+      typedef True ReferenceMapTag;
 
       /// \brief Construct a new map.
       ///
@@ -1031,7 +1039,8 @@
       template<typename _Map>
       struct Constraints {
         void constraints() {
-          checkConcept<ReadWriteMap<Key, Value>, _Map >();
+          checkConcept
+            <ReferenceMap<Key, Value, Value&, const Value&>, _Map>();
           _Map m1(g);
           _Map m2(g,t);
           
@@ -1073,6 +1082,7 @@
       /// \brief Standard graph map for the nodes.
       ///
       /// Standard graph map for the nodes.
+      /// It conforms to the ReferenceMap concept.
       template <typename V>
       class NodeMap : public GraphMap<MappableDigraphComponent, Node, V> {
       public:
@@ -1110,6 +1120,7 @@
       /// \brief Standard graph map for the arcs.
       ///
       /// Standard graph map for the arcs.
+      /// It conforms to the ReferenceMap concept.
       template <typename V>
       class ArcMap : public GraphMap<MappableDigraphComponent, Arc, V> {
       public:
@@ -1207,6 +1218,7 @@
       /// \brief Standard graph map for the edges.
       ///
       /// Standard graph map for the edges.
+      /// It conforms to the ReferenceMap concept.
       template <typename V>
       class EdgeMap : public GraphMap<MappableGraphComponent, Edge, V> {
       public: