From cfbd49534538943ebdaade7ea525b04eb32c28e2 Mon Sep 17 00:00:00 2001 From: Jeremy Siek Date: Thu, 5 Apr 2001 04:53:36 +0000 Subject: [PATCH] new file [SVN r9714] --- include/boost/graph/named_function_params.hpp | 149 ++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 include/boost/graph/named_function_params.hpp diff --git a/include/boost/graph/named_function_params.hpp b/include/boost/graph/named_function_params.hpp new file mode 100644 index 00000000..a2f1cb44 --- /dev/null +++ b/include/boost/graph/named_function_params.hpp @@ -0,0 +1,149 @@ +//======================================================================= +// 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 +// +// You should have received a copy of the License Agreement for the +// Boost Graph Library along with the software; see the file LICENSE. +// If not, contact Office of Research, University of Notre Dame, Notre +// Dame, IN 46556. +// +// Permission to modify the code and to distribute modified code is +// granted, provided the text of this NOTICE is retained, a notice that +// the code was modified is included with the above COPYRIGHT NOTICE and +// with the COPYRIGHT NOTICE in the LICENSE file, and that the LICENSE +// file is distributed with the modified code. +// +// LICENSOR MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED. +// By way of example, but not limitation, Licensor MAKES NO +// REPRESENTATIONS OR WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY +// PARTICULAR PURPOSE OR THAT THE USE OF THE LICENSED SOFTWARE COMPONENTS +// OR DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS, TRADEMARKS +// OR OTHER RIGHTS. +//======================================================================= + +#ifndef BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP +#define BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP + +namespace boost { + + namespace bgl_detail { + struct default_param { + default_param() { } + template + default_param(const T&) { } + }; + } + + // Choose the parameter or the default. + template + const Default& + choose_param(const bgl_detail::default_param&, const Default& d) + { return d; } + template + const P& + choose_param(const P& param, const Default&) { return param; } + + bool is_default_param(const bgl_detail::default_param&) { return true; } + template + bool is_default_param(const T&) { return false; } + + template + struct bgl_named_params + { + bgl_named_params(const WeightMap& wm, const DistanceMap& dm, + const ColorMap& cm, const IndexMap& im, + const Visitor& v) + : m_weight_map(wm), m_dist_map(dm), m_color_map(cm), + m_vertex_index_map(im), m_visitor(v) { } + + template + bgl_named_params + weight_map(const WMap& w_map) { + return bgl_named_params + (w_map, m_dist_map, m_color_map, m_vertex_index_map, m_visitor); + } + template + bgl_named_params + distance_map(const DMap& d_map) { + return bgl_named_params + (m_weight_map, d_map, m_color_map, m_vertex_index_map, m_visitor); + } + template + bgl_named_params + color_map(const CMap& c_map) { + return bgl_named_params + (m_weight_map, distance_map, c_map, m_vertex_index_map, m_visitor); + } + template + bgl_named_params + vertex_index_map(const IMap& i_map) { + return bgl_named_params + (m_weight_map, distance_map, color_map, i_map, m_visitor); + } + template + bgl_named_params + visitor(const Vis& vis) { + return bgl_named_params + (m_weight_map, m_dist_map, m_color_map, m_vertex_index_map, vis); + } + const WeightMap& m_weight_map; + const DistanceMap& m_dist_map; + const ColorMap& m_color_map; + const IndexMap& m_vertex_index_map; + const Visitor& m_visitor; + }; + + + template + bgl_named_params + weight_map(const WeightMap& w_map) { + return bgl_named_params(w_map); + } + template + bgl_named_params + distance_map(const DistMap& d_map) + { + bgl_detail::default_param def; + return bgl_named_params + (def, d_map, def, def, def); + } + template + bgl_named_params + color_map(const ColorMap& c_map) + { + bgl_detail::default_param def; + return bgl_named_params(def, def, c_map, def, def); + } + template + bgl_named_params + vertex_index_map(const IndexMap& i_map) + { + bgl_detail::default_param def; + return bgl_named_params + (def, def, def, i_map, def); + } + template + bgl_named_params + use_visitor(const Visitor& vis) + { + bgl_detail::default_param def; + return bgl_named_params + (def, def, def, def, vis); + } + +} // namespace boost + +#endif // BOOST_GRAPH_NAMED_FUNCTION_PARAMS_HPP