| 1 | //======================================================================= |
|---|
| 2 | // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. |
|---|
| 3 | // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek |
|---|
| 4 | // |
|---|
| 5 | // Distributed under the Boost Software License, Version 1.0. (See |
|---|
| 6 | // accompanying file LICENSE_1_0.txt or copy at |
|---|
| 7 | // http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 8 | //======================================================================= |
|---|
| 9 | |
|---|
| 10 | #ifndef BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP |
|---|
| 11 | #define BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP |
|---|
| 12 | |
|---|
| 13 | #include <boost/graph/properties.hpp> |
|---|
| 14 | |
|---|
| 15 | namespace boost { |
|---|
| 16 | |
|---|
| 17 | struct distance_compare_t { }; |
|---|
| 18 | struct distance_combine_t { }; |
|---|
| 19 | struct distance_inf_t { }; |
|---|
| 20 | struct distance_zero_t { }; |
|---|
| 21 | struct buffer_param_t { }; |
|---|
| 22 | struct edge_copy_t { }; |
|---|
| 23 | struct vertex_copy_t { }; |
|---|
| 24 | struct vertex_isomorphism_t { }; |
|---|
| 25 | struct vertex_invariant_t { }; |
|---|
| 26 | struct vertex_invariant1_t { }; |
|---|
| 27 | struct vertex_invariant2_t { }; |
|---|
| 28 | struct edge_compare_t { }; |
|---|
| 29 | struct vertex_max_invariant_t { }; |
|---|
| 30 | struct orig_to_copy_t { }; |
|---|
| 31 | struct root_vertex_t { }; |
|---|
| 32 | struct attractive_force_t { }; |
|---|
| 33 | struct repulsive_force_t { }; |
|---|
| 34 | struct force_pairs_t { }; |
|---|
| 35 | struct cooling_t { }; |
|---|
| 36 | struct vertex_displacement_t { }; |
|---|
| 37 | struct iterations_t { }; |
|---|
| 38 | struct diameter_range_t { }; |
|---|
| 39 | struct learning_constant_range_t { }; |
|---|
| 40 | |
|---|
| 41 | namespace detail { |
|---|
| 42 | template <class T> |
|---|
| 43 | struct wrap_ref { |
|---|
| 44 | wrap_ref(T& r) : ref(r) {} |
|---|
| 45 | T& ref; |
|---|
| 46 | }; |
|---|
| 47 | } |
|---|
| 48 | |
|---|
| 49 | template <typename T, typename Tag, typename Base = no_property> |
|---|
| 50 | struct bgl_named_params : public Base |
|---|
| 51 | { |
|---|
| 52 | typedef bgl_named_params self; |
|---|
| 53 | typedef Base next_type; |
|---|
| 54 | typedef Tag tag_type; |
|---|
| 55 | typedef T value_type; |
|---|
| 56 | bgl_named_params(T v) : m_value(v) { } |
|---|
| 57 | bgl_named_params(T v, const Base& b) : Base(b), m_value(v) { } |
|---|
| 58 | T m_value; |
|---|
| 59 | |
|---|
| 60 | template <typename WeightMap> |
|---|
| 61 | bgl_named_params<WeightMap, edge_weight_t, self> |
|---|
| 62 | weight_map(const WeightMap& pmap) const { |
|---|
| 63 | typedef bgl_named_params<WeightMap, edge_weight_t, self> Params; |
|---|
| 64 | return Params(pmap, *this); |
|---|
| 65 | } |
|---|
| 66 | |
|---|
| 67 | template <typename WeightMap> |
|---|
| 68 | bgl_named_params<WeightMap, edge_weight2_t, self> |
|---|
| 69 | weight_map2(const WeightMap& pmap) const { |
|---|
| 70 | typedef bgl_named_params<WeightMap, edge_weight2_t, self> Params; |
|---|
| 71 | return Params(pmap, *this); |
|---|
| 72 | } |
|---|
| 73 | |
|---|
| 74 | template <typename DistanceMap> |
|---|
| 75 | bgl_named_params<DistanceMap, vertex_distance_t, self> |
|---|
| 76 | distance_map(const DistanceMap& pmap) const { |
|---|
| 77 | typedef bgl_named_params<DistanceMap, vertex_distance_t, self> Params; |
|---|
| 78 | return Params(pmap, *this); |
|---|
| 79 | } |
|---|
| 80 | |
|---|
| 81 | template <typename PredecessorMap> |
|---|
| 82 | bgl_named_params<PredecessorMap, vertex_predecessor_t, self> |
|---|
| 83 | predecessor_map(const PredecessorMap& pmap) const { |
|---|
| 84 | typedef bgl_named_params<PredecessorMap, vertex_predecessor_t, self> |
|---|
| 85 | Params; |
|---|
| 86 | return Params(pmap, *this); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | template <typename RankMap> |
|---|
| 90 | bgl_named_params<RankMap, vertex_rank_t, self> |
|---|
| 91 | rank_map(const RankMap& pmap) const { |
|---|
| 92 | typedef bgl_named_params<RankMap, vertex_rank_t, self> |
|---|
| 93 | Params; |
|---|
| 94 | return Params(pmap, *this); |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | template <typename RootMap> |
|---|
| 98 | bgl_named_params<RootMap, vertex_root_t, self> |
|---|
| 99 | root_map(const RootMap& pmap) const { |
|---|
| 100 | typedef bgl_named_params<RootMap, vertex_root_t, self> |
|---|
| 101 | Params; |
|---|
| 102 | return Params(pmap, *this); |
|---|
| 103 | } |
|---|
| 104 | |
|---|
| 105 | template <typename Vertex> |
|---|
| 106 | bgl_named_params<Vertex, root_vertex_t, self> |
|---|
| 107 | root_vertex(const Vertex& r) const { |
|---|
| 108 | typedef bgl_named_params<Vertex, root_vertex_t, self> Params; |
|---|
| 109 | return Params(r, *this); |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | template <typename EdgeCentralityMap> |
|---|
| 113 | bgl_named_params<EdgeCentralityMap, edge_centrality_t, self> |
|---|
| 114 | edge_centrality_map(const EdgeCentralityMap& r) const { |
|---|
| 115 | typedef bgl_named_params<EdgeCentralityMap, edge_centrality_t, self> Params; |
|---|
| 116 | return Params(r, *this); |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | template <typename CentralityMap> |
|---|
| 120 | bgl_named_params<CentralityMap, vertex_centrality_t, self> |
|---|
| 121 | centrality_map(const CentralityMap& r) const { |
|---|
| 122 | typedef bgl_named_params<CentralityMap, vertex_centrality_t, self> Params; |
|---|
| 123 | return Params(r, *this); |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | template <typename ColorMap> |
|---|
| 127 | bgl_named_params<ColorMap, vertex_color_t, self> |
|---|
| 128 | color_map(const ColorMap& pmap) const { |
|---|
| 129 | typedef bgl_named_params<ColorMap, vertex_color_t, self> Params; |
|---|
| 130 | return Params(pmap, *this); |
|---|
| 131 | } |
|---|
| 132 | |
|---|
| 133 | template <typename ColorMap> |
|---|
| 134 | bgl_named_params<ColorMap, vertex_color_t, self> |
|---|
| 135 | vertex_color_map(const ColorMap& pmap) const { |
|---|
| 136 | typedef bgl_named_params<ColorMap, vertex_color_t, self> Params; |
|---|
| 137 | return Params(pmap, *this); |
|---|
| 138 | } |
|---|
| 139 | |
|---|
| 140 | template <typename ColorMap> |
|---|
| 141 | bgl_named_params<ColorMap, edge_color_t, self> |
|---|
| 142 | edge_color_map(const ColorMap& pmap) const { |
|---|
| 143 | typedef bgl_named_params<ColorMap, edge_color_t, self> Params; |
|---|
| 144 | return Params(pmap, *this); |
|---|
| 145 | } |
|---|
| 146 | |
|---|
| 147 | template <typename CapacityMap> |
|---|
| 148 | bgl_named_params<CapacityMap, edge_capacity_t, self> |
|---|
| 149 | capacity_map(CapacityMap pmap) { |
|---|
| 150 | typedef bgl_named_params<CapacityMap, edge_capacity_t, self> Params; |
|---|
| 151 | return Params(pmap, *this); |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | template <typename Residual_CapacityMap> |
|---|
| 155 | bgl_named_params<Residual_CapacityMap, edge_residual_capacity_t, self> |
|---|
| 156 | residual_capacity_map(Residual_CapacityMap pmap) { |
|---|
| 157 | typedef bgl_named_params<Residual_CapacityMap, |
|---|
| 158 | edge_residual_capacity_t, self> |
|---|
| 159 | Params; |
|---|
| 160 | return Params(pmap, *this); |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | template <typename ReverseMap> |
|---|
| 164 | bgl_named_params<ReverseMap, edge_reverse_t, self> |
|---|
| 165 | reverse_edge_map(ReverseMap pmap) { |
|---|
| 166 | typedef bgl_named_params<ReverseMap, |
|---|
| 167 | edge_reverse_t, self> |
|---|
| 168 | Params; |
|---|
| 169 | return Params(pmap, *this); |
|---|
| 170 | } |
|---|
| 171 | |
|---|
| 172 | template <typename DiscoverTimeMap> |
|---|
| 173 | bgl_named_params<DiscoverTimeMap, vertex_discover_time_t, self> |
|---|
| 174 | discover_time_map(const DiscoverTimeMap& pmap) const { |
|---|
| 175 | typedef bgl_named_params<DiscoverTimeMap, vertex_discover_time_t, self> |
|---|
| 176 | Params; |
|---|
| 177 | return Params(pmap, *this); |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | template <typename LowPointMap> |
|---|
| 181 | bgl_named_params<LowPointMap, vertex_lowpoint_t, self> |
|---|
| 182 | lowpoint_map(const LowPointMap& pmap) const { |
|---|
| 183 | typedef bgl_named_params<LowPointMap, vertex_lowpoint_t, self> |
|---|
| 184 | Params; |
|---|
| 185 | return Params(pmap, *this); |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | template <typename IndexMap> |
|---|
| 189 | bgl_named_params<IndexMap, vertex_index_t, self> |
|---|
| 190 | vertex_index_map(const IndexMap& pmap) const { |
|---|
| 191 | typedef bgl_named_params<IndexMap, vertex_index_t, self> Params; |
|---|
| 192 | return Params(pmap, *this); |
|---|
| 193 | } |
|---|
| 194 | |
|---|
| 195 | template <typename IndexMap> |
|---|
| 196 | bgl_named_params<IndexMap, vertex_index1_t, self> |
|---|
| 197 | vertex_index1_map(const IndexMap& pmap) const { |
|---|
| 198 | typedef bgl_named_params<IndexMap, vertex_index1_t, self> Params; |
|---|
| 199 | return Params(pmap, *this); |
|---|
| 200 | } |
|---|
| 201 | |
|---|
| 202 | template <typename IndexMap> |
|---|
| 203 | bgl_named_params<IndexMap, vertex_index2_t, self> |
|---|
| 204 | vertex_index2_map(const IndexMap& pmap) const { |
|---|
| 205 | typedef bgl_named_params<IndexMap, vertex_index2_t, self> Params; |
|---|
| 206 | return Params(pmap, *this); |
|---|
| 207 | } |
|---|
| 208 | |
|---|
| 209 | template <typename Visitor> |
|---|
| 210 | bgl_named_params<Visitor, graph_visitor_t, self> |
|---|
| 211 | visitor(const Visitor& vis) const { |
|---|
| 212 | typedef bgl_named_params<Visitor, graph_visitor_t, self> Params; |
|---|
| 213 | return Params(vis, *this); |
|---|
| 214 | } |
|---|
| 215 | |
|---|
| 216 | template <typename Compare> |
|---|
| 217 | bgl_named_params<Compare, distance_compare_t, self> |
|---|
| 218 | distance_compare(Compare cmp) const { |
|---|
| 219 | typedef bgl_named_params<Compare, distance_compare_t, self> Params; |
|---|
| 220 | return Params(cmp, *this); |
|---|
| 221 | } |
|---|
| 222 | |
|---|
| 223 | template <typename Combine> |
|---|
| 224 | bgl_named_params<Combine, distance_combine_t, self> |
|---|
| 225 | distance_combine(Combine cmb) const { |
|---|
| 226 | typedef bgl_named_params<Combine, distance_combine_t, self> Params; |
|---|
| 227 | return Params(cmb, *this); |
|---|
| 228 | } |
|---|
| 229 | |
|---|
| 230 | template <typename Init> |
|---|
| 231 | bgl_named_params<Init, distance_inf_t, self> |
|---|
| 232 | distance_inf(Init init) const { |
|---|
| 233 | typedef bgl_named_params<Init, distance_inf_t, self> Params; |
|---|
| 234 | return Params(init, *this); |
|---|
| 235 | } |
|---|
| 236 | |
|---|
| 237 | template <typename Init> |
|---|
| 238 | bgl_named_params<Init, distance_zero_t, self> |
|---|
| 239 | distance_zero(Init init) const { |
|---|
| 240 | typedef bgl_named_params<Init, distance_zero_t, self> Params; |
|---|
| 241 | return Params(init, *this); |
|---|
| 242 | } |
|---|
| 243 | |
|---|
| 244 | template <typename Buffer> |
|---|
| 245 | bgl_named_params<detail::wrap_ref<Buffer>, buffer_param_t, self> |
|---|
| 246 | buffer(Buffer& b) const { |
|---|
| 247 | typedef bgl_named_params<detail::wrap_ref<Buffer>, buffer_param_t, self> |
|---|
| 248 | Params; |
|---|
| 249 | return Params(detail::wrap_ref<Buffer>(b), *this); |
|---|
| 250 | } |
|---|
| 251 | |
|---|
| 252 | template <typename Copier> |
|---|
| 253 | bgl_named_params<Copier, edge_copy_t, self> |
|---|
| 254 | edge_copy(const Copier& c) const { |
|---|
| 255 | typedef bgl_named_params<Copier, edge_copy_t, self> Params; |
|---|
| 256 | return Params(c, *this); |
|---|
| 257 | } |
|---|
| 258 | |
|---|
| 259 | template <typename Copier> |
|---|
| 260 | bgl_named_params<Copier, vertex_copy_t, self> |
|---|
| 261 | vertex_copy(const Copier& c) const { |
|---|
| 262 | typedef bgl_named_params<Copier, vertex_copy_t, self> Params; |
|---|
| 263 | return Params(c, *this); |
|---|
| 264 | } |
|---|
| 265 | |
|---|
| 266 | template <typename Orig2CopyMap> |
|---|
| 267 | bgl_named_params<Orig2CopyMap, orig_to_copy_t, self> |
|---|
| 268 | orig_to_copy(const Orig2CopyMap& c) const { |
|---|
| 269 | typedef bgl_named_params<Orig2CopyMap, orig_to_copy_t, self> Params; |
|---|
| 270 | return Params(c, *this); |
|---|
| 271 | } |
|---|
| 272 | |
|---|
| 273 | template <typename IsoMap> |
|---|
| 274 | bgl_named_params<IsoMap, vertex_isomorphism_t, self> |
|---|
| 275 | isomorphism_map(const IsoMap& c) const { |
|---|
| 276 | typedef bgl_named_params<IsoMap, vertex_isomorphism_t, self> Params; |
|---|
| 277 | return Params(c, *this); |
|---|
| 278 | } |
|---|
| 279 | |
|---|
| 280 | template <typename VertexInvar> |
|---|
| 281 | bgl_named_params<VertexInvar, vertex_invariant_t, self> |
|---|
| 282 | vertex_invariant(const VertexInvar& c) const { |
|---|
| 283 | typedef bgl_named_params<VertexInvar, vertex_invariant_t, self> Params; |
|---|
| 284 | return Params(c, *this); |
|---|
| 285 | } |
|---|
| 286 | |
|---|
| 287 | template <typename VertexDisplacement> |
|---|
| 288 | bgl_named_params<VertexDisplacement, vertex_displacement_t, self> |
|---|
| 289 | displacement_map(const VertexDisplacement& c) const { |
|---|
| 290 | typedef bgl_named_params<VertexDisplacement, vertex_displacement_t, self> Params; |
|---|
| 291 | return Params(c, *this); |
|---|
| 292 | } |
|---|
| 293 | |
|---|
| 294 | template <typename AttractiveForce> |
|---|
| 295 | bgl_named_params<AttractiveForce, attractive_force_t, self> |
|---|
| 296 | attractive_force(const AttractiveForce& c) { |
|---|
| 297 | typedef bgl_named_params<AttractiveForce, attractive_force_t, self> Params; |
|---|
| 298 | return Params(c, *this); |
|---|
| 299 | } |
|---|
| 300 | |
|---|
| 301 | template <typename RepulsiveForce> |
|---|
| 302 | bgl_named_params<RepulsiveForce, repulsive_force_t, self> |
|---|
| 303 | repulsive_force(const RepulsiveForce& c) { |
|---|
| 304 | typedef bgl_named_params<RepulsiveForce, repulsive_force_t, self> Params; |
|---|
| 305 | return Params(c, *this); |
|---|
| 306 | } |
|---|
| 307 | |
|---|
| 308 | template <typename ForcePairs> |
|---|
| 309 | bgl_named_params<ForcePairs, force_pairs_t, self> |
|---|
| 310 | force_pairs(const ForcePairs& c) { |
|---|
| 311 | typedef bgl_named_params<ForcePairs, force_pairs_t, self> Params; |
|---|
| 312 | return Params(c, *this); |
|---|
| 313 | } |
|---|
| 314 | |
|---|
| 315 | template <typename Cooling> |
|---|
| 316 | bgl_named_params<Cooling, cooling_t, self> |
|---|
| 317 | cooling(const Cooling& c) { |
|---|
| 318 | typedef bgl_named_params<Cooling, cooling_t, self> Params; |
|---|
| 319 | return Params(c, *this); |
|---|
| 320 | } |
|---|
| 321 | |
|---|
| 322 | template <typename TP> |
|---|
| 323 | bgl_named_params<TP, iterations_t, self> |
|---|
| 324 | iterations(const TP& c) { |
|---|
| 325 | typedef bgl_named_params<TP, iterations_t, self> Params; |
|---|
| 326 | return Params(c, *this); |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | template<typename TP> |
|---|
| 330 | bgl_named_params<std::pair<TP, TP>, diameter_range_t, self> |
|---|
| 331 | diameter_range(const std::pair<TP, TP>& c) { |
|---|
| 332 | typedef bgl_named_params<std::pair<TP, TP>, diameter_range_t, self> Params; |
|---|
| 333 | return Params(c, *this); |
|---|
| 334 | } |
|---|
| 335 | |
|---|
| 336 | template<typename TP> |
|---|
| 337 | bgl_named_params<std::pair<TP, TP>, learning_constant_range_t, self> |
|---|
| 338 | learning_constant_range(const std::pair<TP, TP>& c) { |
|---|
| 339 | typedef bgl_named_params<std::pair<TP, TP>, learning_constant_range_t, self> |
|---|
| 340 | Params; |
|---|
| 341 | return Params(c, *this); |
|---|
| 342 | } |
|---|
| 343 | }; |
|---|
| 344 | |
|---|
| 345 | template <typename WeightMap> |
|---|
| 346 | bgl_named_params<WeightMap, edge_weight_t> |
|---|
| 347 | weight_map(WeightMap pmap) { |
|---|
| 348 | typedef bgl_named_params<WeightMap, edge_weight_t> Params; |
|---|
| 349 | return Params(pmap); |
|---|
| 350 | } |
|---|
| 351 | |
|---|
| 352 | template <typename WeightMap> |
|---|
| 353 | bgl_named_params<WeightMap, edge_weight2_t> |
|---|
| 354 | weight_map2(WeightMap pmap) { |
|---|
| 355 | typedef bgl_named_params<WeightMap, edge_weight2_t> Params; |
|---|
| 356 | return Params(pmap); |
|---|
| 357 | } |
|---|
| 358 | |
|---|
| 359 | template <typename DistanceMap> |
|---|
| 360 | bgl_named_params<DistanceMap, vertex_distance_t> |
|---|
| 361 | distance_map(DistanceMap pmap) { |
|---|
| 362 | typedef bgl_named_params<DistanceMap, vertex_distance_t> Params; |
|---|
| 363 | return Params(pmap); |
|---|
| 364 | } |
|---|
| 365 | |
|---|
| 366 | template <typename PredecessorMap> |
|---|
| 367 | bgl_named_params<PredecessorMap, vertex_predecessor_t> |
|---|
| 368 | predecessor_map(PredecessorMap pmap) { |
|---|
| 369 | typedef bgl_named_params<PredecessorMap, vertex_predecessor_t> Params; |
|---|
| 370 | return Params(pmap); |
|---|
| 371 | } |
|---|
| 372 | |
|---|
| 373 | template <typename RankMap> |
|---|
| 374 | bgl_named_params<RankMap, vertex_rank_t> |
|---|
| 375 | rank_map(RankMap pmap) { |
|---|
| 376 | typedef bgl_named_params<RankMap, vertex_rank_t> Params; |
|---|
| 377 | return Params(pmap); |
|---|
| 378 | } |
|---|
| 379 | |
|---|
| 380 | template <typename RootMap> |
|---|
| 381 | bgl_named_params<RootMap, vertex_root_t> |
|---|
| 382 | root_map(RootMap pmap) { |
|---|
| 383 | typedef bgl_named_params<RootMap, vertex_root_t> Params; |
|---|
| 384 | return Params(pmap); |
|---|
| 385 | } |
|---|
| 386 | |
|---|
| 387 | template <typename Vertex> |
|---|
| 388 | bgl_named_params<Vertex, root_vertex_t> |
|---|
| 389 | root_vertex(const Vertex& r) { |
|---|
| 390 | typedef bgl_named_params<Vertex, root_vertex_t> Params; |
|---|
| 391 | return Params(r); |
|---|
| 392 | } |
|---|
| 393 | |
|---|
| 394 | template <typename EdgeCentralityMap> |
|---|
| 395 | bgl_named_params<EdgeCentralityMap, edge_centrality_t> |
|---|
| 396 | edge_centrality_map(const EdgeCentralityMap& r) { |
|---|
| 397 | typedef bgl_named_params<EdgeCentralityMap, edge_centrality_t> Params; |
|---|
| 398 | return Params(r); |
|---|
| 399 | } |
|---|
| 400 | |
|---|
| 401 | template <typename CentralityMap> |
|---|
| 402 | bgl_named_params<CentralityMap, vertex_centrality_t> |
|---|
| 403 | centrality_map(const CentralityMap& r) { |
|---|
| 404 | typedef bgl_named_params<CentralityMap, vertex_centrality_t> Params; |
|---|
| 405 | return Params(r); |
|---|
| 406 | } |
|---|
| 407 | |
|---|
| 408 | template <typename ColorMap> |
|---|
| 409 | bgl_named_params<ColorMap, vertex_color_t> |
|---|
| 410 | color_map(ColorMap pmap) { |
|---|
| 411 | typedef bgl_named_params<ColorMap, vertex_color_t> Params; |
|---|
| 412 | return Params(pmap); |
|---|
| 413 | } |
|---|
| 414 | |
|---|
| 415 | template <typename CapacityMap> |
|---|
| 416 | bgl_named_params<CapacityMap, edge_capacity_t> |
|---|
| 417 | capacity_map(CapacityMap pmap) { |
|---|
| 418 | typedef bgl_named_params<CapacityMap, edge_capacity_t> Params; |
|---|
| 419 | return Params(pmap); |
|---|
| 420 | } |
|---|
| 421 | |
|---|
| 422 | template <typename Residual_CapacityMap> |
|---|
| 423 | bgl_named_params<Residual_CapacityMap, edge_residual_capacity_t> |
|---|
| 424 | residual_capacity_map(Residual_CapacityMap pmap) { |
|---|
| 425 | typedef bgl_named_params<Residual_CapacityMap, edge_residual_capacity_t> |
|---|
| 426 | Params; |
|---|
| 427 | return Params(pmap); |
|---|
| 428 | } |
|---|
| 429 | |
|---|
| 430 | template <typename ReverseMap> |
|---|
| 431 | bgl_named_params<ReverseMap, edge_reverse_t> |
|---|
| 432 | reverse_edge_map(ReverseMap pmap) { |
|---|
| 433 | typedef bgl_named_params<ReverseMap, edge_reverse_t> |
|---|
| 434 | Params; |
|---|
| 435 | return Params(pmap); |
|---|
| 436 | } |
|---|
| 437 | |
|---|
| 438 | template <typename DiscoverTimeMap> |
|---|
| 439 | bgl_named_params<DiscoverTimeMap, vertex_discover_time_t> |
|---|
| 440 | discover_time_map(DiscoverTimeMap pmap) { |
|---|
| 441 | typedef bgl_named_params<DiscoverTimeMap, vertex_discover_time_t> Params; |
|---|
| 442 | return Params(pmap); |
|---|
| 443 | } |
|---|
| 444 | |
|---|
| 445 | template <typename LowPointMap> |
|---|
| 446 | bgl_named_params<LowPointMap, vertex_lowpoint_t> |
|---|
| 447 | lowpoint_map(LowPointMap pmap) { |
|---|
| 448 | typedef bgl_named_params<LowPointMap, vertex_lowpoint_t> Params; |
|---|
| 449 | return Params(pmap); |
|---|
| 450 | } |
|---|
| 451 | |
|---|
| 452 | template <typename IndexMap> |
|---|
| 453 | bgl_named_params<IndexMap, vertex_index_t> |
|---|
| 454 | vertex_index_map(IndexMap pmap) { |
|---|
| 455 | typedef bgl_named_params<IndexMap, vertex_index_t> Params; |
|---|
| 456 | return Params(pmap); |
|---|
| 457 | } |
|---|
| 458 | |
|---|
| 459 | template <typename IndexMap> |
|---|
| 460 | bgl_named_params<IndexMap, vertex_index1_t> |
|---|
| 461 | vertex_index1_map(const IndexMap& pmap) { |
|---|
| 462 | typedef bgl_named_params<IndexMap, vertex_index1_t> Params; |
|---|
| 463 | return Params(pmap); |
|---|
| 464 | } |
|---|
| 465 | |
|---|
| 466 | template <typename IndexMap> |
|---|
| 467 | bgl_named_params<IndexMap, vertex_index2_t> |
|---|
| 468 | vertex_index2_map(const IndexMap& pmap) { |
|---|
| 469 | typedef bgl_named_params<IndexMap, vertex_index2_t> Params; |
|---|
| 470 | return Params(pmap); |
|---|
| 471 | } |
|---|
| 472 | |
|---|
| 473 | template <typename Visitor> |
|---|
| 474 | bgl_named_params<Visitor, graph_visitor_t> |
|---|
| 475 | visitor(const Visitor& vis) { |
|---|
| 476 | typedef bgl_named_params<Visitor, graph_visitor_t> Params; |
|---|
| 477 | return Params(vis); |
|---|
| 478 | } |
|---|
| 479 | |
|---|
| 480 | template <typename Compare> |
|---|
| 481 | bgl_named_params<Compare, distance_compare_t> |
|---|
| 482 | distance_compare(Compare cmp) { |
|---|
| 483 | typedef bgl_named_params<Compare, distance_compare_t> Params; |
|---|
| 484 | return Params(cmp); |
|---|
| 485 | } |
|---|
| 486 | |
|---|
| 487 | template <typename Combine> |
|---|
| 488 | bgl_named_params<Combine, distance_combine_t> |
|---|
| 489 | distance_combine(Combine cmb) { |
|---|
| 490 | typedef bgl_named_params<Combine, distance_combine_t> Params; |
|---|
| 491 | return Params(cmb); |
|---|
| 492 | } |
|---|
| 493 | |
|---|
| 494 | template <typename Init> |
|---|
| 495 | bgl_named_params<Init, distance_inf_t> |
|---|
| 496 | distance_inf(Init init) { |
|---|
| 497 | typedef bgl_named_params<Init, distance_inf_t> Params; |
|---|
| 498 | return Params(init); |
|---|
| 499 | } |
|---|
| 500 | |
|---|
| 501 | template <typename Init> |
|---|
| 502 | bgl_named_params<Init, distance_zero_t> |
|---|
| 503 | distance_zero(Init init) { |
|---|
| 504 | typedef bgl_named_params<Init, distance_zero_t> Params; |
|---|
| 505 | return Params(init); |
|---|
| 506 | } |
|---|
| 507 | |
|---|
| 508 | template <typename Buffer> |
|---|
| 509 | bgl_named_params<detail::wrap_ref<Buffer>, buffer_param_t> |
|---|
| 510 | buffer(Buffer& b) { |
|---|
| 511 | typedef bgl_named_params<detail::wrap_ref<Buffer>, buffer_param_t> Params; |
|---|
| 512 | return Params(detail::wrap_ref<Buffer>(b)); |
|---|
| 513 | } |
|---|
| 514 | |
|---|
| 515 | template <typename Copier> |
|---|
| 516 | bgl_named_params<Copier, edge_copy_t> |
|---|
| 517 | edge_copy(const Copier& c) { |
|---|
| 518 | typedef bgl_named_params<Copier, edge_copy_t> Params; |
|---|
| 519 | return Params(c); |
|---|
| 520 | } |
|---|
| 521 | |
|---|
| 522 | template <typename Copier> |
|---|
| 523 | bgl_named_params<Copier, vertex_copy_t> |
|---|
| 524 | vertex_copy(const Copier& c) { |
|---|
| 525 | typedef bgl_named_params<Copier, vertex_copy_t> Params; |
|---|
| 526 | return Params(c); |
|---|
| 527 | } |
|---|
| 528 | |
|---|
| 529 | template <typename Orig2CopyMap> |
|---|
| 530 | bgl_named_params<Orig2CopyMap, orig_to_copy_t> |
|---|
| 531 | orig_to_copy(const Orig2CopyMap& c) { |
|---|
| 532 | typedef bgl_named_params<Orig2CopyMap, orig_to_copy_t> Params; |
|---|
| 533 | return Params(c); |
|---|
| 534 | } |
|---|
| 535 | |
|---|
| 536 | template <typename IsoMap> |
|---|
| 537 | bgl_named_params<IsoMap, vertex_isomorphism_t> |
|---|
| 538 | isomorphism_map(const IsoMap& c) { |
|---|
| 539 | typedef bgl_named_params<IsoMap, vertex_isomorphism_t> Params; |
|---|
| 540 | return Params(c); |
|---|
| 541 | } |
|---|
| 542 | |
|---|
| 543 | template <typename VertexInvar> |
|---|
| 544 | bgl_named_params<VertexInvar, vertex_invariant_t> |
|---|
| 545 | vertex_invariant(const VertexInvar& c) { |
|---|
| 546 | typedef bgl_named_params<VertexInvar, vertex_invariant_t> Params; |
|---|
| 547 | return Params(c); |
|---|
| 548 | } |
|---|
| 549 | |
|---|
| 550 | template <typename VertexDisplacement> |
|---|
| 551 | bgl_named_params<VertexDisplacement, vertex_displacement_t> |
|---|
| 552 | displacement_map(const VertexDisplacement& c) { |
|---|
| 553 | typedef bgl_named_params<VertexDisplacement, vertex_displacement_t> Params; |
|---|
| 554 | return Params(c); |
|---|
| 555 | } |
|---|
| 556 | |
|---|
| 557 | template <typename AttractiveForce> |
|---|
| 558 | bgl_named_params<AttractiveForce, attractive_force_t> |
|---|
| 559 | attractive_force(const AttractiveForce& c) { |
|---|
| 560 | typedef bgl_named_params<AttractiveForce, attractive_force_t> Params; |
|---|
| 561 | return Params(c); |
|---|
| 562 | } |
|---|
| 563 | |
|---|
| 564 | template <typename RepulsiveForce> |
|---|
| 565 | bgl_named_params<RepulsiveForce, repulsive_force_t> |
|---|
| 566 | repulsive_force(const RepulsiveForce& c) { |
|---|
| 567 | typedef bgl_named_params<RepulsiveForce, repulsive_force_t> Params; |
|---|
| 568 | return Params(c); |
|---|
| 569 | } |
|---|
| 570 | |
|---|
| 571 | template <typename ForcePairs> |
|---|
| 572 | bgl_named_params<ForcePairs, force_pairs_t> |
|---|
| 573 | force_pairs(const ForcePairs& c) { |
|---|
| 574 | typedef bgl_named_params<ForcePairs, force_pairs_t> Params; |
|---|
| 575 | return Params(c); |
|---|
| 576 | } |
|---|
| 577 | |
|---|
| 578 | template <typename Cooling> |
|---|
| 579 | bgl_named_params<Cooling, cooling_t> |
|---|
| 580 | cooling(const Cooling& c) { |
|---|
| 581 | typedef bgl_named_params<Cooling, cooling_t> Params; |
|---|
| 582 | return Params(c); |
|---|
| 583 | } |
|---|
| 584 | |
|---|
| 585 | template <typename T> |
|---|
| 586 | bgl_named_params<T, iterations_t> |
|---|
| 587 | iterations(const T& c) { |
|---|
| 588 | typedef bgl_named_params<T, iterations_t> Params; |
|---|
| 589 | return Params(c); |
|---|
| 590 | } |
|---|
| 591 | |
|---|
| 592 | template<typename T> |
|---|
| 593 | bgl_named_params<std::pair<T, T>, diameter_range_t> |
|---|
| 594 | diameter_range(const std::pair<T, T>& c) { |
|---|
| 595 | typedef bgl_named_params<std::pair<T, T>, diameter_range_t> Params; |
|---|
| 596 | return Params(c); |
|---|
| 597 | } |
|---|
| 598 | |
|---|
| 599 | template<typename T> |
|---|
| 600 | bgl_named_params<std::pair<T, T>, learning_constant_range_t> |
|---|
| 601 | learning_constant_range(const std::pair<T, T>& c) { |
|---|
| 602 | typedef bgl_named_params<std::pair<T, T>, learning_constant_range_t> |
|---|
| 603 | Params; |
|---|
| 604 | return Params(c); |
|---|
| 605 | } |
|---|
| 606 | |
|---|
| 607 | //=========================================================================== |
|---|
| 608 | // Functions for extracting parameters from bgl_named_params |
|---|
| 609 | |
|---|
| 610 | template <class Tag1, class Tag2, class T1, class Base> |
|---|
| 611 | inline |
|---|
| 612 | typename property_value< bgl_named_params<T1,Tag1,Base>, Tag2>::type |
|---|
| 613 | get_param(const bgl_named_params<T1,Tag1,Base>& p, Tag2 tag2) |
|---|
| 614 | { |
|---|
| 615 | enum { match = detail::same_property<Tag1,Tag2>::value }; |
|---|
| 616 | typedef typename |
|---|
| 617 | property_value< bgl_named_params<T1,Tag1,Base>, Tag2>::type T2; |
|---|
| 618 | T2* t2 = 0; |
|---|
| 619 | typedef detail::property_value_dispatch<match> Dispatcher; |
|---|
| 620 | return Dispatcher::const_get_value(p, t2, tag2); |
|---|
| 621 | } |
|---|
| 622 | |
|---|
| 623 | |
|---|
| 624 | namespace detail { |
|---|
| 625 | // MSVC++ workaround |
|---|
| 626 | template <class Param> |
|---|
| 627 | struct choose_param_helper { |
|---|
| 628 | template <class Default> struct result { typedef Param type; }; |
|---|
| 629 | template <typename Default> |
|---|
| 630 | static const Param& apply(const Param& p, const Default&) { return p; } |
|---|
| 631 | }; |
|---|
| 632 | template <> |
|---|
| 633 | struct choose_param_helper<error_property_not_found> { |
|---|
| 634 | template <class Default> struct result { typedef Default type; }; |
|---|
| 635 | template <typename Default> |
|---|
| 636 | static const Default& apply(const error_property_not_found&, const Default& d) |
|---|
| 637 | { return d; } |
|---|
| 638 | }; |
|---|
| 639 | } // namespace detail |
|---|
| 640 | |
|---|
| 641 | template <class P, class Default> |
|---|
| 642 | const typename detail::choose_param_helper<P>::template result<Default>::type& |
|---|
| 643 | choose_param(const P& param, const Default& d) { |
|---|
| 644 | return detail::choose_param_helper<P>::apply(param, d); |
|---|
| 645 | } |
|---|
| 646 | |
|---|
| 647 | template <typename T> |
|---|
| 648 | inline bool is_default_param(const T&) { return false; } |
|---|
| 649 | |
|---|
| 650 | inline bool is_default_param(const detail::error_property_not_found&) |
|---|
| 651 | { return true; } |
|---|
| 652 | |
|---|
| 653 | namespace detail { |
|---|
| 654 | |
|---|
| 655 | struct choose_parameter { |
|---|
| 656 | template <class P, class Graph, class Tag> |
|---|
| 657 | struct bind_ { |
|---|
| 658 | typedef const P& const_result_type; |
|---|
| 659 | typedef const P& result_type; |
|---|
| 660 | typedef P type; |
|---|
| 661 | }; |
|---|
| 662 | |
|---|
| 663 | template <class P, class Graph, class Tag> |
|---|
| 664 | static typename bind_<P, Graph, Tag>::const_result_type |
|---|
| 665 | const_apply(const P& p, const Graph&, Tag&) |
|---|
| 666 | { return p; } |
|---|
| 667 | |
|---|
| 668 | template <class P, class Graph, class Tag> |
|---|
| 669 | static typename bind_<P, Graph, Tag>::result_type |
|---|
| 670 | apply(const P& p, Graph&, Tag&) |
|---|
| 671 | { return p; } |
|---|
| 672 | }; |
|---|
| 673 | |
|---|
| 674 | struct choose_default_param { |
|---|
| 675 | template <class P, class Graph, class Tag> |
|---|
| 676 | struct bind_ { |
|---|
| 677 | typedef typename property_map<Graph, Tag>::type |
|---|
| 678 | result_type; |
|---|
| 679 | typedef typename property_map<Graph, Tag>::const_type |
|---|
| 680 | const_result_type; |
|---|
| 681 | typedef typename property_map<Graph, Tag>::const_type |
|---|
| 682 | type; |
|---|
| 683 | }; |
|---|
| 684 | |
|---|
| 685 | template <class P, class Graph, class Tag> |
|---|
| 686 | static typename bind_<P, Graph, Tag>::const_result_type |
|---|
| 687 | const_apply(const P&, const Graph& g, Tag tag) { |
|---|
| 688 | return get(tag, g); |
|---|
| 689 | } |
|---|
| 690 | template <class P, class Graph, class Tag> |
|---|
| 691 | static typename bind_<P, Graph, Tag>::result_type |
|---|
| 692 | apply(const P&, Graph& g, Tag tag) { |
|---|
| 693 | return get(tag, g); |
|---|
| 694 | } |
|---|
| 695 | }; |
|---|
| 696 | |
|---|
| 697 | template <class Param> |
|---|
| 698 | struct choose_property_map { |
|---|
| 699 | typedef choose_parameter type; |
|---|
| 700 | }; |
|---|
| 701 | template <> |
|---|
| 702 | struct choose_property_map<detail::error_property_not_found> { |
|---|
| 703 | typedef choose_default_param type; |
|---|
| 704 | }; |
|---|
| 705 | |
|---|
| 706 | template <class Param, class Graph, class Tag> |
|---|
| 707 | struct choose_pmap_helper { |
|---|
| 708 | typedef typename choose_property_map<Param>::type Selector; |
|---|
| 709 | typedef typename Selector:: template bind_<Param, Graph, Tag> Bind; |
|---|
| 710 | typedef Bind type; |
|---|
| 711 | typedef typename Bind::result_type result_type; |
|---|
| 712 | typedef typename Bind::const_result_type const_result_type; |
|---|
| 713 | typedef typename Bind::type result; |
|---|
| 714 | }; |
|---|
| 715 | |
|---|
| 716 | // used in the max-flow algorithms |
|---|
| 717 | template <class Graph, class P, class T, class R> |
|---|
| 718 | struct edge_capacity_value |
|---|
| 719 | { |
|---|
| 720 | typedef bgl_named_params<P, T, R> Params; |
|---|
| 721 | typedef typename property_value< Params, edge_capacity_t>::type Param; |
|---|
| 722 | typedef typename detail::choose_pmap_helper<Param, Graph, |
|---|
| 723 | edge_capacity_t>::result CapacityEdgeMap; |
|---|
| 724 | typedef typename property_traits<CapacityEdgeMap>::value_type type; |
|---|
| 725 | }; |
|---|
| 726 | |
|---|
| 727 | } // namespace detail |
|---|
| 728 | |
|---|
| 729 | |
|---|
| 730 | // Use this function instead of choose_param() when you want |
|---|
| 731 | // to avoid requiring get(tag, g) when it is not used. |
|---|
| 732 | template <typename Param, typename Graph, typename PropertyTag> |
|---|
| 733 | typename |
|---|
| 734 | detail::choose_pmap_helper<Param,Graph,PropertyTag>::const_result_type |
|---|
| 735 | choose_const_pmap(const Param& p, const Graph& g, PropertyTag tag) |
|---|
| 736 | { |
|---|
| 737 | typedef typename |
|---|
| 738 | detail::choose_pmap_helper<Param,Graph,PropertyTag>::Selector Choice; |
|---|
| 739 | return Choice::const_apply(p, g, tag); |
|---|
| 740 | } |
|---|
| 741 | |
|---|
| 742 | template <typename Param, typename Graph, typename PropertyTag> |
|---|
| 743 | typename detail::choose_pmap_helper<Param,Graph,PropertyTag>::result_type |
|---|
| 744 | choose_pmap(const Param& p, Graph& g, PropertyTag tag) |
|---|
| 745 | { |
|---|
| 746 | typedef typename |
|---|
| 747 | detail::choose_pmap_helper<Param,Graph,PropertyTag>::Selector Choice; |
|---|
| 748 | return Choice::apply(p, g, tag); |
|---|
| 749 | } |
|---|
| 750 | |
|---|
| 751 | } // namespace boost |
|---|
| 752 | |
|---|
| 753 | #endif // BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP |
|---|