deba@1719
|
1 |
/* -*- C++ -*-
|
deba@1719
|
2 |
*
|
alpar@1956
|
3 |
* This file is a part of LEMON, a generic C++ optimization library
|
alpar@1956
|
4 |
*
|
alpar@1956
|
5 |
* Copyright (C) 2003-2006
|
alpar@1956
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
deba@1719
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
deba@1719
|
8 |
*
|
deba@1719
|
9 |
* Permission to use, modify and distribute this software is granted
|
deba@1719
|
10 |
* provided that this copyright notice appears in all copies. For
|
deba@1719
|
11 |
* precise terms see the accompanying LICENSE file.
|
deba@1719
|
12 |
*
|
deba@1719
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
deba@1719
|
14 |
* express or implied, and with no claim as to its suitability for any
|
deba@1719
|
15 |
* purpose.
|
deba@1719
|
16 |
*
|
deba@1719
|
17 |
*/
|
deba@1719
|
18 |
|
deba@1719
|
19 |
#ifndef LEMON_TRAITS_H
|
deba@1719
|
20 |
#define LEMON_TRAITS_H
|
deba@1719
|
21 |
|
deba@1719
|
22 |
#include <lemon/utility.h>
|
deba@1719
|
23 |
|
deba@1719
|
24 |
///\file
|
deba@1719
|
25 |
///\brief Traits for graphs and maps
|
deba@1719
|
26 |
///
|
deba@1719
|
27 |
|
deba@1719
|
28 |
namespace lemon {
|
deba@1719
|
29 |
template <typename _Graph, typename _Item>
|
deba@1719
|
30 |
class ItemSetTraits {};
|
deba@1719
|
31 |
|
deba@1719
|
32 |
template <typename _Graph>
|
deba@1719
|
33 |
class ItemSetTraits<_Graph, typename _Graph::Node> {
|
deba@1719
|
34 |
public:
|
deba@1719
|
35 |
|
deba@1719
|
36 |
typedef _Graph Graph;
|
deba@1719
|
37 |
|
deba@1719
|
38 |
typedef typename Graph::Node Item;
|
deba@1719
|
39 |
typedef typename Graph::NodeIt ItemIt;
|
deba@1719
|
40 |
|
deba@1719
|
41 |
template <typename _Value>
|
deba@1719
|
42 |
class Map : public Graph::template NodeMap<_Value> {
|
deba@1719
|
43 |
public:
|
deba@1719
|
44 |
typedef typename Graph::template NodeMap<_Value> Parent;
|
deba@1719
|
45 |
typedef typename Parent::Value Value;
|
deba@1719
|
46 |
|
deba@1719
|
47 |
Map(const Graph& _graph) : Parent(_graph) {}
|
deba@1719
|
48 |
Map(const Graph& _graph, const Value& _value)
|
deba@1719
|
49 |
: Parent(_graph, _value) {}
|
deba@1719
|
50 |
};
|
deba@1719
|
51 |
|
deba@1719
|
52 |
};
|
deba@1719
|
53 |
|
deba@1719
|
54 |
template <typename _Graph>
|
deba@1719
|
55 |
class ItemSetTraits<_Graph, typename _Graph::Edge> {
|
deba@1719
|
56 |
public:
|
deba@1719
|
57 |
|
deba@1719
|
58 |
typedef _Graph Graph;
|
deba@1719
|
59 |
|
deba@1719
|
60 |
typedef typename Graph::Edge Item;
|
deba@1719
|
61 |
typedef typename Graph::EdgeIt ItemIt;
|
deba@1719
|
62 |
|
deba@1719
|
63 |
template <typename _Value>
|
deba@1719
|
64 |
class Map : public Graph::template EdgeMap<_Value> {
|
deba@1719
|
65 |
public:
|
deba@1719
|
66 |
typedef typename Graph::template EdgeMap<_Value> Parent;
|
deba@1719
|
67 |
typedef typename Parent::Value Value;
|
deba@1719
|
68 |
|
deba@1719
|
69 |
Map(const Graph& _graph) : Parent(_graph) {}
|
deba@1719
|
70 |
Map(const Graph& _graph, const Value& _value)
|
deba@1719
|
71 |
: Parent(_graph, _value) {}
|
deba@1719
|
72 |
};
|
deba@1719
|
73 |
|
deba@1719
|
74 |
};
|
deba@1719
|
75 |
|
deba@1719
|
76 |
template <typename _Graph>
|
klao@1909
|
77 |
class ItemSetTraits<_Graph, typename _Graph::UEdge> {
|
deba@1719
|
78 |
public:
|
deba@1719
|
79 |
|
deba@1719
|
80 |
typedef _Graph Graph;
|
deba@1719
|
81 |
|
klao@1909
|
82 |
typedef typename Graph::UEdge Item;
|
klao@1909
|
83 |
typedef typename Graph::UEdgeIt ItemIt;
|
deba@1719
|
84 |
|
deba@1719
|
85 |
template <typename _Value>
|
klao@1909
|
86 |
class Map : public Graph::template UEdgeMap<_Value> {
|
deba@1719
|
87 |
public:
|
klao@1909
|
88 |
typedef typename Graph::template UEdgeMap<_Value> Parent;
|
deba@1719
|
89 |
typedef typename Parent::Value Value;
|
deba@1719
|
90 |
|
deba@1719
|
91 |
Map(const Graph& _graph) : Parent(_graph) {}
|
deba@1719
|
92 |
Map(const Graph& _graph, const Value& _value)
|
deba@1719
|
93 |
: Parent(_graph, _value) {}
|
deba@1719
|
94 |
};
|
deba@1719
|
95 |
|
deba@1719
|
96 |
};
|
deba@1719
|
97 |
|
deba@1915
|
98 |
|
deba@1915
|
99 |
template <typename _Graph>
|
deba@1915
|
100 |
class ItemSetTraits<_Graph, typename _Graph::ANode> {
|
deba@1915
|
101 |
public:
|
deba@1915
|
102 |
|
deba@1915
|
103 |
typedef _Graph Graph;
|
deba@1915
|
104 |
|
deba@1915
|
105 |
typedef typename Graph::ANode Item;
|
deba@1915
|
106 |
typedef typename Graph::ANodeIt ItemIt;
|
deba@1915
|
107 |
|
deba@1915
|
108 |
template <typename _Value>
|
deba@1915
|
109 |
class Map : public Graph::template ANodeMap<_Value> {
|
deba@1915
|
110 |
public:
|
deba@1915
|
111 |
typedef typename Graph::template ANodeMap<_Value> Parent;
|
deba@1915
|
112 |
typedef typename Parent::Value Value;
|
deba@1915
|
113 |
|
deba@1915
|
114 |
Map(const Graph& _graph) : Parent(_graph) {}
|
deba@1915
|
115 |
Map(const Graph& _graph, const Value& _value)
|
deba@1915
|
116 |
: Parent(_graph, _value) {}
|
deba@1915
|
117 |
};
|
deba@1915
|
118 |
|
deba@1915
|
119 |
};
|
deba@1915
|
120 |
|
deba@1915
|
121 |
template <typename _Graph>
|
deba@1915
|
122 |
class ItemSetTraits<_Graph, typename _Graph::BNode> {
|
deba@1915
|
123 |
public:
|
deba@1915
|
124 |
|
deba@1915
|
125 |
typedef _Graph Graph;
|
deba@1915
|
126 |
|
deba@1915
|
127 |
typedef typename Graph::BNode Item;
|
deba@1915
|
128 |
typedef typename Graph::BNodeIt ItemIt;
|
deba@1915
|
129 |
|
deba@1915
|
130 |
template <typename _Value>
|
deba@1915
|
131 |
class Map : public Graph::template BNodeMap<_Value> {
|
deba@1915
|
132 |
public:
|
deba@1915
|
133 |
typedef typename Graph::template BNodeMap<_Value> Parent;
|
deba@1915
|
134 |
typedef typename Parent::Value Value;
|
deba@1915
|
135 |
|
deba@1915
|
136 |
Map(const Graph& _graph) : Parent(_graph) {}
|
deba@1915
|
137 |
Map(const Graph& _graph, const Value& _value)
|
deba@1915
|
138 |
: Parent(_graph, _value) {}
|
deba@1915
|
139 |
};
|
deba@1915
|
140 |
|
deba@1915
|
141 |
};
|
deba@1915
|
142 |
|
deba@1915
|
143 |
|
deba@1719
|
144 |
template <typename Map, typename Enable = void>
|
deba@1719
|
145 |
struct MapTraits {
|
deba@1719
|
146 |
typedef False ReferenceMapTag;
|
deba@1719
|
147 |
|
deba@1719
|
148 |
typedef typename Map::Key Key;
|
deba@1719
|
149 |
typedef typename Map::Value Value;
|
deba@1719
|
150 |
|
deba@1790
|
151 |
typedef const Value ConstReturnValue;
|
deba@1790
|
152 |
typedef const Value ReturnValue;
|
deba@1719
|
153 |
};
|
deba@1719
|
154 |
|
deba@1719
|
155 |
template <typename Map>
|
deba@1719
|
156 |
struct MapTraits<
|
deba@1719
|
157 |
Map, typename enable_if<typename Map::ReferenceMapTag, void>::type >
|
deba@1719
|
158 |
{
|
deba@1719
|
159 |
typedef True ReferenceMapTag;
|
deba@1719
|
160 |
|
deba@1719
|
161 |
typedef typename Map::Key Key;
|
deba@1719
|
162 |
typedef typename Map::Value Value;
|
deba@1719
|
163 |
|
deba@1719
|
164 |
typedef typename Map::ConstReference ConstReturnValue;
|
deba@1719
|
165 |
typedef typename Map::Reference ReturnValue;
|
deba@1719
|
166 |
|
deba@1719
|
167 |
typedef typename Map::ConstReference ConstReference;
|
deba@1719
|
168 |
typedef typename Map::Reference Reference;
|
deba@1719
|
169 |
};
|
deba@1719
|
170 |
|
deba@1719
|
171 |
// Indicators for the tags
|
deba@1719
|
172 |
|
deba@1719
|
173 |
template <typename Graph, typename Enable = void>
|
deba@1719
|
174 |
struct NodeNumTagIndicator {
|
deba@1719
|
175 |
static const bool value = false;
|
deba@1719
|
176 |
};
|
deba@1719
|
177 |
|
deba@1719
|
178 |
template <typename Graph>
|
deba@1719
|
179 |
struct NodeNumTagIndicator<
|
deba@1719
|
180 |
Graph,
|
deba@1719
|
181 |
typename enable_if<typename Graph::NodeNumTag, void>::type
|
deba@1719
|
182 |
> {
|
deba@1719
|
183 |
static const bool value = true;
|
deba@1719
|
184 |
};
|
deba@1719
|
185 |
|
deba@1719
|
186 |
template <typename Graph, typename Enable = void>
|
deba@1719
|
187 |
struct EdgeNumTagIndicator {
|
deba@1719
|
188 |
static const bool value = false;
|
deba@1719
|
189 |
};
|
deba@1719
|
190 |
|
deba@1719
|
191 |
template <typename Graph>
|
deba@1719
|
192 |
struct EdgeNumTagIndicator<
|
deba@1719
|
193 |
Graph,
|
deba@1719
|
194 |
typename enable_if<typename Graph::EdgeNumTag, void>::type
|
deba@1719
|
195 |
> {
|
deba@1719
|
196 |
static const bool value = true;
|
deba@1719
|
197 |
};
|
deba@1719
|
198 |
|
deba@1719
|
199 |
template <typename Graph, typename Enable = void>
|
deba@1719
|
200 |
struct FindEdgeTagIndicator {
|
deba@1719
|
201 |
static const bool value = false;
|
deba@1719
|
202 |
};
|
deba@1719
|
203 |
|
deba@1719
|
204 |
template <typename Graph>
|
deba@1719
|
205 |
struct FindEdgeTagIndicator<
|
deba@1719
|
206 |
Graph,
|
deba@1719
|
207 |
typename enable_if<typename Graph::FindEdgeTag, void>::type
|
deba@1719
|
208 |
> {
|
deba@1719
|
209 |
static const bool value = true;
|
deba@1719
|
210 |
};
|
deba@1719
|
211 |
|
deba@1979
|
212 |
template <typename Graph, typename Enable = void>
|
deba@1979
|
213 |
struct UndirectedTagIndicator {
|
deba@1979
|
214 |
static const bool value = false;
|
deba@1979
|
215 |
};
|
deba@1979
|
216 |
|
deba@1979
|
217 |
template <typename Graph>
|
deba@1979
|
218 |
struct UndirectedTagIndicator<
|
deba@1979
|
219 |
Graph,
|
deba@1979
|
220 |
typename enable_if<typename Graph::UndirectedTag, void>::type
|
deba@1979
|
221 |
> {
|
deba@1979
|
222 |
static const bool value = true;
|
deba@1979
|
223 |
};
|
deba@1979
|
224 |
|
deba@1719
|
225 |
|
deba@1719
|
226 |
|
deba@1719
|
227 |
}
|
deba@1719
|
228 |
|
deba@1719
|
229 |
#endif // LEMON_MAPS_H
|