|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r63630 - trunk/boost/graph
From: jewillco_at_[hidden]
Date: 2010-07-04 16:14:46
Author: jewillco
Date: 2010-07-04 16:14:41 EDT (Sun, 04 Jul 2010)
New Revision: 63630
URL: http://svn.boost.org/trac/boost/changeset/63630
Log:
Refactored color map generation code to make it more broadly usable
Text files modified:
trunk/boost/graph/depth_first_search.hpp | 2
trunk/boost/graph/named_function_params.hpp | 62 +++++++++++++++++++++++++++++----------
trunk/boost/graph/random_spanning_tree.hpp | 2
3 files changed, 48 insertions(+), 18 deletions(-)
Modified: trunk/boost/graph/depth_first_search.hpp
==============================================================================
--- trunk/boost/graph/depth_first_search.hpp (original)
+++ trunk/boost/graph/depth_first_search.hpp 2010-07-04 16:14:41 EDT (Sun, 04 Jul 2010)
@@ -297,7 +297,7 @@
depth_first_search
(g,
arg_pack[_visitor | make_dfs_visitor(null_visitor())],
- boost::detail::color_map_maker<VertexListGraph, arg_pack_type>::make_map(g, arg_pack),
+ boost::detail::make_color_map_from_arg_pack(g, arg_pack),
arg_pack[_root_vertex | *vertices(g).first]
);
}
Modified: trunk/boost/graph/named_function_params.hpp
==============================================================================
--- trunk/boost/graph/named_function_params.hpp (original)
+++ trunk/boost/graph/named_function_params.hpp 2010-07-04 16:14:41 EDT (Sun, 04 Jul 2010)
@@ -441,7 +441,7 @@
namespace detail {
template <bool Exists, typename Graph, typename ArgPack, typename Value, typename PM>
- struct color_map_maker_helper {
+ struct map_maker_helper {
typedef PM map_type;
static PM make_map(const Graph&, Value, const PM& pm, const ArgPack&) {
return pm;
@@ -449,7 +449,7 @@
};
template <typename Graph, typename ArgPack, typename Value, typename PM>
- struct color_map_maker_helper<false, Graph, ArgPack, Value, PM> {
+ struct map_maker_helper<false, Graph, ArgPack, Value, PM> {
typedef typename boost::remove_const<
typename override_const_property_t<
typename boost::parameter::value_type<
@@ -476,27 +476,57 @@
}
};
- template <typename Graph, typename ArgPack>
- struct color_map_maker {
+ template <typename Graph, typename ArgPack, typename MapTag, typename ValueType>
+ struct map_maker {
BOOST_STATIC_CONSTANT(
bool,
- has_color_map =
- (parameter_exists<ArgPack, boost::graph::keywords::tag::color_map>
+ has_map =
+ (parameter_exists<ArgPack, MapTag>
::value));
- typedef color_map_maker_helper<has_color_map, Graph, ArgPack, default_color_type,
- typename boost::remove_const<
- typename boost::parameter::value_type<
- ArgPack,
- boost::graph::keywords::tag::color_map,
- int
- >::type
- >::type> helper;
+ typedef map_maker_helper<has_map, Graph, ArgPack, ValueType,
+ typename boost::remove_const<
+ typename boost::parameter::value_type<
+ ArgPack,
+ MapTag,
+ int
+ >::type
+ >::type> helper;
typedef typename helper::map_type map_type;
- static map_type make_map(const Graph& g, const ArgPack& ap) {
- return helper::make_map(g, white_color, ap[boost::graph::keywords::_color_map | 0], ap);
+ static map_type make_map(const Graph& g, const ArgPack& ap, ValueType default_value) {
+ return helper::make_map(g, default_value, ap[::boost::parameter::keyword<MapTag>::instance | 0], ap);
}
};
+ template <typename MapTag, typename ValueType = void>
+ class make_property_map_from_arg_pack_gen {
+ ValueType default_value;
+
+ public:
+ make_property_map_from_arg_pack_gen(ValueType default_value)
+ : default_value(default_value) {}
+
+ template <typename Graph, typename ArgPack>
+ typename map_maker<Graph, ArgPack, MapTag, ValueType>::map_type
+ operator()(const Graph& g, const ArgPack& ap) const {
+ return map_maker<Graph, ArgPack, MapTag, ValueType>::make_map(g, ap, default_value);
+ }
+ };
+
+ template <typename MapTag>
+ class make_property_map_from_arg_pack_gen<MapTag, void> {
+ public:
+ template <typename ValueType, typename Graph, typename ArgPack>
+ typename map_maker<Graph, ArgPack, MapTag, ValueType>::map_type
+ operator()(const Graph& g, const ArgPack& ap, ValueType default_value) const {
+ return map_maker<Graph, ArgPack, MapTag, ValueType>::make_map(g, ap, default_value);
+ }
+ };
+
+ static const
+ make_property_map_from_arg_pack_gen<
+ boost::graph::keywords::tag::color_map,
+ default_color_type>
+ make_color_map_from_arg_pack(white_color);
}
} // namespace boost
Modified: trunk/boost/graph/random_spanning_tree.hpp
==============================================================================
--- trunk/boost/graph/random_spanning_tree.hpp (original)
+++ trunk/boost/graph/random_spanning_tree.hpp 2010-07-04 16:14:41 EDT (Sun, 04 Jul 2010)
@@ -98,7 +98,7 @@
arg_pack[_root_vertex | *vertices(g).first],
arg_pack[_predecessor_map],
arg_pack[_weight_map | static_property_map<double>(1.)],
- boost::detail::color_map_maker<Graph, arg_pack_type>::make_map(g, arg_pack));
+ boost::detail::make_color_map_from_arg_pack(g, arg_pack));
}
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk