New implementation of GRAPH_TYPEDEFS
authorBalazs Dezso <deba@inf.elte.hu>
Tue, 22 Apr 2008 15:07:04 +0200 (2008-04-22)
changeset 140356930927a71
parent 139 701c529ba737
child 145 95d905b6e33d
New implementation of GRAPH_TYPEDEFS
lemon/graph_utils.h
lemon/lgf_reader.h
lemon/lgf_writer.h
     1.1 --- a/lemon/graph_utils.h	Tue Apr 22 15:04:00 2008 +0200
     1.2 +++ b/lemon/graph_utils.h	Tue Apr 22 15:07:04 2008 +0200
     1.3 @@ -42,6 +42,82 @@
     1.4    /// \addtogroup gutils
     1.5    /// @{
     1.6  
     1.7 +  namespace _graph_utils_bits {
     1.8 +    template <typename Graph>
     1.9 +    struct Node { typedef typename Graph::Node type; };
    1.10 +
    1.11 +    template <typename Graph>
    1.12 +    struct NodeIt { typedef typename Graph::NodeIt type; };
    1.13 +
    1.14 +    template <typename Graph>
    1.15 +    struct Arc { typedef typename Graph::Arc type; };
    1.16 +
    1.17 +    template <typename Graph>
    1.18 +    struct ArcIt { typedef typename Graph::ArcIt type; };
    1.19 +
    1.20 +    template <typename Graph>
    1.21 +    struct Edge { typedef typename Graph::Edge type; };
    1.22 +
    1.23 +    template <typename Graph>
    1.24 +    struct EdgeIt { typedef typename Graph::EdgeIt type; };
    1.25 +
    1.26 +    template <typename Graph>
    1.27 +    struct OutArcIt { typedef typename Graph::OutArcIt type; };
    1.28 +
    1.29 +    template <typename Graph>
    1.30 +    struct InArcIt { typedef typename Graph::InArcIt type; };
    1.31 +
    1.32 +    template <typename Graph>
    1.33 +    struct IncEdgeIt { typedef typename Graph::IncEdgeIt type; };
    1.34 +
    1.35 +    template <typename Graph>
    1.36 +    struct BoolNodeMap { 
    1.37 +      typedef typename Graph::template NodeMap<bool> type; 
    1.38 +    };
    1.39 +
    1.40 +    template <typename Graph>
    1.41 +    struct IntNodeMap { 
    1.42 +      typedef typename Graph::template NodeMap<int> type; 
    1.43 +    };
    1.44 +
    1.45 +    template <typename Graph>
    1.46 +    struct DoubleNodeMap { 
    1.47 +      typedef typename Graph::template NodeMap<double> type; 
    1.48 +    };
    1.49 +
    1.50 +    template <typename Graph>
    1.51 +    struct BoolArcMap { 
    1.52 +      typedef typename Graph::template ArcMap<bool> type; 
    1.53 +    };
    1.54 +
    1.55 +    template <typename Graph>
    1.56 +    struct IntArcMap { 
    1.57 +      typedef typename Graph::template ArcMap<int> type; 
    1.58 +    };
    1.59 +
    1.60 +    template <typename Graph>
    1.61 +    struct DoubleArcMap { 
    1.62 +      typedef typename Graph::template ArcMap<double> type; 
    1.63 +    };
    1.64 +
    1.65 +    template <typename Graph>
    1.66 +    struct BoolEdgeMap { 
    1.67 +      typedef typename Graph::template EdgeMap<bool> type; 
    1.68 +    };
    1.69 +
    1.70 +    template <typename Graph>
    1.71 +    struct IntEdgeMap { 
    1.72 +      typedef typename Graph::template EdgeMap<int> type; 
    1.73 +    };
    1.74 +
    1.75 +    template <typename Graph>
    1.76 +    struct DoubleEdgeMap { 
    1.77 +      typedef typename Graph::template EdgeMap<double> type; 
    1.78 +    };
    1.79 +
    1.80 +    
    1.81 +  }
    1.82 +
    1.83    ///Creates convenience typedefs for the digraph types and iterators
    1.84  
    1.85    ///This \c \#define creates convenience typedefs for the following types
    1.86 @@ -49,12 +125,31 @@
    1.87    ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap, 
    1.88    ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap. 
    1.89  #define DIGRAPH_TYPEDEFS(Digraph)					\
    1.90 -  typedef Digraph::Node Node;						\
    1.91 -  typedef Digraph::NodeIt NodeIt;					\
    1.92 -  typedef Digraph::Arc Arc;						\
    1.93 -  typedef Digraph::ArcIt ArcIt;						\
    1.94 -  typedef Digraph::InArcIt InArcIt;					\
    1.95 -  typedef Digraph::OutArcIt OutArcIt
    1.96 +  typedef typename ::lemon::_graph_utils_bits::				\
    1.97 +  Node<Digraph>::type Node;						\
    1.98 +  typedef typename ::lemon::_graph_utils_bits::				\
    1.99 +  NodeIt<Digraph>::type	NodeIt;						\
   1.100 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.101 +  Arc<Digraph>::type Arc;						\
   1.102 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.103 +  ArcIt<Digraph>::type ArcIt;						\
   1.104 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.105 +  OutArcIt<Digraph>::type OutArcIt;					\
   1.106 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.107 +  InArcIt<Digraph>::type InArcIt;					\
   1.108 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.109 +  BoolNodeMap<Digraph>::type BoolNodeMap;				\
   1.110 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.111 +  IntNodeMap<Digraph>::type IntNodeMap;					\
   1.112 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.113 +  DoubleNodeMap<Digraph>::type DoubleNodeMap;				\
   1.114 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.115 +  BoolArcMap<Digraph>::type BoolArcMap;					\
   1.116 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.117 +  IntArcMap<Digraph>::type IntArcMap;					\
   1.118 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.119 +  DoubleArcMap<Digraph>::type DoubleArcMap
   1.120 +
   1.121  
   1.122    ///Creates convenience typedefs for the graph types and iterators
   1.123  
   1.124 @@ -64,9 +159,19 @@
   1.125    ///\c DoubleEdgeMap.
   1.126  #define GRAPH_TYPEDEFS(Graph)						\
   1.127    DIGRAPH_TYPEDEFS(Graph);						\
   1.128 -  typedef Graph::Edge Edge;						\
   1.129 -  typedef Graph::EdgeIt EdgeIt;						\
   1.130 -  typedef Graph::IncEdgeIt IncEdgeIt
   1.131 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.132 +  Edge<Graph>::type Edge;						\
   1.133 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.134 +  EdgeIt<Graph>::type EdgeIt;						\
   1.135 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.136 +  IncEdgeIt<Graph>::type IncEdgeIt					\
   1.137 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.138 +  BoolEdgeMap<Graph>::type BoolEdgeMap;					\
   1.139 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.140 +  IntEdgeMap<Graph>::type IntEdgeMap;					\
   1.141 +  typedef typename ::lemon::_graph_utils_bits::				\
   1.142 +  DoubleEdgeMap<Graph>::type DoubleEdgeMap
   1.143 +
   1.144  
   1.145    /// \brief Function to count the items in the graph.
   1.146    ///
   1.147 @@ -2056,7 +2161,7 @@
   1.148      typedef typename ItemSetTraits<G, typename G::Arc>
   1.149      ::ItemNotifier::ObserverBase Parent;
   1.150  
   1.151 -    DIGRAPH_TYPEDEFS(typename G);
   1.152 +    DIGRAPH_TYPEDEFS(G);
   1.153      typedef G Digraph;
   1.154  
   1.155    protected:
   1.156 @@ -2493,7 +2598,7 @@
   1.157    class ArcLookUp 
   1.158    {
   1.159    public:
   1.160 -    DIGRAPH_TYPEDEFS(typename G);
   1.161 +    DIGRAPH_TYPEDEFS(G);
   1.162      typedef G Digraph;
   1.163  
   1.164    protected:
   1.165 @@ -2610,7 +2715,7 @@
   1.166      using ArcLookUp<G>::_left;
   1.167      using ArcLookUp<G>::_head;
   1.168  
   1.169 -    DIGRAPH_TYPEDEFS(typename G);
   1.170 +    DIGRAPH_TYPEDEFS(G);
   1.171      typedef G Digraph;
   1.172      
   1.173      typename Digraph::template ArcMap<Arc> _next;
     2.1 --- a/lemon/lgf_reader.h	Tue Apr 22 15:04:00 2008 +0200
     2.2 +++ b/lemon/lgf_reader.h	Tue Apr 22 15:07:04 2008 +0200
     2.3 @@ -302,7 +302,7 @@
     2.4    public:
     2.5  
     2.6      typedef _Digraph Digraph;
     2.7 -    DIGRAPH_TYPEDEFS(typename Digraph);
     2.8 +    DIGRAPH_TYPEDEFS(Digraph);
     2.9      
    2.10    private:
    2.11  
     3.1 --- a/lemon/lgf_writer.h	Tue Apr 22 15:04:00 2008 +0200
     3.2 +++ b/lemon/lgf_writer.h	Tue Apr 22 15:07:04 2008 +0200
     3.3 @@ -237,7 +237,7 @@
     3.4    public:
     3.5  
     3.6      typedef _Digraph Digraph;
     3.7 -    DIGRAPH_TYPEDEFS(typename Digraph);
     3.8 +    DIGRAPH_TYPEDEFS(Digraph);
     3.9      
    3.10    private:
    3.11