Chris@16: // (C) Copyright 2007-2009 Andrew Sutton Chris@16: // Chris@16: // Use, modification and distribution are subject to the Chris@16: // Boost Software License, Version 1.0 (See accompanying file Chris@16: // LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) Chris@16: Chris@16: #ifndef BOOST_GRAPH_DETAIL_INDEX_HPP Chris@16: #define BOOST_GRAPH_DETAIL_INDEX_HPP Chris@16: Chris@16: #include Chris@16: Chris@16: // The structures in this module are responsible for selecting and defining Chris@16: // types for accessing a builting index map. Note that the selection of these Chris@16: // types requires the Graph parameter to model either VertexIndexGraph or Chris@16: // EdgeIndexGraph. Chris@16: Chris@16: namespace boost Chris@16: { Chris@16: namespace detail Chris@16: { Chris@16: template Chris@16: struct vertex_indexer Chris@16: { Chris@16: typedef vertex_index_t index_type; Chris@16: typedef typename property_map::type map_type; Chris@16: typedef typename property_map::const_type const_map_type; Chris@16: typedef typename property_traits::value_type value_type; Chris@16: typedef typename graph_traits::vertex_descriptor key_type; Chris@16: Chris@16: static const_map_type index_map(const Graph& g) Chris@16: { return get(vertex_index, g); } Chris@16: Chris@16: static map_type index_map(Graph& g) Chris@16: { return get(vertex_index, g); } Chris@16: Chris@16: static value_type index(key_type k, const Graph& g) Chris@16: { return get(vertex_index, g, k); } Chris@16: }; Chris@16: Chris@16: template Chris@16: struct edge_indexer Chris@16: { Chris@16: typedef edge_index_t index_type; Chris@16: typedef typename property_map::type map_type; Chris@16: typedef typename property_map::const_type const_map_type; Chris@16: typedef typename property_traits::value_type value_type; Chris@16: typedef typename graph_traits::edge_descriptor key_type; Chris@16: Chris@16: static const_map_type index_map(const Graph& g) Chris@16: { return get(edge_index, g); } Chris@16: Chris@16: static map_type index_map(Graph& g) Chris@16: { return get(edge_index, g); } Chris@16: Chris@16: static value_type index(key_type k, const Graph& g) Chris@16: { return get(edge_index, g, k); } Chris@16: }; Chris@16: Chris@16: // NOTE: The Graph parameter MUST be a model of VertexIndexGraph or Chris@16: // VertexEdgeGraph - whichever type Key is selecting. Chris@16: template Chris@16: struct choose_indexer Chris@16: { Chris@16: typedef typename mpl::if_< Chris@16: is_same::vertex_descriptor>, Chris@16: vertex_indexer, Chris@16: edge_indexer Chris@16: >::type indexer_type; Chris@16: typedef typename indexer_type::index_type index_type; Chris@16: }; Chris@16: } Chris@16: } Chris@16: Chris@16: #endif