Index: src/lemon/default_map.h
===================================================================
--- src/lemon/default_map.h	(revision 937)
+++ src/lemon/default_map.h	(revision 946)
@@ -24,5 +24,5 @@
 ///\ingroup graphmaps
 ///\file
-///\brief Graph maps that construates and destruates
+///\brief Graph maps that construct and destruct
 ///their elements dynamically.
 
@@ -42,98 +42,183 @@
 
 
-  /** Macro to implement the DefaultMap.
-   */
-#define DEFAULT_MAP_BODY(DynMap, Value) \
-{ \
-\
-public: \
-\
-typedef DynMap<MapRegistry, Value> Parent; \
-\
-typedef typename MapRegistry::Graph Graph; \
-\
-DefaultMap(const Graph& g, MapRegistry& r) : Parent(g, r) {} \
-DefaultMap(const Graph& g, MapRegistry& r, const Value& v) \
-  : Parent(g, r, v) {} \
-DefaultMap(const DefaultMap& copy) \
-  : Parent(static_cast<const Parent&>(copy)) {} \
-template <typename TT> \
-DefaultMap(const DefaultMap<MapRegistry, TT>& copy) \
-  : Parent(*copy.getGraph()) { \
-  if (Parent::getGraph()) { \
-    for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
-      Parent::operator[](it) = copy[it]; \
-    } \
-  } \
-} \
-DefaultMap& operator=(const DefaultMap& copy) { \
-  Parent::operator=(static_cast<const Parent&>(copy)); \
-  return *this; \
-} \
-template <typename TT> \
-DefaultMap& operator=(const DefaultMap<MapRegistry, TT>& copy) { \
-  if (Parent::getGraph() != copy.getGraph()) { \
-    Parent::clear(); \
-    Parent::MapBase::operator=(copy); \
-    Parent::construct(); \
-  } \
-  if (Parent::getGraph()) { \
-    for (typename Parent::KeyIt it(*Parent::getGraph()); it!=INVALID; ++it) {\
-      Parent::operator[](it) = copy[it]; \
-    } \
-  } \
-  return *this; \
-} \
-};
-
-
-  template <typename MapRegistry, typename Type>
-  class DefaultMap : public ArrayMap<MapRegistry, Type> 
-  DEFAULT_MAP_BODY(ArrayMap, Type);
-
-  template <typename MapRegistry>
-  class DefaultMap<MapRegistry, bool> 
-    : public VectorMap<MapRegistry, bool> 
-  DEFAULT_MAP_BODY(VectorMap, bool);
-
-  template <typename MapRegistry>
-  class DefaultMap<MapRegistry, char> 
-    : public VectorMap<MapRegistry, char> 
-  DEFAULT_MAP_BODY(VectorMap, char);
-
-  template <typename MapRegistry>
-  class DefaultMap<MapRegistry, int> 
-    : public VectorMap<MapRegistry, int> 
-  DEFAULT_MAP_BODY(VectorMap, int);
-
-  template <typename MapRegistry>
-  class DefaultMap<MapRegistry, short> 
-    : public VectorMap<MapRegistry, short> 
-  DEFAULT_MAP_BODY(VectorMap, short);
-
-  template <typename MapRegistry>
-  class DefaultMap<MapRegistry, long> 
-    : public VectorMap<MapRegistry, long> 
-  DEFAULT_MAP_BODY(VectorMap, long);
-
-  template <typename MapRegistry>
-  class DefaultMap<MapRegistry, float> 
-    : public VectorMap<MapRegistry, float> 
-  DEFAULT_MAP_BODY(VectorMap, float);
-
-  template <typename MapRegistry>
-  class DefaultMap<MapRegistry, double> 
-    : public VectorMap<MapRegistry, double> 
-  DEFAULT_MAP_BODY(VectorMap, double);
-
-  template <typename MapRegistry>
-  class DefaultMap<MapRegistry, long double> 
-    : public VectorMap<MapRegistry, long double> 
-  DEFAULT_MAP_BODY(VectorMap, long double);
-
-  template <typename MapRegistry, typename Type>
-  class DefaultMap<MapRegistry, Type*>
-    : public VectorMap<MapRegistry, Type*> 
-  DEFAULT_MAP_BODY(VectorMap, Type*);
+
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap, typename _Value>
+  struct DefaultMapSelector {
+    typedef ArrayMap<_Graph, _Item, _ItemIt, _IdMap, _Value> Map;
+  };
+
+  // bool
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, bool> {
+    typedef VectorMap<_Graph, _Item, _IdMap, bool> Map;
+  };
+
+  // char
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, char> {
+    typedef VectorMap<_Graph, _Item, _IdMap, char> Map;
+  };
+
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed char> {
+    typedef VectorMap<_Graph, _Item, _IdMap, signed char> Map;
+  };
+
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned char> {
+    typedef VectorMap<_Graph, _Item, _IdMap, unsigned char> Map;
+  };
+
+
+  // int
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed int> {
+    typedef VectorMap<_Graph, _Item, _IdMap, signed int> Map;
+  };
+
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned int> {
+    typedef VectorMap<_Graph, _Item, _IdMap, unsigned int> Map;
+  };
+
+
+  // short
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed short> {
+    typedef VectorMap<_Graph, _Item, _IdMap, signed short> Map;
+  };
+
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned short> {
+    typedef VectorMap<_Graph, _Item, _IdMap, unsigned short> Map;
+  };
+
+
+  // long
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, signed long> {
+    typedef VectorMap<_Graph, _Item, _IdMap, signed long> Map;
+  };
+
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, unsigned long> {
+    typedef VectorMap<_Graph, _Item, _IdMap, unsigned long> Map;
+  };
+
+  // \todo handling long long type
+
+
+  // float
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, float> {
+    typedef VectorMap<_Graph, _Item, _IdMap, float> Map;
+  };
+
+
+  // double
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, double> {
+    typedef VectorMap<_Graph, _Item, _IdMap,  double> Map;
+  };
+
+
+  // long double
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, long double> {
+    typedef VectorMap<_Graph, _Item, _IdMap, long double> Map;
+  };
+
+
+  // pointer
+  template <typename _Graph, typename _Item, typename _ItemIt, typename _IdMap, typename _Ptr>
+  struct DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Ptr*> {
+    typedef VectorMap<_Graph, _Item, _IdMap, _Ptr*> Map;
+  };
+
+
+
+  template <typename _Graph, 
+	    typename _Item,
+	    typename _ItemIt,
+	    typename _IdMap,
+	    typename _Value>
+  class DefaultMap : public DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Value>::Map {
+  public:
+    typedef typename DefaultMapSelector<_Graph, _Item, _ItemIt, _IdMap, _Value>::Map Parent;
+    typedef DefaultMap<_Graph, _Item, _ItemIt, _IdMap, bool> Map;
+    
+    typedef typename Parent::Graph Graph;
+    typedef typename Parent::Registry Registry;
+    typedef typename Parent::ValueType ValueType;
+
+    DefaultMap(const Graph& _g, Registry& _r) : Parent(_g, _r) {}
+    DefaultMap(const Graph& _g, Registry& _r, const ValueType& _v) : Parent(_g, _r, _v) {}
+  };
+
+
+
+  template <typename _Base> 
+  class DefaultMappableGraphExtender : public _Base {
+  public:
+
+    typedef DefaultMappableGraphExtender<_Base> Graph;
+    typedef _Base Parent;
+
+    typedef typename Parent::Node Node;
+    typedef typename Parent::NodeIt NodeIt;
+    typedef typename Parent::NodeIdMap NodeIdMap;
+    typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
+
+    typedef typename Parent::Edge Edge;
+    typedef typename Parent::EdgeIt EdgeIt;
+    typedef typename Parent::EdgeIdMap EdgeIdMap;
+    typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
+
+    
+
+    template <typename _Value>
+    class NodeMap : public DefaultMap<Graph, Node, NodeIt, NodeIdMap, _Value> {
+    public:
+      typedef DefaultMappableGraphExtender<_Base> Graph;
+
+      typedef typename Graph::Node Node;
+      typedef typename Graph::NodeIt NodeIt;
+      typedef typename Graph::NodeIdMap NodeIdMap;
+
+      typedef DefaultMap<Graph, Node, NodeIt, NodeIdMap, _Value> Parent;
+
+      typedef typename Parent::Graph Graph;
+      typedef typename Parent::ValueType ValueType;
+
+      NodeMap(const Graph& g) 
+	: Parent(g, g.getNodeObserverRegistry()) {}
+      NodeMap(const Graph& g, const ValueType& v) 
+	: Parent(g, g.getNodeObserverRegistry(), v) {}
+
+    };
+
+    template <typename _Value>
+    class EdgeMap : public DefaultMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> {
+    public:
+      typedef DefaultMappableGraphExtender<_Base> Graph;
+
+      typedef typename Graph::Edge Edge;
+      typedef typename Graph::EdgeIt EdgeIt;
+      typedef typename Graph::EdgeIdMap EdgeIdMap;
+
+      typedef DefaultMap<Graph, Edge, EdgeIt, EdgeIdMap, _Value> Parent;
+
+      typedef typename Parent::Graph Graph;
+      typedef typename Parent::ValueType ValueType;
+
+      EdgeMap(const Graph& g) 
+	: Parent(g, g.getEdgeObserverRegistry()) {}
+      EdgeMap(const Graph& g, const ValueType& v) 
+	: Parent(g, g.getEdgeObserverRegistry(), v) {}
+
+    };
+    
+  };
+
 
 }
