PageRenderTime 21ms CodeModel.GetById 14ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/Src/Dependencies/Boost/boost/graph/detail/index.hpp

http://hadesmem.googlecode.com/
C++ Header | 74 lines | 50 code | 13 blank | 11 comment | 0 complexity | 2cccdaa633ec1380d8628675ecc44bec MD5 | raw file
 1// (C) Copyright 2007-2009 Andrew Sutton
 2//
 3// Use, modification and distribution are subject to the
 4// Boost Software License, Version 1.0 (See accompanying file
 5// LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
 6
 7#ifndef BOOST_GRAPH_DETAIL_INDEX_HPP
 8#define BOOST_GRAPH_DETAIL_INDEX_HPP
 9
10#include <boost/graph/graph_traits.hpp>
11
12// The structures in this module are responsible for selecting and defining
13// types for accessing a builting index map. Note that the selection of these
14// types requires the Graph parameter to model either VertexIndexGraph or
15// EdgeIndexGraph.
16
17namespace boost
18{
19    namespace detail
20    {
21        template <typename Graph>
22        struct vertex_indexer
23        {
24            typedef vertex_index_t index_type;
25            typedef typename property_map<Graph, vertex_index_t>::type map_type;
26            typedef typename property_map<Graph, vertex_index_t>::const_type const_map_type;
27            typedef typename property_traits<map_type>::value_type value_type;
28            typedef typename graph_traits<Graph>::vertex_descriptor key_type;
29
30            static const_map_type index_map(const Graph& g)
31            { return get(vertex_index, g); }
32
33            static map_type index_map(Graph& g)
34            { return get(vertex_index, g); }
35
36            static value_type index(key_type k, const Graph& g)
37            { return get(vertex_index, g, k); }
38        };
39
40        template <typename Graph>
41        struct edge_indexer
42        {
43            typedef edge_index_t index_type;
44            typedef typename property_map<Graph, edge_index_t>::type map_type;
45            typedef typename property_map<Graph, edge_index_t>::const_type const_map_type;
46            typedef typename property_traits<map_type>::value_type value_type;
47            typedef typename graph_traits<Graph>::edge_descriptor key_type;
48
49            static const_map_type index_map(const Graph& g)
50            { return get(edge_index, g); }
51
52            static map_type index_map(Graph& g)
53            { return get(edge_index, g); }
54
55            static value_type index(key_type k, const Graph& g)
56            { return get(edge_index, g, k); }
57        };
58
59        // NOTE: The Graph parameter MUST be a model of VertexIndexGraph or
60        // VertexEdgeGraph - whichever type Key is selecting.
61        template <typename Graph, typename Key>
62        struct choose_indexer
63        {
64            typedef typename mpl::if_<
65                    is_same<Key, typename graph_traits<Graph>::vertex_descriptor>,
66                    vertex_indexer<Graph>,
67                    edge_indexer<Graph>
68                >::type indexer_type;
69            typedef typename indexer_type::index_type index_type;
70        };
71    }
72}
73
74#endif