# HG changeset patch # User Peter Kovacs # Date 2009-04-24 11:54:48 # Node ID 4137ef9aacc6570e5ec02d979059eb94b695938d # Parent f2d6d3446adf31a3906cac0b7c44c8e11488ad9c Fix and uniform the usage of Graph and Parent typedefs (#268) - Rename Graph typedefs to GraphType in the implementation of graph maps and MapExtender to prevent conflicts (especially using VS). They are not public. - Make Parent typedefs private in all classes. - Replace Digraph with Graph in some places (fix faulty renamings of the script). - Use Graph and Digraph typedefs (more) consequently. diff --git a/lemon/adaptors.h b/lemon/adaptors.h --- a/lemon/adaptors.h +++ b/lemon/adaptors.h @@ -109,13 +109,11 @@ template class NodeMap : public DGR::template NodeMap { + typedef typename DGR::template NodeMap Parent; + public: - - typedef typename DGR::template NodeMap Parent; - explicit NodeMap(const Adaptor& adaptor) : Parent(*adaptor._digraph) {} - NodeMap(const Adaptor& adaptor, const V& value) : Parent(*adaptor._digraph, value) { } @@ -134,13 +132,11 @@ template class ArcMap : public DGR::template ArcMap { + typedef typename DGR::template ArcMap Parent; + public: - - typedef typename DGR::template ArcMap Parent; - explicit ArcMap(const DigraphAdaptorBase& adaptor) : Parent(*adaptor._digraph) {} - ArcMap(const DigraphAdaptorBase& adaptor, const V& value) : Parent(*adaptor._digraph, value) {} @@ -255,8 +251,9 @@ template class NodeMap : public GR::template NodeMap { + typedef typename GR::template NodeMap Parent; + public: - typedef typename GR::template NodeMap Parent; explicit NodeMap(const GraphAdaptorBase& adapter) : Parent(*adapter._graph) {} NodeMap(const GraphAdaptorBase& adapter, const V& value) @@ -277,8 +274,9 @@ template class ArcMap : public GR::template ArcMap { + typedef typename GR::template ArcMap Parent; + public: - typedef typename GR::template ArcMap Parent; explicit ArcMap(const GraphAdaptorBase& adapter) : Parent(*adapter._graph) {} ArcMap(const GraphAdaptorBase& adapter, const V& value) @@ -298,8 +296,9 @@ template class EdgeMap : public GR::template EdgeMap { + typedef typename GR::template EdgeMap Parent; + public: - typedef typename GR::template EdgeMap Parent; explicit EdgeMap(const GraphAdaptorBase& adapter) : Parent(*adapter._graph) {} EdgeMap(const GraphAdaptorBase& adapter, const V& value) @@ -321,9 +320,9 @@ template class ReverseDigraphBase : public DigraphAdaptorBase { + typedef DigraphAdaptorBase Parent; public: typedef DGR Digraph; - typedef DigraphAdaptorBase Parent; protected: ReverseDigraphBase() : Parent() { } public: @@ -374,10 +373,10 @@ class ReverseDigraph : public DigraphAdaptorExtender > { #endif + typedef DigraphAdaptorExtender > Parent; public: /// The type of the adapted digraph. typedef DGR Digraph; - typedef DigraphAdaptorExtender > Parent; protected: ReverseDigraph() { } public: @@ -403,13 +402,13 @@ template class SubDigraphBase : public DigraphAdaptorBase { + typedef DigraphAdaptorBase Parent; public: typedef DGR Digraph; typedef NF NodeFilterMap; typedef AF ArcFilterMap; typedef SubDigraphBase Adaptor; - typedef DigraphAdaptorBase Parent; protected: NF* _node_filter; AF* _arc_filter; @@ -509,10 +508,11 @@ class NodeMap : public SubMapExtender, LEMON_SCOPE_FIX(DigraphAdaptorBase, NodeMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(DigraphAdaptorBase, NodeMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(DigraphAdaptorBase, NodeMap)> Parent; NodeMap(const SubDigraphBase& adaptor) : Parent(adaptor) {} @@ -535,10 +535,11 @@ class ArcMap : public SubMapExtender, LEMON_SCOPE_FIX(DigraphAdaptorBase, ArcMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(DigraphAdaptorBase, ArcMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(DigraphAdaptorBase, ArcMap)> Parent; ArcMap(const SubDigraphBase& adaptor) : Parent(adaptor) {} @@ -562,13 +563,13 @@ template class SubDigraphBase : public DigraphAdaptorBase { + typedef DigraphAdaptorBase Parent; public: typedef DGR Digraph; typedef NF NodeFilterMap; typedef AF ArcFilterMap; typedef SubDigraphBase Adaptor; - typedef DigraphAdaptorBase Parent; protected: NF* _node_filter; AF* _arc_filter; @@ -650,10 +651,11 @@ class NodeMap : public SubMapExtender, LEMON_SCOPE_FIX(DigraphAdaptorBase, NodeMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(DigraphAdaptorBase, NodeMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(DigraphAdaptorBase, NodeMap)> Parent; NodeMap(const SubDigraphBase& adaptor) : Parent(adaptor) {} @@ -676,10 +678,11 @@ class ArcMap : public SubMapExtender, LEMON_SCOPE_FIX(DigraphAdaptorBase, ArcMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(DigraphAdaptorBase, ArcMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(DigraphAdaptorBase, ArcMap)> Parent; ArcMap(const SubDigraphBase& adaptor) : Parent(adaptor) {} @@ -863,13 +866,13 @@ template class SubGraphBase : public GraphAdaptorBase { + typedef GraphAdaptorBase Parent; public: typedef GR Graph; typedef NF NodeFilterMap; typedef EF EdgeFilterMap; typedef SubGraphBase Adaptor; - typedef GraphAdaptorBase Parent; protected: NF* _node_filter; @@ -1016,10 +1019,11 @@ class NodeMap : public SubMapExtender, LEMON_SCOPE_FIX(GraphAdaptorBase, NodeMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(GraphAdaptorBase, NodeMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(GraphAdaptorBase, NodeMap)> Parent; NodeMap(const SubGraphBase& adaptor) : Parent(adaptor) {} @@ -1042,10 +1046,11 @@ class ArcMap : public SubMapExtender, LEMON_SCOPE_FIX(GraphAdaptorBase, ArcMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(GraphAdaptorBase, ArcMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(GraphAdaptorBase, ArcMap)> Parent; ArcMap(const SubGraphBase& adaptor) : Parent(adaptor) {} @@ -1068,10 +1073,11 @@ class EdgeMap : public SubMapExtender, LEMON_SCOPE_FIX(GraphAdaptorBase, EdgeMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(GraphAdaptorBase, EdgeMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(GraphAdaptorBase, EdgeMap)> Parent; EdgeMap(const SubGraphBase& adaptor) : Parent(adaptor) {} @@ -1096,13 +1102,13 @@ template class SubGraphBase : public GraphAdaptorBase { + typedef GraphAdaptorBase Parent; public: typedef GR Graph; typedef NF NodeFilterMap; typedef EF EdgeFilterMap; typedef SubGraphBase Adaptor; - typedef GraphAdaptorBase Parent; protected: NF* _node_filter; EF* _edge_filter; @@ -1211,10 +1217,11 @@ class NodeMap : public SubMapExtender, LEMON_SCOPE_FIX(GraphAdaptorBase, NodeMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(GraphAdaptorBase, NodeMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(GraphAdaptorBase, NodeMap)> Parent; NodeMap(const SubGraphBase& adaptor) : Parent(adaptor) {} @@ -1237,10 +1244,11 @@ class ArcMap : public SubMapExtender, LEMON_SCOPE_FIX(GraphAdaptorBase, ArcMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(GraphAdaptorBase, ArcMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(GraphAdaptorBase, ArcMap)> Parent; ArcMap(const SubGraphBase& adaptor) : Parent(adaptor) {} @@ -1263,10 +1271,11 @@ class EdgeMap : public SubMapExtender, LEMON_SCOPE_FIX(GraphAdaptorBase, EdgeMap)> { + typedef SubMapExtender, + LEMON_SCOPE_FIX(GraphAdaptorBase, EdgeMap)> Parent; + public: typedef V Value; - typedef SubMapExtender, - LEMON_SCOPE_FIX(GraphAdaptorBase, EdgeMap)> Parent; EdgeMap(const SubGraphBase& adaptor) : Parent(adaptor) {} @@ -1485,15 +1494,15 @@ SubDigraphBase >, true> > { #endif - public: - - typedef GR Digraph; - typedef NF NodeFilterMap; - typedef DigraphAdaptorExtender< SubDigraphBase >, true> > Parent; + public: + + typedef GR Digraph; + typedef NF NodeFilterMap; + typedef typename Parent::Node Node; protected: @@ -1548,14 +1557,17 @@ SubGraphBase >, true> > { - public: - typedef GR Graph; - typedef NF NodeFilterMap; typedef GraphAdaptorExtender< SubGraphBase >, true> > Parent; + public: + + typedef GR Graph; + typedef NF NodeFilterMap; + typedef typename Parent::Node Node; + protected: ConstMap > const_true_map; @@ -1629,16 +1641,17 @@ SubDigraphBase >, AF, false> > { #endif + typedef DigraphAdaptorExtender< + SubDigraphBase >, + AF, false> > Parent; + public: + /// The type of the adapted digraph. typedef DGR Digraph; /// The type of the arc filter map. typedef AF ArcFilterMap; - typedef DigraphAdaptorExtender< - SubDigraphBase >, - AF, false> > Parent; - typedef typename Parent::Arc Arc; protected: @@ -1738,16 +1751,17 @@ SubGraphBase >, EF, false> > { #endif + typedef GraphAdaptorExtender< + SubGraphBase >, + EF, false> > Parent; + public: + /// The type of the adapted graph. typedef GR Graph; /// The type of the edge filter map. typedef EF EdgeFilterMap; - typedef GraphAdaptorExtender< - SubGraphBase >, - EF, false> > Parent; - typedef typename Parent::Edge Edge; protected: @@ -2111,10 +2125,10 @@ template class NodeMap : public DGR::template NodeMap { + typedef typename DGR::template NodeMap Parent; + public: - typedef V Value; - typedef typename DGR::template NodeMap Parent; explicit NodeMap(const UndirectorBase& adaptor) : Parent(*adaptor._digraph) {} @@ -2137,11 +2151,11 @@ template class ArcMap - : public SubMapExtender, ArcMapBase > - { + : public SubMapExtender, ArcMapBase > { + typedef SubMapExtender, ArcMapBase > Parent; + public: typedef V Value; - typedef SubMapExtender > Parent; explicit ArcMap(const UndirectorBase& adaptor) : Parent(adaptor) {} @@ -2163,10 +2177,10 @@ template class EdgeMap : public Digraph::template ArcMap { + typedef typename Digraph::template ArcMap Parent; + public: - typedef V Value; - typedef typename Digraph::template ArcMap Parent; explicit EdgeMap(const UndirectorBase& adaptor) : Parent(*adaptor._digraph) {} @@ -2238,10 +2252,10 @@ class Undirector : public GraphAdaptorExtender > { #endif + typedef GraphAdaptorExtender > Parent; public: /// The type of the adapted digraph. typedef DGR Digraph; - typedef GraphAdaptorExtender > Parent; protected: Undirector() { } public: @@ -2449,10 +2463,10 @@ template class NodeMap : public GR::template NodeMap { + typedef typename GR::template NodeMap Parent; + public: - typedef typename GR::template NodeMap Parent; - explicit NodeMap(const OrienterBase& adapter) : Parent(*adapter._graph) {} @@ -2474,10 +2488,10 @@ template class ArcMap : public GR::template EdgeMap { + typedef typename Graph::template EdgeMap Parent; + public: - typedef typename Graph::template EdgeMap Parent; - explicit ArcMap(const OrienterBase& adapter) : Parent(*adapter._graph) { } @@ -2546,6 +2560,7 @@ class Orienter : public DigraphAdaptorExtender > { #endif + typedef DigraphAdaptorExtender > Parent; public: /// The type of the adapted graph. @@ -2553,10 +2568,11 @@ /// The type of the direction edge map. typedef DM DirectionMap; - typedef DigraphAdaptorExtender > Parent; typedef typename Parent::Arc Arc; + protected: Orienter() { } + public: /// \brief Constructor @@ -2866,10 +2882,11 @@ template class SplitNodesBase { + typedef DigraphAdaptorBase Parent; + public: typedef DGR Digraph; - typedef DigraphAdaptorBase Parent; typedef SplitNodesBase Adaptor; typedef typename DGR::Node DigraphNode; @@ -3228,11 +3245,11 @@ template class NodeMap - : public SubMapExtender, NodeMapBase > - { + : public SubMapExtender, NodeMapBase > { + typedef SubMapExtender, NodeMapBase > Parent; + public: typedef V Value; - typedef SubMapExtender, NodeMapBase > Parent; NodeMap(const SplitNodesBase& adaptor) : Parent(adaptor) {} @@ -3254,11 +3271,11 @@ template class ArcMap - : public SubMapExtender, ArcMapBase > - { + : public SubMapExtender, ArcMapBase > { + typedef SubMapExtender, ArcMapBase > Parent; + public: typedef V Value; - typedef SubMapExtender, ArcMapBase > Parent; ArcMap(const SplitNodesBase& adaptor) : Parent(adaptor) {} @@ -3324,9 +3341,10 @@ class SplitNodes : public DigraphAdaptorExtender > { #endif + typedef DigraphAdaptorExtender > Parent; + public: typedef DGR Digraph; - typedef DigraphAdaptorExtender > Parent; typedef typename DGR::Node DigraphNode; typedef typename DGR::Arc DigraphArc; diff --git a/lemon/bits/array_map.h b/lemon/bits/array_map.h --- a/lemon/bits/array_map.h +++ b/lemon/bits/array_map.h @@ -47,7 +47,7 @@ : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase { public: // The graph type. - typedef _Graph Graph; + typedef _Graph GraphType; // The item type. typedef _Item Item; // The reference map tag. @@ -63,13 +63,17 @@ // The reference type of the map. typedef _Value& Reference; + // The map type. + typedef ArrayMap Map; + // The notifier type. typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier; + private: + // The MapBase of the Map which imlements the core regisitry function. typedef typename Notifier::ObserverBase Parent; - private: typedef std::allocator Allocator; public: @@ -77,7 +81,7 @@ // \brief Graph initialized map constructor. // // Graph initialized map constructor. - explicit ArrayMap(const Graph& graph) { + explicit ArrayMap(const GraphType& graph) { Parent::attach(graph.notifier(Item())); allocate_memory(); Notifier* nf = Parent::notifier(); @@ -91,7 +95,7 @@ // \brief Constructor to use default value to initialize the map. // // It constructs a map and initialize all of the the map. - ArrayMap(const Graph& graph, const Value& value) { + ArrayMap(const GraphType& graph, const Value& value) { Parent::attach(graph.notifier(Item())); allocate_memory(); Notifier* nf = Parent::notifier(); diff --git a/lemon/bits/base_extender.h b/lemon/bits/base_extender.h --- a/lemon/bits/base_extender.h +++ b/lemon/bits/base_extender.h @@ -38,10 +38,10 @@ // \brief BaseDigraph to BaseGraph extender template class UndirDigraphExtender : public Base { + typedef Base Parent; public: - typedef Base Parent; typedef typename Parent::Arc Edge; typedef typename Parent::Node Node; @@ -280,8 +280,9 @@ template class BidirBpGraphExtender : public Base { + typedef Base Parent; + public: - typedef Base Parent; typedef BidirBpGraphExtender Digraph; typedef typename Parent::Node Node; diff --git a/lemon/bits/default_map.h b/lemon/bits/default_map.h --- a/lemon/bits/default_map.h +++ b/lemon/bits/default_map.h @@ -153,15 +153,16 @@ template class DefaultMap : public DefaultMapSelector<_Graph, _Item, _Value>::Map { + typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent; + public: - typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent; typedef DefaultMap<_Graph, _Item, _Value> Map; - - typedef typename Parent::Graph Graph; + + typedef typename Parent::GraphType GraphType; typedef typename Parent::Value Value; - explicit DefaultMap(const Graph& graph) : Parent(graph) {} - DefaultMap(const Graph& graph, const Value& value) + explicit DefaultMap(const GraphType& graph) : Parent(graph) {} + DefaultMap(const GraphType& graph, const Value& value) : Parent(graph, value) {} DefaultMap& operator=(const DefaultMap& cmap) { diff --git a/lemon/bits/edge_set_extender.h b/lemon/bits/edge_set_extender.h --- a/lemon/bits/edge_set_extender.h +++ b/lemon/bits/edge_set_extender.h @@ -34,9 +34,10 @@ // \brief Extender for the ArcSets template class ArcSetExtender : public Base { + typedef Base Parent; + public: - typedef Base Parent; typedef ArcSetExtender Digraph; // Base extensions @@ -218,10 +219,9 @@ template class ArcMap : public MapExtender > { - public: - typedef ArcSetExtender Digraph; typedef MapExtender > Parent; + public: explicit ArcMap(const Digraph& _g) : Parent(_g) {} ArcMap(const Digraph& _g, const _Value& _v) @@ -274,17 +274,16 @@ // \brief Extender for the EdgeSets template class EdgeSetExtender : public Base { + typedef Base Parent; public: - typedef Base Parent; - typedef EdgeSetExtender Digraph; + typedef EdgeSetExtender Graph; typedef typename Parent::Node Node; typedef typename Parent::Arc Arc; typedef typename Parent::Edge Edge; - int maxId(Node) const { return Parent::maxNodeId(); } @@ -350,22 +349,22 @@ class NodeIt : public Node { - const Digraph* digraph; + const Graph* graph; public: NodeIt() {} NodeIt(Invalid i) : Node(i) { } - explicit NodeIt(const Digraph& _graph) : digraph(&_graph) { + explicit NodeIt(const Graph& _graph) : graph(&_graph) { _graph.first(static_cast(*this)); } - NodeIt(const Digraph& _graph, const Node& node) - : Node(node), digraph(&_graph) {} + NodeIt(const Graph& _graph, const Node& node) + : Node(node), graph(&_graph) {} NodeIt& operator++() { - digraph->next(*this); + graph->next(*this); return *this; } @@ -373,22 +372,22 @@ class ArcIt : public Arc { - const Digraph* digraph; + const Graph* graph; public: ArcIt() { } ArcIt(Invalid i) : Arc(i) { } - explicit ArcIt(const Digraph& _graph) : digraph(&_graph) { + explicit ArcIt(const Graph& _graph) : graph(&_graph) { _graph.first(static_cast(*this)); } - ArcIt(const Digraph& _graph, const Arc& e) : - Arc(e), digraph(&_graph) { } + ArcIt(const Graph& _graph, const Arc& e) : + Arc(e), graph(&_graph) { } ArcIt& operator++() { - digraph->next(*this); + graph->next(*this); return *this; } @@ -396,23 +395,23 @@ class OutArcIt : public Arc { - const Digraph* digraph; + const Graph* graph; public: OutArcIt() { } OutArcIt(Invalid i) : Arc(i) { } - OutArcIt(const Digraph& _graph, const Node& node) - : digraph(&_graph) { + OutArcIt(const Graph& _graph, const Node& node) + : graph(&_graph) { _graph.firstOut(*this, node); } - OutArcIt(const Digraph& _graph, const Arc& arc) - : Arc(arc), digraph(&_graph) {} + OutArcIt(const Graph& _graph, const Arc& arc) + : Arc(arc), graph(&_graph) {} OutArcIt& operator++() { - digraph->nextOut(*this); + graph->nextOut(*this); return *this; } @@ -420,23 +419,23 @@ class InArcIt : public Arc { - const Digraph* digraph; + const Graph* graph; public: InArcIt() { } InArcIt(Invalid i) : Arc(i) { } - InArcIt(const Digraph& _graph, const Node& node) - : digraph(&_graph) { + InArcIt(const Graph& _graph, const Node& node) + : graph(&_graph) { _graph.firstIn(*this, node); } - InArcIt(const Digraph& _graph, const Arc& arc) : - Arc(arc), digraph(&_graph) {} + InArcIt(const Graph& _graph, const Arc& arc) : + Arc(arc), graph(&_graph) {} InArcIt& operator++() { - digraph->nextIn(*this); + graph->nextIn(*this); return *this; } @@ -444,22 +443,22 @@ class EdgeIt : public Parent::Edge { - const Digraph* digraph; + const Graph* graph; public: EdgeIt() { } EdgeIt(Invalid i) : Edge(i) { } - explicit EdgeIt(const Digraph& _graph) : digraph(&_graph) { + explicit EdgeIt(const Graph& _graph) : graph(&_graph) { _graph.first(static_cast(*this)); } - EdgeIt(const Digraph& _graph, const Edge& e) : - Edge(e), digraph(&_graph) { } + EdgeIt(const Graph& _graph, const Edge& e) : + Edge(e), graph(&_graph) { } EdgeIt& operator++() { - digraph->next(*this); + graph->next(*this); return *this; } @@ -467,7 +466,7 @@ class IncEdgeIt : public Parent::Edge { friend class EdgeSetExtender; - const Digraph* digraph; + const Graph* graph; bool direction; public: @@ -475,17 +474,17 @@ IncEdgeIt(Invalid i) : Edge(i), direction(false) { } - IncEdgeIt(const Digraph& _graph, const Node &n) : digraph(&_graph) { + IncEdgeIt(const Graph& _graph, const Node &n) : graph(&_graph) { _graph.firstInc(*this, direction, n); } - IncEdgeIt(const Digraph& _graph, const Edge &ue, const Node &n) - : digraph(&_graph), Edge(ue) { + IncEdgeIt(const Graph& _graph, const Edge &ue, const Node &n) + : graph(&_graph), Edge(ue) { direction = (_graph.source(ue) == n); } IncEdgeIt& operator++() { - digraph->nextInc(*this, direction); + graph->nextInc(*this, direction); return *this; } }; @@ -534,14 +533,13 @@ template class ArcMap - : public MapExtender > { + : public MapExtender > { + typedef MapExtender > Parent; + public: - typedef EdgeSetExtender Digraph; - typedef MapExtender > Parent; - - ArcMap(const Digraph& _g) + ArcMap(const Graph& _g) : Parent(_g) {} - ArcMap(const Digraph& _g, const _Value& _v) + ArcMap(const Graph& _g, const _Value& _v) : Parent(_g, _v) {} ArcMap& operator=(const ArcMap& cmap) { @@ -559,15 +557,14 @@ template class EdgeMap - : public MapExtender > { + : public MapExtender > { + typedef MapExtender > Parent; + public: - typedef EdgeSetExtender Digraph; - typedef MapExtender > Parent; - - EdgeMap(const Digraph& _g) + EdgeMap(const Graph& _g) : Parent(_g) {} - EdgeMap(const Digraph& _g, const _Value& _v) + EdgeMap(const Graph& _g, const _Value& _v) : Parent(_g, _v) {} EdgeMap& operator=(const EdgeMap& cmap) { diff --git a/lemon/bits/graph_adaptor_extender.h b/lemon/bits/graph_adaptor_extender.h --- a/lemon/bits/graph_adaptor_extender.h +++ b/lemon/bits/graph_adaptor_extender.h @@ -26,9 +26,10 @@ template class DigraphAdaptorExtender : public _Digraph { + typedef _Digraph Parent; + public: - typedef _Digraph Parent; typedef _Digraph Digraph; typedef DigraphAdaptorExtender Adaptor; @@ -173,9 +174,10 @@ template class GraphAdaptorExtender : public _Graph { + typedef _Graph Parent; + public: - typedef _Graph Parent; typedef _Graph Graph; typedef GraphAdaptorExtender Adaptor; diff --git a/lemon/bits/graph_extender.h b/lemon/bits/graph_extender.h --- a/lemon/bits/graph_extender.h +++ b/lemon/bits/graph_extender.h @@ -37,9 +37,10 @@ // \brief Extender for the digraph implementations template class DigraphExtender : public Base { + typedef Base Parent; + public: - typedef Base Parent; typedef DigraphExtender Digraph; // Base extensions @@ -218,10 +219,9 @@ template class NodeMap : public MapExtender > { - public: - typedef DigraphExtender Digraph; typedef MapExtender > Parent; + public: explicit NodeMap(const Digraph& digraph) : Parent(digraph) {} NodeMap(const Digraph& digraph, const _Value& value) @@ -243,10 +243,9 @@ template class ArcMap : public MapExtender > { - public: - typedef DigraphExtender Digraph; typedef MapExtender > Parent; + public: explicit ArcMap(const Digraph& digraph) : Parent(digraph) {} ArcMap(const Digraph& digraph, const _Value& value) @@ -330,9 +329,10 @@ // \brief Extender for the Graphs template class GraphExtender : public Base { + typedef Base Parent; + public: - typedef Base Parent; typedef GraphExtender Graph; typedef True UndirectedTag; @@ -601,10 +601,9 @@ template class NodeMap : public MapExtender > { - public: - typedef GraphExtender Graph; typedef MapExtender > Parent; + public: NodeMap(const Graph& graph) : Parent(graph) {} NodeMap(const Graph& graph, const _Value& value) @@ -626,10 +625,9 @@ template class ArcMap : public MapExtender > { - public: - typedef GraphExtender Graph; typedef MapExtender > Parent; + public: ArcMap(const Graph& graph) : Parent(graph) {} ArcMap(const Graph& graph, const _Value& value) @@ -651,10 +649,9 @@ template class EdgeMap : public MapExtender > { - public: - typedef GraphExtender Graph; typedef MapExtender > Parent; + public: EdgeMap(const Graph& graph) : Parent(graph) {} diff --git a/lemon/bits/map_extender.h b/lemon/bits/map_extender.h --- a/lemon/bits/map_extender.h +++ b/lemon/bits/map_extender.h @@ -36,13 +36,12 @@ // \brief Extender for maps template class MapExtender : public _Map { + typedef _Map Parent; + typedef typename Parent::GraphType GraphType; + public: - typedef _Map Parent; typedef MapExtender Map; - - - typedef typename Parent::Graph Graph; typedef typename Parent::Key Item; typedef typename Parent::Key Key; @@ -58,10 +57,10 @@ public: - MapExtender(const Graph& graph) + MapExtender(const GraphType& graph) : Parent(graph) {} - MapExtender(const Graph& graph, const Value& value) + MapExtender(const GraphType& graph, const Value& value) : Parent(graph, value) {} private: @@ -77,9 +76,10 @@ public: class MapIt : public Item { + typedef Item Parent; + public: - typedef Item Parent; typedef typename Map::Value Value; MapIt() {} @@ -116,10 +116,10 @@ }; class ConstMapIt : public Item { + typedef Item Parent; + public: - typedef Item Parent; - typedef typename Map::Value Value; ConstMapIt() {} @@ -147,10 +147,10 @@ }; class ItemIt : public Item { + typedef Item Parent; + public: - typedef Item Parent; - ItemIt() {} ItemIt(Invalid i) : Parent(i) { } @@ -178,13 +178,12 @@ // \brief Extender for maps which use a subset of the items. template class SubMapExtender : public _Map { + typedef _Map Parent; + typedef _Graph GraphType; + public: - typedef _Map Parent; typedef SubMapExtender Map; - - typedef _Graph Graph; - typedef typename Parent::Key Item; typedef typename Parent::Key Key; @@ -200,10 +199,10 @@ public: - SubMapExtender(const Graph& _graph) + SubMapExtender(const GraphType& _graph) : Parent(_graph), graph(_graph) {} - SubMapExtender(const Graph& _graph, const Value& _value) + SubMapExtender(const GraphType& _graph, const Value& _value) : Parent(_graph, _value), graph(_graph) {} private: @@ -223,9 +222,9 @@ public: class MapIt : public Item { + typedef Item Parent; + public: - - typedef Item Parent; typedef typename Map::Value Value; MapIt() {} @@ -262,10 +261,10 @@ }; class ConstMapIt : public Item { + typedef Item Parent; + public: - typedef Item Parent; - typedef typename Map::Value Value; ConstMapIt() {} @@ -293,10 +292,10 @@ }; class ItemIt : public Item { + typedef Item Parent; + public: - typedef Item Parent; - ItemIt() {} ItemIt(Invalid i) : Parent(i) { } @@ -320,7 +319,7 @@ private: - const Graph& graph; + const GraphType& graph; }; diff --git a/lemon/bits/vector_map.h b/lemon/bits/vector_map.h --- a/lemon/bits/vector_map.h +++ b/lemon/bits/vector_map.h @@ -56,7 +56,7 @@ public: // The graph type of the map. - typedef _Graph Graph; + typedef _Graph GraphType; // The item type of the map. typedef _Item Item; // The reference map tag. @@ -72,20 +72,24 @@ // The map type. typedef VectorMap Map; - // The base class of the map. - typedef typename Notifier::ObserverBase Parent; // The reference type of the map; typedef typename Container::reference Reference; // The const reference type of the map; typedef typename Container::const_reference ConstReference; + private: + + // The base class of the map. + typedef typename Notifier::ObserverBase Parent; + + public: // \brief Constructor to attach the new map into the notifier. // // It constructs a map and attachs it into the notifier. // It adds all the items of the graph to the map. - VectorMap(const Graph& graph) { + VectorMap(const GraphType& graph) { Parent::attach(graph.notifier(Item())); container.resize(Parent::notifier()->maxId() + 1); } @@ -94,7 +98,7 @@ // // It constructs a map uses a given value to initialize the map. // It adds all the items of the graph to the map. - VectorMap(const Graph& graph, const Value& value) { + VectorMap(const GraphType& graph, const Value& value) { Parent::attach(graph.notifier(Item())); container.resize(Parent::notifier()->maxId() + 1, value); } diff --git a/lemon/concepts/graph_components.h b/lemon/concepts/graph_components.h --- a/lemon/concepts/graph_components.h +++ b/lemon/concepts/graph_components.h @@ -180,6 +180,9 @@ /// to convert from arcs to edges and to get both direction of edges. class BaseGraphComponent : public BaseDigraphComponent { public: + + typedef BaseGraphComponent Graph; + typedef BaseDigraphComponent::Node Node; typedef BaseDigraphComponent::Arc Arc; @@ -189,9 +192,9 @@ /// Undirected graphs can be used as directed graphs, each edge is /// represented by two opposite directed arcs. class Edge : public GraphItem<'e'> { - public: typedef GraphItem<'e'> Parent; + public: /// \brief Default constructor. /// /// Default constructor. @@ -991,12 +994,10 @@ /// The standard graph maps must conform to the ReferenceMap concept. template class GraphMap : public ReferenceMap { + typedef ReferenceMap Parent; + public: - typedef ReadWriteMap Parent; - - /// The graph type of the map. - typedef GR Graph; /// The key type of the map. typedef K Key; /// The value type of the map. @@ -1012,11 +1013,11 @@ /// \brief Construct a new map. /// /// Construct a new map for the graph. - explicit GraphMap(const Graph&) {} + explicit GraphMap(const GR&) {} /// \brief Construct a new map with default value. /// /// Construct a new map for the graph and initalize the values. - GraphMap(const Graph&, const Value&) {} + GraphMap(const GR&, const Value&) {} private: /// \brief Copy constructor. @@ -1057,7 +1058,7 @@ } const _Map &m; - const Graph &g; + const GR &g; const typename GraphMap::Value &t; }; @@ -1085,9 +1086,9 @@ /// It conforms to the ReferenceMap concept. template class NodeMap : public GraphMap { - public: typedef GraphMap Parent; + public: /// \brief Construct a new map. /// /// Construct a new map for the digraph. @@ -1123,9 +1124,9 @@ /// It conforms to the ReferenceMap concept. template class ArcMap : public GraphMap { - public: typedef GraphMap Parent; + public: /// \brief Construct a new map. /// /// Construct a new map for the digraph. @@ -1221,9 +1222,9 @@ /// It conforms to the ReferenceMap concept. template class EdgeMap : public GraphMap { - public: typedef GraphMap Parent; + public: /// \brief Construct a new map. /// /// Construct a new map for the graph. diff --git a/lemon/core.h b/lemon/core.h --- a/lemon/core.h +++ b/lemon/core.h @@ -1036,26 +1036,25 @@ ///\sa ArcLookUp, AllArcLookUp, DynArcLookUp template class ConArcIt : public GR::Arc { + typedef typename GR::Arc Parent; + public: - typedef GR Graph; - typedef typename Graph::Arc Parent; - - typedef typename Graph::Arc Arc; - typedef typename Graph::Node Node; + typedef typename GR::Arc Arc; + typedef typename GR::Node Node; /// \brief Constructor. /// /// Construct a new ConArcIt iterating on the arcs that /// connects nodes \c u and \c v. - ConArcIt(const Graph& g, Node u, Node v) : _graph(g) { + ConArcIt(const GR& g, Node u, Node v) : _graph(g) { Parent::operator=(findArc(_graph, u, v)); } /// \brief Constructor. /// /// Construct a new ConArcIt that continues the iterating from arc \c a. - ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {} + ConArcIt(const GR& g, Arc a) : Parent(a), _graph(g) {} /// \brief Increment operator. /// @@ -1066,7 +1065,7 @@ return *this; } private: - const Graph& _graph; + const GR& _graph; }; namespace _core_bits { @@ -1159,26 +1158,25 @@ ///\sa findEdge() template class ConEdgeIt : public GR::Edge { + typedef typename GR::Edge Parent; + public: - typedef GR Graph; - typedef typename Graph::Edge Parent; - - typedef typename Graph::Edge Edge; - typedef typename Graph::Node Node; + typedef typename GR::Edge Edge; + typedef typename GR::Node Node; /// \brief Constructor. /// /// Construct a new ConEdgeIt iterating on the edges that /// connects nodes \c u and \c v. - ConEdgeIt(const Graph& g, Node u, Node v) : _graph(g), _u(u), _v(v) { + ConEdgeIt(const GR& g, Node u, Node v) : _graph(g), _u(u), _v(v) { Parent::operator=(findEdge(_graph, _u, _v)); } /// \brief Constructor. /// /// Construct a new ConEdgeIt that continues iterating from edge \c e. - ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {} + ConEdgeIt(const GR& g, Edge e) : Parent(e), _graph(g) {} /// \brief Increment operator. /// @@ -1188,7 +1186,7 @@ return *this; } private: - const Graph& _graph; + const GR& _graph; Node _u, _v; }; @@ -1219,20 +1217,23 @@ class DynArcLookUp : protected ItemSetTraits::ItemNotifier::ObserverBase { - public: typedef typename ItemSetTraits ::ItemNotifier::ObserverBase Parent; TEMPLATE_DIGRAPH_TYPEDEFS(GR); + + public: + + /// The Digraph type typedef GR Digraph; protected: class AutoNodeMap : public ItemSetTraits::template Map::Type { + typedef typename ItemSetTraits::template Map::Type Parent; + public: - typedef typename ItemSetTraits::template Map::Type Parent; - AutoNodeMap(const GR& digraph) : Parent(digraph, INVALID) {} virtual void add(const Node& node) { @@ -1257,12 +1258,6 @@ } }; - const Digraph &_g; - AutoNodeMap _head; - typename Digraph::template ArcMap _parent; - typename Digraph::template ArcMap _left; - typename Digraph::template ArcMap _right; - class ArcLess { const Digraph &g; public: @@ -1273,6 +1268,14 @@ } }; + protected: + + const Digraph &_g; + AutoNodeMap _head; + typename Digraph::template ArcMap _parent; + typename Digraph::template ArcMap _left; + typename Digraph::template ArcMap _right; + public: ///Constructor @@ -1630,8 +1633,11 @@ template class ArcLookUp { + TEMPLATE_DIGRAPH_TYPEDEFS(GR); + public: - TEMPLATE_DIGRAPH_TYPEDEFS(GR); + + /// The Digraph type typedef GR Digraph; protected: @@ -1746,9 +1752,8 @@ using ArcLookUp::_head; TEMPLATE_DIGRAPH_TYPEDEFS(GR); - typedef GR Digraph; - typename Digraph::template ArcMap _next; + typename GR::template ArcMap _next; Arc refreshNext(Arc head,Arc next=INVALID) { @@ -1767,6 +1772,10 @@ } public: + + /// The Digraph type + typedef GR Digraph; + ///Constructor ///Constructor. diff --git a/lemon/edge_set.h b/lemon/edge_set.h --- a/lemon/edge_set.h +++ b/lemon/edge_set.h @@ -33,7 +33,6 @@ class ListArcSetBase { public: - typedef GR Graph; typedef typename GR::Node Node; typedef typename GR::NodeIt NodeIt; @@ -208,10 +207,10 @@ template class NodeMap : public GR::template NodeMap { + typedef typename GR::template NodeMap Parent; + public: - typedef typename GR::template NodeMap Parent; - explicit NodeMap(const ListArcSetBase& arcset) : Parent(*arcset._graph) {} @@ -259,17 +258,13 @@ /// "Digraph" concept. template class ListArcSet : public ArcSetExtender > { + typedef ArcSetExtender > Parent; public: - typedef ArcSetExtender > Parent; - typedef typename Parent::Node Node; typedef typename Parent::Arc Arc; - typedef GR Graph; - - typedef typename Parent::NodesImplBase NodesImplBase; void eraseNode(const Node& node) { @@ -292,9 +287,9 @@ } class NodesImpl : public NodesImplBase { - public: typedef NodesImplBase Parent; + public: NodesImpl(const GR& graph, ListArcSet& arcset) : Parent(graph), _arcset(arcset) {} @@ -354,7 +349,6 @@ class ListEdgeSetBase { public: - typedef GR Graph; typedef typename GR::Node Node; typedef typename GR::NodeIt NodeIt; @@ -637,10 +631,10 @@ template class NodeMap : public GR::template NodeMap { + typedef typename GR::template NodeMap Parent; + public: - typedef typename GR::template NodeMap Parent; - explicit NodeMap(const ListEdgeSetBase& arcset) : Parent(*arcset._graph) {} @@ -688,18 +682,14 @@ /// concept. template class ListEdgeSet : public EdgeSetExtender > { + typedef EdgeSetExtender > Parent; public: - typedef EdgeSetExtender > Parent; - typedef typename Parent::Node Node; typedef typename Parent::Arc Arc; typedef typename Parent::Edge Edge; - typedef GR Graph; - - typedef typename Parent::NodesImplBase NodesImplBase; void eraseNode(const Node& node) { @@ -717,9 +707,9 @@ } class NodesImpl : public NodesImplBase { - public: typedef NodesImplBase Parent; + public: NodesImpl(const GR& graph, ListEdgeSet& arcset) : Parent(graph), _arcset(arcset) {} @@ -779,9 +769,8 @@ class SmartArcSetBase { public: - typedef GR Graph; - typedef typename Graph::Node Node; - typedef typename Graph::NodeIt NodeIt; + typedef typename GR::Node Node; + typedef typename GR::NodeIt NodeIt; protected: @@ -900,10 +889,10 @@ template class NodeMap : public GR::template NodeMap { + typedef typename GR::template NodeMap Parent; + public: - typedef typename GR::template NodeMap Parent; - explicit NodeMap(const SmartArcSetBase& arcset) : Parent(*arcset._graph) { } @@ -956,16 +945,13 @@ /// "Digraph" concept. template class SmartArcSet : public ArcSetExtender > { + typedef ArcSetExtender > Parent; public: - typedef ArcSetExtender > Parent; - typedef typename Parent::Node Node; typedef typename Parent::Arc Arc; - typedef GR Graph; - protected: typedef typename Parent::NodesImplBase NodesImplBase; @@ -983,9 +969,9 @@ } class NodesImpl : public NodesImplBase { - public: typedef NodesImplBase Parent; + public: NodesImpl(const GR& graph, SmartArcSet& arcset) : Parent(graph), _arcset(arcset) {} @@ -1062,7 +1048,6 @@ class SmartEdgeSetBase { public: - typedef GR Graph; typedef typename GR::Node Node; typedef typename GR::NodeIt NodeIt; @@ -1249,10 +1234,10 @@ template class NodeMap : public GR::template NodeMap { + typedef typename GR::template NodeMap Parent; + public: - typedef typename GR::template NodeMap Parent; - explicit NodeMap(const SmartEdgeSetBase& arcset) : Parent(*arcset._graph) { } @@ -1304,17 +1289,14 @@ /// "Graph" concept. template class SmartEdgeSet : public EdgeSetExtender > { + typedef EdgeSetExtender > Parent; public: - typedef EdgeSetExtender > Parent; - typedef typename Parent::Node Node; typedef typename Parent::Arc Arc; typedef typename Parent::Edge Edge; - typedef GR Graph; - protected: typedef typename Parent::NodesImplBase NodesImplBase; @@ -1331,9 +1313,9 @@ } class NodesImpl : public NodesImplBase { - public: typedef NodesImplBase Parent; + public: NodesImpl(const GR& graph, SmartEdgeSet& arcset) : Parent(graph), _arcset(arcset) {} diff --git a/lemon/full_graph.h b/lemon/full_graph.h --- a/lemon/full_graph.h +++ b/lemon/full_graph.h @@ -31,7 +31,7 @@ class FullDigraphBase { public: - typedef FullDigraphBase Graph; + typedef FullDigraphBase Digraph; class Node; class Arc; @@ -169,10 +169,10 @@ /// /// \sa FullGraph class FullDigraph : public ExtendedFullDigraphBase { + typedef ExtendedFullDigraphBase Parent; + public: - typedef ExtendedFullDigraphBase Parent; - /// \brief Constructor FullDigraph() { construct(0); } @@ -226,8 +226,6 @@ class FullGraphBase { - int _node_num; - int _edge_num; public: typedef FullGraphBase Graph; @@ -238,6 +236,9 @@ protected: + int _node_num; + int _edge_num; + FullGraphBase() {} void construct(int n) { _node_num = n; _edge_num = n * (n - 1) / 2; } @@ -537,10 +538,10 @@ /// /// \sa FullDigraph class FullGraph : public ExtendedFullGraphBase { + typedef ExtendedFullGraphBase Parent; + public: - typedef ExtendedFullGraphBase Parent; - /// \brief Constructor FullGraph() { construct(0); } diff --git a/lemon/graph_to_eps.h b/lemon/graph_to_eps.h --- a/lemon/graph_to_eps.h +++ b/lemon/graph_to_eps.h @@ -69,6 +69,7 @@ struct DefaultGraphToEpsTraits { typedef GR Graph; + typedef GR Digraph; typedef typename Graph::Node Node; typedef typename Graph::NodeIt NodeIt; typedef typename Graph::Arc Arc; @@ -241,6 +242,7 @@ // dradnats ++C eht yb deriuqer si ti eveileb t'naC typedef typename T::Graph Graph; + typedef typename T::Digraph Digraph; typedef typename Graph::Node Node; typedef typename Graph::NodeIt NodeIt; typedef typename Graph::Arc Arc; diff --git a/lemon/grid_graph.h b/lemon/grid_graph.h --- a/lemon/grid_graph.h +++ b/lemon/grid_graph.h @@ -499,10 +499,10 @@ /// This graph type fully conforms to the \ref concepts::Graph /// "Graph concept". class GridGraph : public ExtendedGridGraphBase { + typedef ExtendedGridGraphBase Parent; + public: - typedef ExtendedGridGraphBase Parent; - /// \brief Map to get the indices of the nodes as dim2::Point. /// /// Map to get the indices of the nodes as dim2::Point. diff --git a/lemon/hypercube_graph.h b/lemon/hypercube_graph.h --- a/lemon/hypercube_graph.h +++ b/lemon/hypercube_graph.h @@ -294,10 +294,10 @@ /// This graph type fully conforms to the \ref concepts::Graph /// "Graph concept". class HypercubeGraph : public ExtendedHypercubeGraphBase { + typedef ExtendedHypercubeGraphBase Parent; + public: - typedef ExtendedHypercubeGraphBase Parent; - /// \brief Constructs a hypercube graph with \c dim dimensions. /// /// Constructs a hypercube graph with \c dim dimensions. diff --git a/lemon/list_graph.h b/lemon/list_graph.h --- a/lemon/list_graph.h +++ b/lemon/list_graph.h @@ -323,6 +323,8 @@ ///\sa concepts::Digraph class ListDigraph : public ExtendedListDigraphBase { + typedef ExtendedListDigraphBase Parent; + private: ///ListDigraph is \e not copy constructible. Use copyDigraph() instead. @@ -337,8 +339,6 @@ void operator=(const ListDigraph &) {} public: - typedef ExtendedListDigraphBase Parent; - /// Constructor /// Constructor. @@ -793,7 +793,7 @@ public: - typedef ListGraphBase Digraph; + typedef ListGraphBase Graph; class Node; class Arc; @@ -1176,6 +1176,8 @@ ///\sa concepts::Graph class ListGraph : public ExtendedListGraphBase { + typedef ExtendedListGraphBase Parent; + private: ///ListGraph is \e not copy constructible. Use copyGraph() instead. @@ -1195,8 +1197,6 @@ /// ListGraph() {} - typedef ExtendedListGraphBase Parent; - typedef Parent::OutArcIt IncEdgeIt; /// \brief Add a new node to the graph. diff --git a/lemon/maps.h b/lemon/maps.h --- a/lemon/maps.h +++ b/lemon/maps.h @@ -1838,6 +1838,7 @@ public: /// The graph type of IdMap. typedef GR Graph; + typedef GR Digraph; /// The key type of IdMap (\c Node, \c Arc or \c Edge). typedef K Item; /// The key type of IdMap (\c Node, \c Arc or \c Edge). @@ -1929,6 +1930,7 @@ /// The graph type of CrossRefMap. typedef GR Graph; + typedef GR Digraph; /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). typedef K Item; /// The key type of CrossRefMap (\c Node, \c Arc or \c Edge). @@ -2132,6 +2134,7 @@ public: /// The graph type of RangeIdMap. typedef GR Graph; + typedef GR Digraph; /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge). typedef K Item; /// The key type of RangeIdMap (\c Node, \c Arc or \c Edge). @@ -2494,7 +2497,8 @@ public: - /// The digraph type + /// The graph type of InDegMap + typedef GR Graph; typedef GR Digraph; /// The key type typedef typename Digraph::Node Key; @@ -2623,7 +2627,8 @@ public: - /// The digraph type + /// The graph type of OutDegMap + typedef GR Graph; typedef GR Digraph; /// The key type typedef typename Digraph::Node Key; diff --git a/lemon/smart_graph.h b/lemon/smart_graph.h --- a/lemon/smart_graph.h +++ b/lemon/smart_graph.h @@ -55,7 +55,7 @@ public: - typedef SmartDigraphBase Graph; + typedef SmartDigraphBase Digraph; class Node; class Arc; @@ -195,8 +195,6 @@ /// ///\sa concepts::Digraph. class SmartDigraph : public ExtendedSmartDigraphBase { - public: - typedef ExtendedSmartDigraphBase Parent; private: @@ -420,7 +418,7 @@ public: - typedef SmartGraphBase Digraph; + typedef SmartGraphBase Graph; class Node; class Arc; @@ -631,6 +629,8 @@ /// /// \sa concepts::Graph. class SmartGraph : public ExtendedSmartGraphBase { + typedef ExtendedSmartGraphBase Parent; + private: ///SmartGraph is \e not copy constructible. Use GraphCopy() instead. @@ -648,8 +648,6 @@ public: - typedef ExtendedSmartGraphBase Parent; - /// Constructor /// Constructor.