//======================================================================= // Copyright 1997, 1998, 1999, 2000 University of Notre Dame. // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek // // This file is part of the Boost Graph Library // // Distributed under the Boost Software License, Version 1.0. (See // accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) //======================================================================= // Copyright (c) 2007 GeometryFactory (France). All rights reserved. // // $URL$ // $Id$ // SPDX-License-Identifier: BSL-1.0 // // Author(s) : Andreas Fabri, Fernando Cacciola #ifndef CGAL_BOOST_GRAPH_NAMED_FUNCTION_PARAMS_H #define CGAL_BOOST_GRAPH_NAMED_FUNCTION_PARAMS_H #include #include #include #if defined(BOOST_MSVC) # pragma warning(push) # pragma warning(disable:4172) // returning address of local variable or temporary #endif #include #if defined(BOOST_MSVC) # pragma warning(pop) #endif #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. #if BOOST_VERSION < 105100 namespace boost{ typedef detail::error_property_not_found param_not_found; template struct lookup_named_param_def { typedef Def type; static const Def& get(const Args&, const Def& def) {return def;} }; 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); } }; } //end of namespace boost #endif #define CGAL_BGL_NP_TEMPLATE_PARAMETERS T, typename Tag, typename Base #define CGAL_BGL_NP_CLASS CGAL::cgal_bgl_named_params namespace CGAL { namespace internal_np{ enum all_default_t { all_default }; //cannot use macro because it takes no argument // for uniformity we import them in this namespace. Note that // it is an import so that if we use the named parameter function // from boost it will work using boost::vertex_index_t; using boost::vertex_index; using boost::graph_visitor_t; using boost::graph_visitor; // define enum types and values for new named parameters #define CGAL_add_named_parameter(X, Y, Z) \ enum X { Y }; #include #undef CGAL_add_named_parameter }//internal_np 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) {} cgal_bgl_named_params all_default() const { typedef cgal_bgl_named_params Params; return Params(*this); } // create the functions for new named parameters and the one imported boost // used to concatenate several parameters #define CGAL_add_named_parameter(X, Y, Z) \ template \ cgal_bgl_named_params \ Z(const K& k) const \ { \ typedef cgal_bgl_named_params Params;\ return Params(k, *this); \ } #include #include #undef CGAL_add_named_parameter }; namespace parameters { cgal_bgl_named_params inline all_default() { typedef cgal_bgl_named_params Params; return Params(); } template cgal_bgl_named_params inline no_parameters(cgal_bgl_named_params) { typedef cgal_bgl_named_params Params; return Params(); } // define free functions for named parameters #define CGAL_add_named_parameter(X, Y, Z) \ template \ cgal_bgl_named_params \ Z(K const& p) \ { \ typedef cgal_bgl_named_params Params;\ return Params(p); \ } #include #include #undef CGAL_add_named_parameter } // namespace parameters } //namespace CGAL // partial specializations hate inheritance and we need to repeat // those here. this is rather fragile. namespace boost { #if BOOST_VERSION < 105100 template inline typename property_value< CGAL::cgal_bgl_named_params, Tag2>::type get_param(const CGAL::cgal_bgl_named_params& p, Tag2 tag2) { enum { match = detail::same_property::value }; typedef typename boost::property_value< CGAL::cgal_bgl_named_params, Tag2>::type T2; T2* t2 = 0; typedef detail::property_value_dispatch Dispatcher; return Dispatcher::const_get_value(p, t2, tag2); } #endif 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 #include #endif // CGAL_BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP