From 4c75c1a88dc858f205d8d0ec036c945a5b8dabc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20M=C3=B6ller?= Date: Mon, 22 Oct 2012 16:28:46 +0000 Subject: [PATCH] Implement compatibility between bgl_named_parameters for BOOST_VERSION >= 10510 The implementation of cgal_bgl_named_params (ab)uses internals of bgl_named_params. Those internals have been changed/removed in Boost 1.51 and I have added another implementation that (ab)uses the new internals. --- .../CGAL/boost/graph/named_function_params.h | 159 ++++++++++++++++-- 1 file changed, 144 insertions(+), 15 deletions(-) diff --git a/BGL/include/CGAL/boost/graph/named_function_params.h b/BGL/include/CGAL/boost/graph/named_function_params.h index f1baca36367..c8df45cdcb3 100644 --- a/BGL/include/CGAL/boost/graph/named_function_params.h +++ b/BGL/include/CGAL/boost/graph/named_function_params.h @@ -50,7 +50,16 @@ #include #include #include +#include +#include +// An explanation about the version hackery below: There is no real +// API to introduce custom properties to the Graph API and the +// internals have changed with Boost Version 1.51 and changes aren't +// backward compatible. To work around that we carry around two +// versions of cgal_bgl_named_params. One imitates the pre 1.51 +// bgl_named_params, the newer one hooks into the API through +// inheritance and addition of the some partial specializations. namespace CGAL { enum vertex_is_fixed_t { vertex_is_fixed } ; @@ -60,6 +69,105 @@ namespace CGAL { enum get_placement_policy_t { get_placement_policy } ; enum get_placement_policy_params_t { get_placement_policy_params } ; +#if BOOST_VERSION >= 105100 + template + struct cgal_bgl_named_params : boost::bgl_named_params + { + typedef boost::bgl_named_params base; + typedef cgal_bgl_named_params self; + + cgal_bgl_named_params(T v = T()) : base(v) {} + cgal_bgl_named_params(T v, const Base& b) : base(v, b) {} + + template + cgal_bgl_named_params + vertex_index_map(const IndexMap& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + vertex_point_map(const PointMap& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + vertex_is_fixed_map(const IsFixedMap& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + edge_index_map(const IndexMap& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + edge_is_border_map(const IsBorderMap& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + visitor(const Visitor& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + set_cache(const SetCache& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + get_cost(const GetCost& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + get_cost_params(const GetCostParams& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + get_placement(const GetPlacement& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + + template + cgal_bgl_named_params + get_placement_params(const GetPlacementParams& p) const + { + typedef cgal_bgl_named_params Params; + return Params(p, *this); + } + }; +#else template struct cgal_bgl_named_params : public Base { @@ -164,6 +272,20 @@ namespace CGAL { } }; + template + inline + typename boost::property_value< cgal_bgl_named_params, Tag2>::type + get_param(const cgal_bgl_named_params& p, Tag2 tag2) + { + enum { match = boost::detail::same_property::value }; + typedef typename + boost::property_value< cgal_bgl_named_params, Tag2>::type T2; + T2* t2 = 0; + typedef boost::detail::property_value_dispatch Dispatcher; + return Dispatcher::const_get_value(p, t2, tag2); + } +#endif + template cgal_bgl_named_params vertex_index_map(IndexMap const& p) @@ -251,21 +373,28 @@ namespace CGAL { typedef cgal_bgl_named_params Params; return Params(p); } - - - template - inline - typename boost::property_value< cgal_bgl_named_params, Tag2>::type - get_param(const cgal_bgl_named_params& p, Tag2 tag2) - { - enum { match = boost::detail::same_property::value }; - typedef typename - boost::property_value< cgal_bgl_named_params, Tag2>::type T2; - T2* t2 = 0; - typedef boost::detail::property_value_dispatch Dispatcher; - return Dispatcher::const_get_value(p, t2, tag2); - } - } //namespace CGAL +#if BOOST_VERSION >= 105100 +// partial specializations hate inheritance and we need to repeat +// those here. this is rather fragile. +namespace boost { +template +struct lookup_named_param_def, Def> { + typedef T type; + static const type& get(const bgl_named_params& p, const Def&) { + return p.m_value; + } +}; + +template +struct lookup_named_param_def, Def> { + typedef typename lookup_named_param_def::type type; + static const type& get(const bgl_named_params& p, const Def& def) { + return lookup_named_param_def::get(p.m_base, def); + } +}; +} // boost +#endif + #endif // CGAL_BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP