src/lemon/mappable_graph_extender.h
author klao
Mon, 08 Nov 2004 16:42:35 +0000
changeset 971 643d3192ebc8
permissions -rw-r--r--
remove an annoying warning
     1 // -*- c++ -*-
     2 
     3 #ifndef LEMON_MAPPABLE_GRAPH_EXTENDER_H
     4 #define LEMON_MAPPABLE_GRAPH_EXTENDER_H
     5 
     6 namespace lemon {
     7 
     8   template <typename Base, template <class,class,class,class,class,class> class DynMap> 
     9   class MappableGraphExtender : public Base {
    10   public:
    11 
    12     typedef MappableGraphExtender Graph;
    13     typedef Base Parent;
    14 
    15     typedef typename Parent::Node Node;
    16     typedef typename Parent::NodeIt NodeIt;
    17     typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
    18 
    19     typedef typename Parent::Edge Edge;
    20     typedef typename Parent::EdgeIt EdgeIt;
    21     typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
    22 
    23   public:
    24 
    25     class NodeIdMap {
    26     private:
    27       const Graph* graph;
    28 
    29     public:
    30       NodeIdMap(const Graph& g) : graph(&g) {}
    31 
    32       int operator[](const Node& node) { return graph->id(node); }
    33 
    34       int maxId() const {return graph->maxNodeId(); }
    35 
    36     };
    37 
    38     //    template <typename Value>
    39     //    friend class DynMap<NodeObserverRegistry, Graph, Node, NodeIt,
    40     //		NodeIdMap, Value>;
    41 
    42     class EdgeIdMap {
    43     private:
    44       const Graph* graph;
    45 
    46     public:
    47       EdgeIdMap(const Graph& g) : graph(&g) {}
    48 
    49       int operator[](const Edge& edge) const { return graph->id(edge); }
    50 
    51       int maxId() const {return graph->maxEdgeId(); }
    52 
    53     };
    54 
    55     //    template <typename Value>
    56     //    friend class DynMap<EdgeObserverRegistry, Graph, Edge, EdgeIt,
    57     //		EdgeIdMap, Value>;
    58 
    59   public:
    60     
    61     template <typename Value>
    62     class NodeMap 
    63       : public DynMap<NodeObserverRegistry, Graph, Node, NodeIt,
    64 		      NodeIdMap, Value> {
    65     public:
    66       typedef DynMap<NodeObserverRegistry, Graph, Node, NodeIt,
    67 		     NodeIdMap, Value> Parent;
    68 
    69       NodeMap(const Graph& g) 
    70 	: Parent(g, g.Graph::Parent::getNodeObserverRegistry()) {}
    71       NodeMap(const Graph& g, const Value& v) 
    72 	: Parent(g, g.Graph::Parent::getNodeObserverRegistry(), v) {}
    73 
    74     };
    75 
    76     template <typename Value>
    77     class EdgeMap 
    78       : public DynMap<EdgeObserverRegistry, Graph, Edge, EdgeIt,
    79 		      EdgeIdMap, Value> {
    80     public:
    81       typedef DynMap<EdgeObserverRegistry, Graph, Edge, EdgeIt,
    82 		     EdgeIdMap, Value> Parent;
    83 
    84       EdgeMap(const Graph& g) 
    85 	: Parent(g, g.Graph::Parent::getEdgeObserverRegistry()) {}
    86       EdgeMap(const Graph& g, const Value& v) 
    87 	: Parent(g, g.Graph::Parent::getEdgeObserverRegistry(), v) {}
    88 
    89     };
    90 
    91     
    92   };
    93 
    94 }
    95 
    96 #endif
    97