[Lemon-commits] Balazs Dezso: Fixes for MSVC 2008 in grap_adapto...
Lemon HG
hg at lemon.cs.elte.hu
Fri Feb 13 18:55:58 CET 2009
details: http://lemon.cs.elte.hu/hg/lemon/rev/9b9ffe7d9b75
changeset: 517:9b9ffe7d9b75
user: Balazs Dezso <deba [at] inf.elte.hu>
date: Fri Feb 13 13:29:28 2009 +0100
description:
Fixes for MSVC 2008 in grap_adaptors.h and edge_set.h (#194)
Several renamings and changes in adaptors and edge sets
- Fixing scope usage for MSVC
- ResidualDigraph based on SubDigraph instead of FilterArcs
- Use initialize() in adaptors and edge sets
- Wrap ListDigraph for edge set tests
diffstat:
4 files changed, 774 insertions(+), 785 deletions(-)
lemon/adaptors.h | 1171 ++++++++++++++++++++++++-------------------------
lemon/edge_set.h | 376 +++++++--------
test/CMakeLists.txt | 4
test/edge_set_test.cc | 8
diffs (truncated from 3442 to 300 lines):
diff --git a/lemon/adaptors.h b/lemon/adaptors.h
--- a/lemon/adaptors.h
+++ b/lemon/adaptors.h
@@ -36,23 +36,28 @@
namespace lemon {
- template<typename _Digraph>
+#ifdef _MSC_VER
+#define LEMON_SCOPE_FIX(OUTER, NESTED) OUTER::NESTED
+#else
+#define LEMON_SCOPE_FIX(OUTER, NESTED) typename OUTER::template NESTED
+#endif
+
+ template<typename DGR>
class DigraphAdaptorBase {
public:
- typedef _Digraph Digraph;
+ typedef DGR Digraph;
typedef DigraphAdaptorBase Adaptor;
- typedef Digraph ParentDigraph;
protected:
- Digraph* _digraph;
+ DGR* _digraph;
DigraphAdaptorBase() : _digraph(0) { }
- void setDigraph(Digraph& digraph) { _digraph = &digraph; }
+ void initialize(DGR& digraph) { _digraph = &digraph; }
public:
- DigraphAdaptorBase(Digraph& digraph) : _digraph(&digraph) { }
+ DigraphAdaptorBase(DGR& digraph) : _digraph(&digraph) { }
- typedef typename Digraph::Node Node;
- typedef typename Digraph::Arc Arc;
+ typedef typename DGR::Node Node;
+ typedef typename DGR::Arc Arc;
void first(Node& i) const { _digraph->first(i); }
void first(Arc& i) const { _digraph->first(i); }
@@ -67,13 +72,13 @@
Node source(const Arc& a) const { return _digraph->source(a); }
Node target(const Arc& a) const { return _digraph->target(a); }
- typedef NodeNumTagIndicator<Digraph> NodeNumTag;
+ typedef NodeNumTagIndicator<DGR> NodeNumTag;
int nodeNum() const { return _digraph->nodeNum(); }
- typedef ArcNumTagIndicator<Digraph> ArcNumTag;
+ typedef ArcNumTagIndicator<DGR> ArcNumTag;
int arcNum() const { return _digraph->arcNum(); }
- typedef FindArcTagIndicator<Digraph> FindArcTag;
+ typedef FindArcTagIndicator<DGR> FindArcTag;
Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) const {
return _digraph->findArc(u, v, prev);
}
@@ -95,22 +100,22 @@
int maxNodeId() const { return _digraph->maxNodeId(); }
int maxArcId() const { return _digraph->maxArcId(); }
- typedef typename ItemSetTraits<Digraph, Node>::ItemNotifier NodeNotifier;
+ typedef typename ItemSetTraits<DGR, Node>::ItemNotifier NodeNotifier;
NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
- typedef typename ItemSetTraits<Digraph, Arc>::ItemNotifier ArcNotifier;
+ typedef typename ItemSetTraits<DGR, Arc>::ItemNotifier ArcNotifier;
ArcNotifier& notifier(Arc) const { return _digraph->notifier(Arc()); }
- template <typename _Value>
- class NodeMap : public Digraph::template NodeMap<_Value> {
+ template <typename V>
+ class NodeMap : public DGR::template NodeMap<V> {
public:
- typedef typename Digraph::template NodeMap<_Value> Parent;
+ typedef typename DGR::template NodeMap<V> Parent;
explicit NodeMap(const Adaptor& adaptor)
: Parent(*adaptor._digraph) {}
- NodeMap(const Adaptor& adaptor, const _Value& value)
+ NodeMap(const Adaptor& adaptor, const V& value)
: Parent(*adaptor._digraph, value) { }
private:
@@ -126,16 +131,16 @@
};
- template <typename _Value>
- class ArcMap : public Digraph::template ArcMap<_Value> {
+ template <typename V>
+ class ArcMap : public DGR::template ArcMap<V> {
public:
- typedef typename Digraph::template ArcMap<_Value> Parent;
+ typedef typename DGR::template ArcMap<V> Parent;
- explicit ArcMap(const Adaptor& adaptor)
+ explicit ArcMap(const DigraphAdaptorBase<DGR>& adaptor)
: Parent(*adaptor._digraph) {}
- ArcMap(const Adaptor& adaptor, const _Value& value)
+ ArcMap(const DigraphAdaptorBase<DGR>& adaptor, const V& value)
: Parent(*adaptor._digraph, value) {}
private:
@@ -153,25 +158,24 @@
};
- template<typename _Graph>
+ template<typename GR>
class GraphAdaptorBase {
public:
- typedef _Graph Graph;
- typedef Graph ParentGraph;
+ typedef GR Graph;
protected:
- Graph* _graph;
+ GR* _graph;
GraphAdaptorBase() : _graph(0) {}
- void setGraph(Graph& graph) { _graph = &graph; }
+ void initialize(GR& graph) { _graph = &graph; }
public:
- GraphAdaptorBase(Graph& graph) : _graph(&graph) {}
+ GraphAdaptorBase(GR& graph) : _graph(&graph) {}
- typedef typename Graph::Node Node;
- typedef typename Graph::Arc Arc;
- typedef typename Graph::Edge Edge;
+ typedef typename GR::Node Node;
+ typedef typename GR::Arc Arc;
+ typedef typename GR::Edge Edge;
void first(Node& i) const { _graph->first(i); }
void first(Arc& i) const { _graph->first(i); }
@@ -239,22 +243,22 @@
int maxArcId() const { return _graph->maxArcId(); }
int maxEdgeId() const { return _graph->maxEdgeId(); }
- typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier;
+ typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
- typedef typename ItemSetTraits<Graph, Arc>::ItemNotifier ArcNotifier;
+ typedef typename ItemSetTraits<GR, Arc>::ItemNotifier ArcNotifier;
ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
- typedef typename ItemSetTraits<Graph, Edge>::ItemNotifier EdgeNotifier;
+ typedef typename ItemSetTraits<GR, Edge>::ItemNotifier EdgeNotifier;
EdgeNotifier& notifier(Edge) const { return _graph->notifier(Edge()); }
- template <typename _Value>
- class NodeMap : public Graph::template NodeMap<_Value> {
+ template <typename V>
+ class NodeMap : public GR::template NodeMap<V> {
public:
- typedef typename Graph::template NodeMap<_Value> Parent;
- explicit NodeMap(const GraphAdaptorBase<Graph>& adapter)
+ typedef typename GR::template NodeMap<V> Parent;
+ explicit NodeMap(const GraphAdaptorBase<GR>& adapter)
: Parent(*adapter._graph) {}
- NodeMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value)
+ NodeMap(const GraphAdaptorBase<GR>& adapter, const V& value)
: Parent(*adapter._graph, value) {}
private:
@@ -270,13 +274,13 @@
};
- template <typename _Value>
- class ArcMap : public Graph::template ArcMap<_Value> {
+ template <typename V>
+ class ArcMap : public GR::template ArcMap<V> {
public:
- typedef typename Graph::template ArcMap<_Value> Parent;
- explicit ArcMap(const GraphAdaptorBase<Graph>& adapter)
+ typedef typename GR::template ArcMap<V> Parent;
+ explicit ArcMap(const GraphAdaptorBase<GR>& adapter)
: Parent(*adapter._graph) {}
- ArcMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value)
+ ArcMap(const GraphAdaptorBase<GR>& adapter, const V& value)
: Parent(*adapter._graph, value) {}
private:
@@ -291,13 +295,13 @@
}
};
- template <typename _Value>
- class EdgeMap : public Graph::template EdgeMap<_Value> {
+ template <typename V>
+ class EdgeMap : public GR::template EdgeMap<V> {
public:
- typedef typename Graph::template EdgeMap<_Value> Parent;
- explicit EdgeMap(const GraphAdaptorBase<Graph>& adapter)
+ typedef typename GR::template EdgeMap<V> Parent;
+ explicit EdgeMap(const GraphAdaptorBase<GR>& adapter)
: Parent(*adapter._graph) {}
- EdgeMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value)
+ EdgeMap(const GraphAdaptorBase<GR>& adapter, const V& value)
: Parent(*adapter._graph, value) {}
private:
@@ -314,11 +318,11 @@
};
- template <typename _Digraph>
- class ReverseDigraphBase : public DigraphAdaptorBase<_Digraph> {
+ template <typename DGR>
+ class ReverseDigraphBase : public DigraphAdaptorBase<DGR> {
public:
- typedef _Digraph Digraph;
- typedef DigraphAdaptorBase<_Digraph> Parent;
+ typedef DGR Digraph;
+ typedef DigraphAdaptorBase<DGR> Parent;
protected:
ReverseDigraphBase() : Parent() { }
public:
@@ -336,7 +340,7 @@
Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); }
- typedef FindArcTagIndicator<Digraph> FindArcTag;
+ typedef FindArcTagIndicator<DGR> FindArcTag;
Arc findArc(const Node& u, const Node& v,
const Arc& prev = INVALID) const {
return Parent::findArc(v, u, prev);
@@ -356,23 +360,23 @@
/// by adding or removing nodes or arcs, unless the \c GR template
/// parameter is set to be \c const.
///
- /// \tparam GR The type of the adapted digraph.
+ /// \tparam DGR The type of the adapted digraph.
/// It must conform to the \ref concepts::Digraph "Digraph" concept.
/// It can also be specified to be \c const.
///
/// \note The \c Node and \c Arc types of this adaptor and the adapted
/// digraph are convertible to each other.
- template<typename GR>
+ template<typename DGR>
#ifdef DOXYGEN
class ReverseDigraph {
#else
class ReverseDigraph :
- public DigraphAdaptorExtender<ReverseDigraphBase<GR> > {
+ public DigraphAdaptorExtender<ReverseDigraphBase<DGR> > {
#endif
public:
/// The type of the adapted digraph.
- typedef GR Digraph;
- typedef DigraphAdaptorExtender<ReverseDigraphBase<GR> > Parent;
+ typedef DGR Digraph;
+ typedef DigraphAdaptorExtender<ReverseDigraphBase<DGR> > Parent;
protected:
ReverseDigraph() { }
public:
@@ -380,8 +384,8 @@
/// \brief Constructor
///
/// Creates a reverse digraph adaptor for the given digraph.
- explicit ReverseDigraph(Digraph& digraph) {
- Parent::setDigraph(digraph);
+ explicit ReverseDigraph(DGR& digraph) {
+ Parent::initialize(digraph);
}
};
@@ -390,33 +394,31 @@
/// This function just returns a read-only \ref ReverseDigraph adaptor.
/// \ingroup graph_adaptors
/// \relates ReverseDigraph
- template<typename GR>
- ReverseDigraph<const GR> reverseDigraph(const GR& digraph) {
- return ReverseDigraph<const GR>(digraph);
+ template<typename DGR>
+ ReverseDigraph<const DGR> reverseDigraph(const DGR& digraph) {
+ return ReverseDigraph<const DGR>(digraph);
}
- template <typename _Digraph, typename _NodeFilterMap,
- typename _ArcFilterMap, bool _checked = true>
- class SubDigraphBase : public DigraphAdaptorBase<_Digraph> {
+ template <typename DGR, typename NF, typename AF, bool ch = true>
+ class SubDigraphBase : public DigraphAdaptorBase<DGR> {
public:
- typedef _Digraph Digraph;
- typedef _NodeFilterMap NodeFilterMap;
- typedef _ArcFilterMap ArcFilterMap;
+ typedef DGR Digraph;
+ typedef NF NodeFilterMap;
More information about the Lemon-commits
mailing list