1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/src/lemon/mappable_graph_extender.h Wed Oct 27 22:38:50 2004 +0000
1.3 @@ -0,0 +1,97 @@
1.4 +// -*- c++ -*-
1.5 +
1.6 +#ifndef LEMON_MAPPABLE_GRAPH_EXTENDER_H
1.7 +#define LEMON_MAPPABLE_GRAPH_EXTENDER_H
1.8 +
1.9 +namespace lemon {
1.10 +
1.11 + template <typename Base, template <class,class,class,class,class,class> class DynMap>
1.12 + class MappableGraphExtender : public Base {
1.13 + public:
1.14 +
1.15 + typedef MappableGraphExtender Graph;
1.16 + typedef Base Parent;
1.17 +
1.18 + typedef typename Parent::Node Node;
1.19 + typedef typename Parent::NodeIt NodeIt;
1.20 + typedef typename Parent::NodeObserverRegistry NodeObserverRegistry;
1.21 +
1.22 + typedef typename Parent::Edge Edge;
1.23 + typedef typename Parent::EdgeIt EdgeIt;
1.24 + typedef typename Parent::EdgeObserverRegistry EdgeObserverRegistry;
1.25 +
1.26 + public:
1.27 +
1.28 + class NodeIdMap {
1.29 + private:
1.30 + const Graph* graph;
1.31 +
1.32 + public:
1.33 + NodeIdMap(const Graph& g) : graph(&g) {}
1.34 +
1.35 + int operator[](const Node& node) { return graph->id(node); }
1.36 +
1.37 + int maxId() const {return graph->maxNodeId(); }
1.38 +
1.39 + };
1.40 +
1.41 + // template <typename Value>
1.42 + // friend class DynMap<NodeObserverRegistry, Graph, Node, NodeIt,
1.43 + // NodeIdMap, Value>;
1.44 +
1.45 + class EdgeIdMap {
1.46 + private:
1.47 + const Graph* graph;
1.48 +
1.49 + public:
1.50 + EdgeIdMap(const Graph& g) : graph(&g) {}
1.51 +
1.52 + int operator[](const Edge& edge) const { return graph->id(edge); }
1.53 +
1.54 + int maxId() const {return graph->maxEdgeId(); }
1.55 +
1.56 + };
1.57 +
1.58 + // template <typename Value>
1.59 + // friend class DynMap<EdgeObserverRegistry, Graph, Edge, EdgeIt,
1.60 + // EdgeIdMap, Value>;
1.61 +
1.62 + public:
1.63 +
1.64 + template <typename Value>
1.65 + class NodeMap
1.66 + : public DynMap<NodeObserverRegistry, Graph, Node, NodeIt,
1.67 + NodeIdMap, Value> {
1.68 + public:
1.69 + typedef DynMap<NodeObserverRegistry, Graph, Node, NodeIt,
1.70 + NodeIdMap, Value> Parent;
1.71 +
1.72 + NodeMap(const Graph& g)
1.73 + : Parent(g, g.Graph::Parent::getNodeObserverRegistry()) {}
1.74 + NodeMap(const Graph& g, const Value& v)
1.75 + : Parent(g, g.Graph::Parent::getNodeObserverRegistry(), v) {}
1.76 +
1.77 + };
1.78 +
1.79 + template <typename Value>
1.80 + class EdgeMap
1.81 + : public DynMap<EdgeObserverRegistry, Graph, Edge, EdgeIt,
1.82 + EdgeIdMap, Value> {
1.83 + public:
1.84 + typedef DynMap<EdgeObserverRegistry, Graph, Edge, EdgeIt,
1.85 + EdgeIdMap, Value> Parent;
1.86 +
1.87 + EdgeMap(const Graph& g)
1.88 + : Parent(g, g.Graph::Parent::getEdgeObserverRegistry()) {}
1.89 + EdgeMap(const Graph& g, const Value& v)
1.90 + : Parent(g, g.Graph::Parent::getEdgeObserverRegistry(), v) {}
1.91 +
1.92 + };
1.93 +
1.94 +
1.95 + };
1.96 +
1.97 +}
1.98 +
1.99 +#endif
1.100 +